text:
module KuboOscillatorProblem

    using GeometricIntegrators.Equations

    export kubo_oscillator_sde_1, kubo_oscillator_psde_1, kubo_oscillator_spsde_1
    export kubo_oscillator_sde_2, kubo_oscillator_psde_2, kubo_oscillator_spsde_2
    export kubo_oscillator_sde_3, kubo_oscillator_psde_3, kubo_oscillator_spsde_3

    q_init_A=[0.5, 0.0]
    q_init_B=[0.5 0.0 -0.5; 0.0 0.5 0.0]

    const noise_intensity = 0.1

    const Δt = 0.01
    const nt = 10

    function kubo_oscillator_sde_v(t, q, v_out)
        v_out[1]=  q[2]
        v_out[2]= -q[1]
    end

    function kubo_oscillator_sde_B(t, q, B_out::AbstractVector, ν=noise_intensity)
        B_out[1] = +ν*q[2]
        B_out[2] = -ν*q[1]
    end

    function kubo_oscillator_sde_B(t, q, B_out::AbstractMatrix, col=1, ν=noise_intensity)
        B_out[1,col] = +ν*q[2]
        B_out[2,col] = -ν*q[1]
    end

    function kubo_oscillator_sde_1(q₀=q_init_A)
        # q_init_A - single deterministic initial condition
        # Generating 3 sample paths
        # 1-dimensional noise
        SDE(1, 3, kubo_oscillator_sde_v, kubo_oscillator_sde_B, q₀)
    end

    function kubo_oscillator_sde_2(q₀=q_init_B)
        # q_init_B - interpreted as three random initial conditions
        # The 3 columns correspond to 3 sample paths
        # 1-dimensional noise
        SDE(1, 1, kubo_oscillator_sde_v, kubo_oscillator_sde_B, q₀)
    end

    function kubo_oscillator_sde_3(q₀=q_init_A)
        # q_init_A - interpreted as one random initial conditions with one sample path
        # 1-dimensional noise
        SDE(1, 1, kubo_oscillator_sde_v, kubo_oscillator_sde_B, q₀)
    end

    # PSDE

    q_init_C=[0.5]
    p_init_C=[0.0]

    q_init_D=[0.5 0.0 -0.5]
    p_init_D=[0.0 0.5 0.0]

    function kubo_oscillator_psde_v(t, q, p, v_out)
        v_out[1] =  p[1]
    end

    function kubo_oscillator_psde_f(t, q, p, f_out)
        f_out[1] = -q[1]
    end

    function kubo_oscillator_psde_B(t, q, p, B_out, ν=noise_intensity)
        B_out[1,1] = +ν*p[1]
    end

    function kubo_oscillator_psde_G(t, q, p, G_out, ν=noise_intensity)
        G_out[1,1] = -ν*q[1]
    end

    function kubo_oscillator_psde_1(q₀=q_init_C, p₀=p_init_C)
        # q_init_C - single deterministic initial condition
        # Generating 3 sample paths
        # 1-dimensional noise
        PSDE(1, 3, kubo_oscillator_psde_v, kubo_oscillator_psde_f, kubo_oscillator_psde_B, kubo_oscillator_psde_G, q₀, p₀)
    end

    function kubo_oscillator_psde_2(q₀=q_init_D, p₀=p_init_D)
        # q_init_D - interpreted as a single random initial condition
        # The 3 columns correspond to 3 sample paths
        # 1-dimensional noise
        PSDE(1, 1, kubo_oscillator_psde_v, kubo_oscillator_psde_f, kubo_oscillator_psde_B, kubo_oscillator_psde_G, q₀, p₀)
    end

    function kubo_oscillator_psde_3(q₀=q_init_C, p₀=p_init_C)
        # q_init_C - interpreted as a single random initial condition with one sample path
        # 1-dimensional noise
        PSDE(1, 1, kubo_oscillator_psde_v, kubo_oscillator_psde_f, kubo_oscillator_psde_B, kubo_oscillator_psde_G, q₀, p₀)
    end

    # SPSDE

    function kubo_oscillator_spsde_v(t, q, p, v_out)
        v_out[1] =  p[1]
    end

    function kubo_oscillator_spsde_f1(t, q, p, f_out)
        f_out[1] = -q[1]
    end

    function kubo_oscillator_spsde_f2(t, q, p, f_out)
        f_out[1] = 0
    end

    function kubo_oscillator_spsde_B(t, q, p, B_out, ν=noise_intensity)
        B_out[1,1] = +ν*p[1]
    end

    function kubo_oscillator_spsde_G1(t, q, p, G_out, ν=noise_intensity)
        G_out[1,1] = -ν*q[1]
    end

    function kubo_oscillator_spsde_G2(t, q, p, G_out, ν=noise_intensity)
        G_out[1,1] = 0
    end

    function kubo_oscillator_spsde_1(q₀=q_init_C, p₀=p_init_C)
        # q_init_C - single deterministic initial condition
        # Generating 3 sample paths
        # 1-dimensional noise
        SPSDE(1, 3, kubo_oscillator_spsde_v, kubo_oscillator_spsde_f1, kubo_oscillator_spsde_f2, kubo_oscillator_spsde_B, kubo_oscillator_spsde_G1, kubo_oscillator_spsde_G2, q₀, p₀)
    end

    function kubo_oscillator_spsde_2(q₀=q_init_D, p₀=p_init_D)
        # q_init_D - interpreted as a single random initial condition
        # The 3 columns correspond to 3 sample paths
        # 1-dimensional noise
        SPSDE(1, 1, kubo_oscillator_spsde_v, kubo_oscillator_spsde_f1, kubo_oscillator_spsde_f2, kubo_oscillator_spsde_B, kubo_oscillator_spsde_G1, kubo_oscillator_spsde_G2, q₀, p₀)
    end

    function kubo_oscillator_spsde_3(q₀=q_init_C, p₀=p_init_C)
        # q_init_C - interpreted as a single random initial condition with one sample path
        # 1-dimensional noise
        SPSDE(1, 1, kubo_oscillator_spsde_v, kubo_oscillator_spsde_f1, kubo_oscillator_spsde_f2, kubo_oscillator_spsde_B, kubo_oscillator_spsde_G1, kubo_oscillator_spsde_G2, q₀, p₀)
    end

end


text:
baremodule SyncBarriers

export
    # Types:
    Barrier,
    CentralizedBarrier,
    DisseminationBarrier,
    FlatTreeBarrier,
    StaticTreeBarrier,
    TreeBarrier,
    # Functions:
    arrive!,
    cycle!,
    depart!,
    fuzzy_barrier,
    fuzzy_reduce_barrier,
    reduce!,
    reduce_arrive!,
    reduce_barrier

abstract type Barrier end

# Factories
function fuzzy_barrier end
function fuzzy_reduce_barrier end
function reduce_barrier end

# Synchronizing API
function cycle! end
function arrive! end
function depart! end
function reduce! end
function reduce_arrive! end

abstract type CentralizedBarrier <: Barrier end
abstract type DisseminationBarrier <: Barrier end
abstract type TreeBarrier{N,T} <: Barrier end
abstract type FlatTreeBarrier{N,T} <: Barrier end
abstract type StaticTreeBarrier{NArrive,NDepart,T} <: Barrier end

module Internal

using ArgCheck: ArgCheck, @argcheck, @check
using RecordArrays

using ..SyncBarriers: SyncBarriers

include("utils.jl")
include("oneway.jl")
include("common.jl")
include("centralized_barrier.jl")
include("dissemination_barrier.jl")
include("static_tree_barrier.jl")
include("tree_barrier.jl")
include("flat_tree_barrier.jl")
include("barrier_api.jl")

end  # module Internal

Internal.define_docstrings()

end  # baremodule SyncBarriers

ext: jl


text:
using LinearAlgebra
import HomotopyContinuation: Variable
import HarmonicBalance: Problem; export Problem
export Num_to_Variable

"Conversion from Symbolics.jl types to HomotopyContinuation types."
Variable(var::Num) = var.val isa SymbolicUtils.Term ? Variable(string(var.val.f)) : Variable(string(var_name(var)))

"Converts a Num into Variable in the active namespace."
function Num_to_Variable(x::Num)
    var = Variable(x)
    s = Symbol(string(var))
    @eval (($s) = ($var))
end

"Converts a Num dictionary into a Variable dictionary."
Num_to_Variable(dict::Dict{Num, ComplexF64}) = Dict{Variable, ComplexF64}([[Variable(key), dict[key]] for key in keys(dict)]) # for the parameter assignments

"Parse symbolic expressions as the Expression type in HomotopyContinuation."
function parse_equations(eqs::Vector{Num})
    parsed_strings = [Meta.parse(s) for s in string.(eqs)]
    return [Expression(eval(symbol)) for symbol in parsed_strings]
end

"Declare a new variable in the the current namespace."
 function declare_variable(name::String)
    var_sym = Symbol(name)
    @eval($(var_sym) = first(@variables $var_sym))
    return eval(var_sym)
 end

declare_variable(x::Num) = declare_variable(string(x))

"Constructor for the type `Problem` (to be solved by HomotopyContinuation)
from a `HarmonicEquation`."
function Problem(eom::HarmonicEquation; Jacobian=true)

    S = System(eom)
    # use the rearranged system for the proper definition of the Jacobian
    # this possibly has variables in the denominator and cannot be used for solving
    if Jacobian == true || Jacobian == "explicit"
        J = HarmonicBalance.get_Jacobian(eom)
    elseif Jacobian == "implicit"
        # compute the Jacobian implicitly
        J = HarmonicBalance.LinearResponse.get_implicit_Jacobian(eom)
    elseif Jacobian == "false" || Jacobian == false
        dummy_J(arg) = I(1)
        J = dummy_J
    else
        J = Jacobian
    end
    vars_orig  = get_variables(eom)
    vars_new = declare_variable.(HarmonicBalance.var_name.(vars_orig))
    return Problem(vars_new, eom.parameters, S, J,eom)
end

"A constructor for Problem from explicitly entered equations, variables and parameters."
function Problem(equations::Vector{Num},variables::Vector{Num},parameters::Vector{Num})
    conv_vars = Num_to_Variable.(variables)
    conv_para = Num_to_Variable.(parameters)

    eqs_HC=[Expression(eval(symbol)) for symbol in [Meta.parse(s) for s in [string(eq) for eq in equations]]] #note in polar coordinates there could be imaginary factors, requiring the extra replacement "I"=>"1im"
    system = HomotopyContinuation.System(eqs_HC, variables = conv_vars, parameters = conv_para)
    J = HarmonicBalance.get_Jacobian(equations,variables) #all derivatives are assumed to be in the left hand side;
    return Problem(variables,parameters,system,J)
end

function System(eom::HarmonicEquation)
    eqs = expand_derivatives.(_remove_brackets(eom))
    conv_vars = Num_to_Variable.(get_variables(eom))
    conv_para = Num_to_Variable.(eom.parameters)
    S = HomotopyContinuation.System(parse_equations(eqs),variables=conv_vars,parameters=conv_para)
end

###
# DEPRECATED
###

#=

"Parse symbolic expressions as the Expression type in HomotopyContinuation."
function parse_equations(eqs::HarmonicEquation)
    equation_strings = string.(HarmonicBalance._equations_without_brackets(eqs))
    println(equation_strings)
    parsed_strings = [Meta.parse(s) for s in equation_strings]
    return [Expression(eval(symbol)) for symbol in parsed_strings]
end

"""
$(TYPEDSIGNATURES)
Return the Jacobian of the solution `s` (specifies all variables and parameters)
of `problem`.
"""
function Jacobian(s::Dict, problem::Problem; im_tol=im_tol)
    #svar = Num_to_Variable(s)
    #isnan(prod(values(svar))) && error("trying to find the Jacobian of an invalid solution")
    #!HarmonicBalance.is_physical(s, problem, im_tol=im_tol) && error("unphysical solutions have no Jacobian")
    return substitute_all(problem.jacobian, s)
end

function Jacobian(s::Dict, res::HarmonicBalance.Result; im_tol=im_tol)
    J = res.jacobian
    vals = [s[var] for var in cat(res.problem.variables, collect(keys(res.swept_parameters)), dims=1)]
    return real.([Base.invokelatest(el, vals) for el in J])
end

function construct_Jacobian(eom::HarmonicEquation)
    parameters = declare_variable.(eom.parameters)
    time = declare_variable(get_independent_variables(eom)[1])
    variables = declare_variable.(HarmonicBalance.var_name.(get_variables(eom)))
    dummy_system = deepcopy(eom)
    eqs = HarmonicBalance.equation_without_brackets(eom)
    #dummy_system.equations = [eval(Meta.parse(string(eq))) for eq in eqs]
    #Symbolics.solve_for(dummy_system.equations .~ dummy_system.left_hand_side, d.(get_variables(eom), time))
    #S_rearranged = HomotopyContinuation.System(equations_hc(rearranged),variables=conv_vars,parameters=conv_para)
end
=#

#=
"Converts a Variable into Sym in the HomotopySolving namespace"
function Variable_to_Num(x::Variable)
    #s = Symbol(x.name)
    s = Symbol(string(x))
    var = @variables($s)
    var = var[1]
    display(typeof(var))
    s = Symbol(string(x))
    @eval (($s) = ($var))
end

"Performs multiple replacements on a string. REPLACEMENTS ARE PERFORMED IN SUCCESSION, EACH ONLY ONCE"
function replace_string_successive(old_string::String, rules::Vector{Pair{String, String}})
    new_string = old_string
    for rule in rules
        new_string = Base.replace(new_string, rule)
    end
    new_string
end
=#


text:
# This file is a part of Julia. License is MIT: https://julialang.org/license

module Partr

using ..Threads: SpinLock, nthreads, threadid

# a task minheap
mutable struct taskheap
    const lock::SpinLock
    const tasks::Vector{Task}
    @atomic ntasks::Int32
    @atomic priority::UInt16
    taskheap() = new(SpinLock(), Vector{Task}(undef, 256), zero(Int32), typemax(UInt16))
end

# multiqueue minheap state
const heap_d = UInt32(8)
const heaps = [Vector{taskheap}(undef, 0), Vector{taskheap}(undef, 0)]
const heaps_lock = [SpinLock(), SpinLock()]
const cong_unbias = [typemax(UInt32), typemax(UInt32)]

cong(max::UInt32, unbias::UInt32) =
    ccall(:jl_rand_ptls, UInt32, (UInt32, UInt32), max, unbias) + UInt32(1)

function unbias_cong(max::UInt32)
    return typemax(UInt32) - ((typemax(UInt32) % max) + UInt32(1))
end

function multiq_sift_up(heap::taskheap, idx::Int32)
    while idx > Int32(1)
        parent = (idx - Int32(2)) ÷ heap_d + Int32(1)
        if heap.tasks[idx].priority < heap.tasks[parent].priority
            t = heap.tasks[parent]
            heap.tasks[parent] = heap.tasks[idx]
            heap.tasks[idx] = t
            idx = parent
        else
            break
        end
    end
end

function multiq_sift_down(heap::taskheap, idx::Int32)
    if idx <= heap.ntasks
        for child = (heap_d * idx - heap_d + 2):(heap_d * idx + 1)
            child = Int(child)
            child > length(heap.tasks) && break
            if isassigned(heap.tasks, child) &&
                    heap.tasks[child].priority < heap.tasks[idx].priority
                t = heap.tasks[idx]
                heap.tasks[idx] = heap.tasks[child]
                heap.tasks[child] = t
                multiq_sift_down(heap, Int32(child))
            end
        end
    end
end

function multiq_size(tpid::Int8)
    nt = UInt32(Threads._nthreads_in_pool(tpid))
    tp = tpid + 1
    tpheaps = heaps[tp]
    heap_c = UInt32(2)
    heap_p = UInt32(length(tpheaps))

    if heap_c * nt <= heap_p
        return heap_p
    end

    @lock heaps_lock[tp] begin
        heap_p = UInt32(length(tpheaps))
        nt = UInt32(Threads._nthreads_in_pool(tpid))
        if heap_c * nt <= heap_p
            return heap_p
        end

        heap_p += heap_c * nt
        newheaps = Vector{taskheap}(undef, heap_p)
        copyto!(newheaps, tpheaps)
        for i = (1 + length(tpheaps)):heap_p
            newheaps[i] = taskheap()
        end
        heaps[tp] = newheaps
        cong_unbias[tp] = unbias_cong(heap_p)
    end

    return heap_p
end

function multiq_insert(task::Task, priority::UInt16)
    tpid = ccall(:jl_get_task_threadpoolid, Int8, (Any,), task)
    heap_p = multiq_size(tpid)
    tp = tpid + 1

    task.priority = priority

    rn = cong(heap_p, cong_unbias[tp])
    tpheaps = heaps[tp]
    while !trylock(tpheaps[rn].lock)
        rn = cong(heap_p, cong_unbias[tp])
    end

    heap = tpheaps[rn]
    if heap.ntasks >= length(heap.tasks)
        resize!(heap.tasks, length(heap.tasks) * 2)
    end

    ntasks = heap.ntasks + Int32(1)
    @atomic :monotonic heap.ntasks = ntasks
    heap.tasks[ntasks] = task
    multiq_sift_up(heap, ntasks)
    priority = heap.priority
    if task.priority < priority
        @atomic :monotonic heap.priority = task.priority
    end
    unlock(heap.lock)

    return true
end

function multiq_deletemin()
    local rn1, rn2
    local prio1, prio2

    tid = Threads.threadid()
    tp = ccall(:jl_threadpoolid, Int8, (Int16,), tid-1) + 1
    tpheaps = heaps[tp]

    @label retry
    GC.safepoint()
    heap_p = UInt32(length(tpheaps))
    for i = UInt32(0):heap_p
        if i == heap_p
            return nothing
        end
        rn1 = cong(heap_p, cong_unbias[tp])
        rn2 = cong(heap_p, cong_unbias[tp])
        prio1 = tpheaps[rn1].priority
        prio2 = tpheaps[rn2].priority
        if prio1 > prio2
            prio1 = prio2
            rn1 = rn2
        elseif prio1 == prio2 && prio1 == typemax(UInt16)
            continue
        end
        if trylock(tpheaps[rn1].lock)
            if prio1 == tpheaps[rn1].priority
                break
            end
            unlock(tpheaps[rn1].lock)
        end
    end

    heap = tpheaps[rn1]
    task = heap.tasks[1]
    if ccall(:jl_set_task_tid, Cint, (Any, Cint), task, tid-1) == 0
        unlock(heap.lock)
        @goto retry
    end
    ntasks = heap.ntasks
    @atomic :monotonic heap.ntasks = ntasks - Int32(1)
    heap.tasks[1] = heap.tasks[ntasks]
    Base._unsetindex!(heap.tasks, Int(ntasks))
    prio1 = typemax(UInt16)
    if ntasks > 1
        multiq_sift_down(heap, Int32(1))
        prio1 = heap.tasks[1].priority
    end
    @atomic :monotonic heap.priority = prio1
    unlock(heap.lock)

    return task
end

function multiq_check_empty()
    for j = UInt32(1):length(heaps)
        for i = UInt32(1):length(heaps[j])
            if heaps[j][i].ntasks != 0
                return false
            end
        end
    end
    return true
end

end

max_stars_repo_name: SmiteWindows/julia

max_issues_repo_name: SmiteWindows/julia

max_forks_repo_name: SmiteWindows/julia


text:
tests = ["CLI",
         "Encode",
         "Decode",
         "ErlProto",
         "ErlTerms",
         "Erlang",
         "StdIO"]

println("Running tests ...")

for t in tests
    fn = string(t, "Test.jl")
    println("* $fn ...")
    include(fn)
end


text:
using Rubin
using Tests
using Elliptic
using HypergeometricFunctions
using Polylogarithms
using SpecialFunctions

@test integrate(x^4*arcsinh(a*x), x) == :(-1//5*a^-5*(1+a^2*x^2)^(1/2)+-1//25*a^-5*(1+a^2*x^2)^5//2+1//5*x^5*arcsinh(a*x)+2//15*a^-5*(1+a^2*x^2)^3//2)
@test integrate(x^3*arcsinh(a*x), x) == :(-3//32*a^-4*arcsinh(a*x)+1//4*x^4*arcsinh(a*x)+-1//16*a^-1*x^3*(1+a^2*x^2)^(1/2)+3//32*x*a^-3*(1+a^2*x^2)^(1/2))
@test integrate(x^2*arcsinh(a*x), x) == :(-1//9*a^-3*(1+a^2*x^2)^3//2+1//3*a^-3*(1+a^2*x^2)^(1/2)+1//3*x^3*arcsinh(a*x))
@test integrate(x*arcsinh(a*x), x) == :((1/2)*x^2*arcsinh(a*x)+1//4*a^-2*arcsinh(a*x)+-1//4*x*a^-1*(1+a^2*x^2)^(1/2))
@test integrate(arcsinh(a*x), x) == :(x*arcsinh(a*x)+-1*a^-1*(1+a^2*x^2)^(1/2))
@test integrate(x^-1*arcsinh(a*x), x) == :((1/2)*Polylogarithms.polylog(2,exp(2*arcsinh(a*x)))+-1//2*arcsinh(a*x)^2+arcsinh(a*x)*log(1+-1*exp(2*arcsinh(a*x))))
@test integrate(x^-2*arcsinh(a*x), x) == :(-1*a*arctanh((1+a^2*x^2)^(1/2))+-1*x^-1*arcsinh(a*x))
@test integrate(x^-3*arcsinh(a*x), x) == :(-1//2*x^-2*arcsinh(a*x)+-1//2*a*x^-1*(1+a^2*x^2)^(1/2))
@test integrate(x^-4*arcsinh(a*x), x) == :(-1//3*x^-3*arcsinh(a*x)+1//6*a^3*arctanh((1+a^2*x^2)^(1/2))+-1//6*a*x^-2*(1+a^2*x^2)^(1/2))
@test integrate(x^-5*arcsinh(a*x), x) == :(-1//4*x^-4*arcsinh(a*x)+-1//12*a*x^-3*(1+a^2*x^2)^(1/2)+1//6*a^3*x^-1*(1+a^2*x^2)^(1/2))
@test integrate(x^-6*arcsinh(a*x), x) == :(-3//40*a^5*arctanh((1+a^2*x^2)^(1/2))+-1//5*x^-5*arcsinh(a*x)+-1//20*a*x^-4*(1+a^2*x^2)^(1/2)+3//40*a^3*x^-2*(1+a^2*x^2)^(1/2))
@test integrate(x^4*arcsinh(a*x)^2, x) == :(2//125*x^5+-8//225*a^-2*x^3+1//5*x^5*arcsinh(a*x)^2+16//75*x*a^-4+-16//75*a^-5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-2//25*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+8//75*a^-3*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^3*arcsinh(a*x)^2, x) == :(1//32*x^4+-3//32*a^-4*arcsinh(a*x)^2+-3//32*a^-2*x^2+1//4*x^4*arcsinh(a*x)^2+-1//8*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+3//16*x*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^2*arcsinh(a*x)^2, x) == :(2//27*x^3+-4//9*x*a^-2+1//3*x^3*arcsinh(a*x)^2+4//9*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-2//9*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x*arcsinh(a*x)^2, x) == :(1//4*x^2+(1/2)*x^2*arcsinh(a*x)^2+1//4*a^-2*arcsinh(a*x)^2+-1//2*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(arcsinh(a*x)^2, x) == :(2x+x*arcsinh(a*x)^2+-2*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^-1*arcsinh(a*x)^2, x) == :(-1//2*Polylogarithms.polylog(3,exp(2*arcsinh(a*x)))+-1//3*arcsinh(a*x)^3+arcsinh(a*x)^2*log(1+-1*exp(2*arcsinh(a*x)))+Polylogarithms.polylog(2,exp(2*arcsinh(a*x)))*arcsinh(a*x))
@test integrate(x^-2*arcsinh(a*x)^2, x) == :(-1*x^-1*arcsinh(a*x)^2+-2*a*Polylogarithms.polylog(2,-1*exp(arcsinh(a*x)))+2*a*Polylogarithms.polylog(2,exp(arcsinh(a*x)))+-4*a*arcsinh(a*x)*arctanh(exp(arcsinh(a*x))))
@test integrate(x^-3*arcsinh(a*x)^2, x) == :(a^2*log(x)+-1//2*x^-2*arcsinh(a*x)^2+-1*a*x^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^-4*arcsinh(a*x)^2, x) == :(-1//3*a^2*x^-1+-1//3*a^3*Polylogarithms.polylog(2,exp(arcsinh(a*x)))+-1//3*x^-3*arcsinh(a*x)^2+1//3*a^3*Polylogarithms.polylog(2,-1*exp(arcsinh(a*x)))+2//3*a^3*arcsinh(a*x)*arctanh(exp(arcsinh(a*x)))+-1//3*a*x^-2*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^-5*arcsinh(a*x)^2, x) == :(-1//3*a^4*log(x)+-1//4*x^-4*arcsinh(a*x)^2+-1//12*a^2*x^-2+-1//6*a*x^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+1//3*a^3*x^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^4*arcsinh(a*x)^3, x) == :(-298//375*a^-5*(1+a^2*x^2)^(1/2)+-6//625*a^-5*(1+a^2*x^2)^5//2+1//5*x^5*arcsinh(a*x)^3+6//125*x^5*arcsinh(a*x)+76//1125*a^-5*(1+a^2*x^2)^3//2+-8//25*a^-5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2+-8//75*a^-2*x^3*arcsinh(a*x)+16//25*x*a^-4*arcsinh(a*x)+-3//25*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2+4//25*a^-3*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2)
@test integrate(x^3*arcsinh(a*x)^3, x) == :(-45//256*a^-4*arcsinh(a*x)+-3//32*a^-4*arcsinh(a*x)^3+1//4*x^4*arcsinh(a*x)^3+3//32*x^4*arcsinh(a*x)+-9//32*a^-2*x^2*arcsinh(a*x)+-3//128*a^-1*x^3*(1+a^2*x^2)^(1/2)+45//256*x*a^-3*(1+a^2*x^2)^(1/2)+-3//16*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2+9//32*x*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2)
@test integrate(x^2*arcsinh(a*x)^3, x) == :(-2//27*a^-3*(1+a^2*x^2)^3//2+1//3*x^3*arcsinh(a*x)^3+2//9*x^3*arcsinh(a*x)+14//9*a^-3*(1+a^2*x^2)^(1/2)+-4//3*x*a^-2*arcsinh(a*x)+2//3*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2+-1//3*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2)
@test integrate(x*arcsinh(a*x)^3, x) == :((1/2)*x^2*arcsinh(a*x)^3+1//4*a^-2*arcsinh(a*x)^3+3//4*x^2*arcsinh(a*x)+3//8*a^-2*arcsinh(a*x)+-3//8*x*a^-1*(1+a^2*x^2)^(1/2)+-3//4*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2)
@test integrate(arcsinh(a*x)^3, x) == :(x*arcsinh(a*x)^3+-6*a^-1*(1+a^2*x^2)^(1/2)+6*x*arcsinh(a*x)+-3*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2)
@test integrate(x^-1*arcsinh(a*x)^3, x) == :(-1//4*arcsinh(a*x)^4+3//4*Polylogarithms.polylog(4,exp(2*arcsinh(a*x)))+arcsinh(a*x)^3*log(1+-1*exp(2*arcsinh(a*x)))+-3//2*Polylogarithms.polylog(3,exp(2*arcsinh(a*x)))*arcsinh(a*x)+3//2*arcsinh(a*x)^2*Polylogarithms.polylog(2,exp(2*arcsinh(a*x))))
@test integrate(x^-2*arcsinh(a*x)^3, x) == :(-1*x^-1*arcsinh(a*x)^3+-6*a*Polylogarithms.polylog(3,exp(arcsinh(a*x)))+6*a*Polylogarithms.polylog(3,-1*exp(arcsinh(a*x)))+-6*a*arcsinh(a*x)^2*arctanh(exp(arcsinh(a*x)))+-6*a*Polylogarithms.polylog(2,-1*exp(arcsinh(a*x)))*arcsinh(a*x)+6*a*Polylogarithms.polylog(2,exp(arcsinh(a*x)))*arcsinh(a*x))
@test integrate(x^-3*arcsinh(a*x)^3, x) == :(-3//2*a^2*arcsinh(a*x)^2+-1//2*x^-2*arcsinh(a*x)^3+3//2*a^2*Polylogarithms.polylog(2,exp(2*arcsinh(a*x)))+3*a^2*arcsinh(a*x)*log(1+-1*exp(2*arcsinh(a*x)))+-3//2*a*x^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2)
@test integrate(x^-4*arcsinh(a*x)^3, x) == :(a^3*Polylogarithms.polylog(3,exp(arcsinh(a*x)))+-1*a^3*Polylogarithms.polylog(3,-1*exp(arcsinh(a*x)))+-1*a^3*arctanh((1+a^2*x^2)^(1/2))+-1//3*x^-3*arcsinh(a*x)^3+a^3*arcsinh(a*x)^2*arctanh(exp(arcsinh(a*x)))+a^3*Polylogarithms.polylog(2,-1*exp(arcsinh(a*x)))*arcsinh(a*x)+-1*a^2*x^-1*arcsinh(a*x)+-1*a^3*Polylogarithms.polylog(2,exp(arcsinh(a*x)))*arcsinh(a*x)+-1//2*a*x^-2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2)
@test integrate(x^-5*arcsinh(a*x)^3, x) == :((1/2)*a^4*arcsinh(a*x)^2+-1//2*a^4*Polylogarithms.polylog(2,exp(2*arcsinh(a*x)))+-1//4*x^-4*arcsinh(a*x)^3+-1*a^4*arcsinh(a*x)*log(1+-1*exp(2*arcsinh(a*x)))+-1//4*a^2*x^-2*arcsinh(a*x)+-1//4*a^3*x^-1*(1+a^2*x^2)^(1/2)+(1/2)*a^3*x^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2+-1//4*a*x^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^2)
@test integrate(x^5*arcsinh(a*x)^4, x) == :(1//324*x^6+-65//3456*a^-2*x^4+1//6*x^6*arcsinh(a*x)^4+1//18*x^6*arcsinh(a*x)^2+5//96*a^-6*arcsinh(a*x)^4+245//1152*a^-6*arcsinh(a*x)^2+245//1152*a^-4*x^2+-5//48*a^-2*x^4*arcsinh(a*x)^2+5//16*a^-4*x^2*arcsinh(a*x)^2+-245//576*x*a^-5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-5//24*x*a^-5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+-1//9*a^-1*x^5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+-1//54*a^-1*x^5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+5//36*a^-3*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+65//864*a^-3*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^4*arcsinh(a*x)^4, x) == :(24//3125*x^5+-1088//16875*a^-2*x^3+1//5*x^5*arcsinh(a*x)^4+12//125*x^5*arcsinh(a*x)^2+16576//5625*x*a^-4+-16576//5625*a^-5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-32//75*a^-5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+-16//75*a^-2*x^3*arcsinh(a*x)^2+32//25*x*a^-4*arcsinh(a*x)^2+-24//625*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-4//25*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+16//75*a^-3*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+1088//5625*a^-3*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^3*arcsinh(a*x)^4, x) == :(3//128*x^4+-45//128*a^-4*arcsinh(a*x)^2+-45//128*a^-2*x^2+-3//32*a^-4*arcsinh(a*x)^4+1//4*x^4*arcsinh(a*x)^4+3//16*x^4*arcsinh(a*x)^2+-9//16*a^-2*x^2*arcsinh(a*x)^2+-3//32*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-1//4*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+3//8*x*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+45//64*x*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(x^2*arcsinh(a*x)^4, x) == :(8//81*x^3+-160//27*x*a^-2+1//3*x^3*arcsinh(a*x)^4+4//9*x^3*arcsinh(a*x)^2+-8//3*x*a^-2*arcsinh(a*x)^2+8//9*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+160//27*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-8//27*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-4//9*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3)
@test integrate(x*arcsinh(a*x)^4, x) == :(3//4*x^2+(1/2)*x^2*arcsinh(a*x)^4+1//4*a^-2*arcsinh(a*x)^4+3//2*x^2*arcsinh(a*x)^2+3//4*a^-2*arcsinh(a*x)^2+-1*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3+-3//2*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x))
@test integrate(arcsinh(a*x)^4, x) == :(24x+x*arcsinh(a*x)^4+12*x*arcsinh(a*x)^2+-24*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)+-4*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3)
@test integrate(x^-1*arcsinh(a*x)^4, x) == :(-3//2*Polylogarithms.polylog(5,exp(2*arcsinh(a*x)))+-1//5*arcsinh(a*x)^5+arcsinh(a*x)^4*log(1+-1*exp(2*arcsinh(a*x)))+-3*arcsinh(a*x)^2*Polylogarithms.polylog(3,exp(2*arcsinh(a*x)))+2*arcsinh(a*x)^3*Polylogarithms.polylog(2,exp(2*arcsinh(a*x)))+3*Polylogarithms.polylog(4,exp(2*arcsinh(a*x)))*arcsinh(a*x))
@test integrate(x^-2*arcsinh(a*x)^4, x) == :(-1*x^-1*arcsinh(a*x)^4+-24*a*Polylogarithms.polylog(4,-1*exp(arcsinh(a*x)))+24*a*Polylogarithms.polylog(4,exp(arcsinh(a*x)))+-24*a*Polylogarithms.polylog(3,exp(arcsinh(a*x)))*arcsinh(a*x)+-12*a*arcsinh(a*x)^2*Polylogarithms.polylog(2,-1*exp(arcsinh(a*x)))+-8*a*arcsinh(a*x)^3*arctanh(exp(arcsinh(a*x)))+12*a*arcsinh(a*x)^2*Polylogarithms.polylog(2,exp(arcsinh(a*x)))+24*a*Polylogarithms.polylog(3,-1*exp(arcsinh(a*x)))*arcsinh(a*x))
@test integrate(x^-3*arcsinh(a*x)^4, x) == :(-3*a^2*Polylogarithms.polylog(3,exp(2*arcsinh(a*x)))+-2*a^2*arcsinh(a*x)^3+-1//2*x^-2*arcsinh(a*x)^4+6*a^2*arcsinh(a*x)^2*log(1+-1*exp(2*arcsinh(a*x)))+6*a^2*Polylogarithms.polylog(2,exp(2*arcsinh(a*x)))*arcsinh(a*x)+-2*a*x^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3)
@test integrate(x^-4*arcsinh(a*x)^4, x) == :(-4*a^3*Polylogarithms.polylog(2,-1*exp(arcsinh(a*x)))+-4*a^3*Polylogarithms.polylog(4,exp(arcsinh(a*x)))+4*a^3*Polylogarithms.polylog(2,exp(arcsinh(a*x)))+4*a^3*Polylogarithms.polylog(4,-1*exp(arcsinh(a*x)))+-1//3*x^-3*arcsinh(a*x)^4+-8*a^3*arcsinh(a*x)*arctanh(exp(arcsinh(a*x)))+-4*a^3*Polylogarithms.polylog(3,-1*exp(arcsinh(a*x)))*arcsinh(a*x)+-2*a^2*x^-1*arcsinh(a*x)^2+-2*a^3*arcsinh(a*x)^2*Polylogarithms.polylog(2,exp(arcsinh(a*x)))+2*a^3*arcsinh(a*x)^2*Polylogarithms.polylog(2,-1*exp(arcsinh(a*x)))+4*a^3*Polylogarithms.polylog(3,exp(arcsinh(a*x)))*arcsinh(a*x)+4//3*a^3*arcsinh(a*x)^3*arctanh(exp(arcsinh(a*x)))+-2//3*a*x^-2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3)
@test integrate(x^6*arcsinh(a*x)^-1, x) == :(-5//64*a^-7*coshintegral(5*arcsinh(a*x))+-5//64*a^-7*coshintegral(arcsinh(a*x))+1//64*a^-7*coshintegral(7*arcsinh(a*x))+9//64*a^-7*coshintegral(3*arcsinh(a*x)))
@test integrate(x^5*arcsinh(a*x)^-1, x) == :(-1//8*a^-6*sinhintegral(4*arcsinh(a*x))+1//32*a^-6*sinhintegral(6*arcsinh(a*x))+5//32*a^-6*sinhintegral(2*arcsinh(a*x)))
@test integrate(x^4*arcsinh(a*x)^-1, x) == :(-3//16*a^-5*coshintegral(3*arcsinh(a*x))+1//8*a^-5*coshintegral(arcsinh(a*x))+1//16*a^-5*coshintegral(5*arcsinh(a*x)))
@test integrate(x^3*arcsinh(a*x)^-1, x) == :(-1//4*a^-4*sinhintegral(2*arcsinh(a*x))+1//8*a^-4*sinhintegral(4*arcsinh(a*x)))
@test integrate(x^2*arcsinh(a*x)^-1, x) == :(-1//4*a^-3*coshintegral(arcsinh(a*x))+1//4*a^-3*coshintegral(3*arcsinh(a*x)))
@test integrate(x*arcsinh(a*x)^-1, x) == :((1/2)*a^-2*sinhintegral(2*arcsinh(a*x)))
@test integrate(arcsinh(a*x)^-1, x) == :(a^-1*coshintegral(arcsinh(a*x)))
@test integrate(x^6*arcsinh(a*x)^-2, x) == :(-25//64*a^-7*sinhintegral(5*arcsinh(a*x))+-5//64*a^-7*sinhintegral(arcsinh(a*x))+7//64*a^-7*sinhintegral(7*arcsinh(a*x))+27//64*a^-7*sinhintegral(3*arcsinh(a*x))+-1*a^-1*x^6*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1)
@test integrate(x^5*arcsinh(a*x)^-2, x) == :(-1//2*a^-6*coshintegral(4*arcsinh(a*x))+3//16*a^-6*coshintegral(6*arcsinh(a*x))+5//16*a^-6*coshintegral(2*arcsinh(a*x))+-1*a^-1*x^5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1)
@test integrate(x^4*arcsinh(a*x)^-2, x) == :(-9//16*a^-5*sinhintegral(3*arcsinh(a*x))+1//8*a^-5*sinhintegral(arcsinh(a*x))+5//16*a^-5*sinhintegral(5*arcsinh(a*x))+-1*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1)
@test integrate(x^3*arcsinh(a*x)^-2, x) == :((1/2)*a^-4*coshintegral(4*arcsinh(a*x))+-1//2*a^-4*coshintegral(2*arcsinh(a*x))+-1*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1)
@test integrate(x^2*arcsinh(a*x)^-2, x) == :(-1//4*a^-3*sinhintegral(arcsinh(a*x))+3//4*a^-3*sinhintegral(3*arcsinh(a*x))+-1*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1)
@test integrate(x*arcsinh(a*x)^-2, x) == :(a^-2*coshintegral(2*arcsinh(a*x))+-1*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1)
@test integrate(arcsinh(a*x)^-2, x) == :(a^-1*sinhintegral(arcsinh(a*x))+-1*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1)
@test integrate(x^4*arcsinh(a*x)^-3, x) == :(-27//32*a^-5*coshintegral(3*arcsinh(a*x))+-5//2*x^5*arcsinh(a*x)^-1+1//16*a^-5*coshintegral(arcsinh(a*x))+25//32*a^-5*coshintegral(5*arcsinh(a*x))+-2*a^-2*x^3*arcsinh(a*x)^-1+-1//2*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-2)
@test integrate(x^3*arcsinh(a*x)^-3, x) == :(a^-4*sinhintegral(4*arcsinh(a*x))+-2*x^4*arcsinh(a*x)^-1+-1//2*a^-4*sinhintegral(2*arcsinh(a*x))+-3//2*a^-2*x^2*arcsinh(a*x)^-1+-1//2*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-2)
@test integrate(x^2*arcsinh(a*x)^-3, x) == :(-3//2*x^3*arcsinh(a*x)^-1+-1//8*a^-3*coshintegral(arcsinh(a*x))+9//8*a^-3*coshintegral(3*arcsinh(a*x))+-1*x*a^-2*arcsinh(a*x)^-1+-1//2*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-2)
@test integrate(x*arcsinh(a*x)^-3, x) == :(a^-2*sinhintegral(2*arcsinh(a*x))+-1*x^2*arcsinh(a*x)^-1+-1//2*a^-2*arcsinh(a*x)^-1+-1//2*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-2)
@test integrate(arcsinh(a*x)^-3, x) == :((1/2)*a^-1*coshintegral(arcsinh(a*x))+-1//2*x*arcsinh(a*x)^-1+-1//2*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-2)
@test integrate(x^4*arcsinh(a*x)^-4, x) == :(-27//32*a^-5*sinhintegral(3*arcsinh(a*x))+-5//6*x^5*arcsinh(a*x)^-2+1//48*a^-5*sinhintegral(arcsinh(a*x))+125//96*a^-5*sinhintegral(5*arcsinh(a*x))+-2//3*a^-2*x^3*arcsinh(a*x)^-2+-2*a^-3*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1+-25//6*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1+-1//3*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3)
@test integrate(x^3*arcsinh(a*x)^-4, x) == :(-2//3*x^4*arcsinh(a*x)^-2+-1//3*a^-4*coshintegral(2*arcsinh(a*x))+4//3*a^-4*coshintegral(4*arcsinh(a*x))+-1//2*a^-2*x^2*arcsinh(a*x)^-2+-1*x*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1+-8//3*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1+-1//3*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3)
@test integrate(x^2*arcsinh(a*x)^-4, x) == :(-1//2*x^3*arcsinh(a*x)^-2+-1//24*a^-3*sinhintegral(arcsinh(a*x))+9//8*a^-3*sinhintegral(3*arcsinh(a*x))+-1//3*x*a^-2*arcsinh(a*x)^-2+-1//3*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1+-3//2*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1+-1//3*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3)
@test integrate(x*arcsinh(a*x)^-4, x) == :(-1//3*x^2*arcsinh(a*x)^-2+-1//6*a^-2*arcsinh(a*x)^-2+2//3*a^-2*coshintegral(2*arcsinh(a*x))+-2//3*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1+-1//3*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3)
@test integrate(arcsinh(a*x)^-4, x) == :(-1//6*x*arcsinh(a*x)^-2+1//6*a^-1*sinhintegral(arcsinh(a*x))+-1//3*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3+-1//6*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1)
@test integrate(x^4*arcsinh(a*x)^(1/2), x) == :(1//5*x^5*arcsinh(a*x)^(1/2)+-1//32*pi^(1/2)*a^-5*erfi(arcsinh(a*x)^(1/2))+1//32*pi^(1/2)*a^-5*erf(arcsinh(a*x)^(1/2))+-1//192*3^(1/2)*pi^(1/2)*a^-5*erf(3^(1/2)*arcsinh(a*x)^(1/2))+-1//1600*5^(1/2)*pi^(1/2)*a^-5*erfi(5^(1/2)*arcsinh(a*x)^(1/2))+1//192*3^(1/2)*pi^(1/2)*a^-5*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+1//1600*5^(1/2)*pi^(1/2)*a^-5*erf(5^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^3*arcsinh(a*x)^(1/2), x) == :(-3//32*a^-4*arcsinh(a*x)^(1/2)+1//4*x^4*arcsinh(a*x)^(1/2)+-1//256*pi^(1/2)*a^-4*erf(2*arcsinh(a*x)^(1/2))+-1//256*pi^(1/2)*a^-4*erfi(2*arcsinh(a*x)^(1/2))+1//64*2^(1/2)*pi^(1/2)*a^-4*erf(2^(1/2)*arcsinh(a*x)^(1/2))+1//64*2^(1/2)*pi^(1/2)*a^-4*erfi(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^2*arcsinh(a*x)^(1/2), x) == :(1//3*x^3*arcsinh(a*x)^(1/2)+-1//16*pi^(1/2)*a^-3*erf(arcsinh(a*x)^(1/2))+1//16*pi^(1/2)*a^-3*erfi(arcsinh(a*x)^(1/2))+-1//144*3^(1/2)*pi^(1/2)*a^-3*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+1//144*3^(1/2)*pi^(1/2)*a^-3*erf(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x*arcsinh(a*x)^(1/2), x) == :((1/2)*x^2*arcsinh(a*x)^(1/2)+1//4*a^-2*arcsinh(a*x)^(1/2)+-1//32*2^(1/2)*pi^(1/2)*a^-2*erf(2^(1/2)*arcsinh(a*x)^(1/2))+-1//32*2^(1/2)*pi^(1/2)*a^-2*erfi(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(arcsinh(a*x)^(1/2), x) == :(x*arcsinh(a*x)^(1/2)+-1//4*pi^(1/2)*a^-1*erfi(arcsinh(a*x)^(1/2))+1//4*pi^(1/2)*a^-1*erf(arcsinh(a*x)^(1/2)))
@test integrate(x^4*arcsinh(a*x)^3//2, x) == :(1//5*x^5*arcsinh(a*x)^3//2+-4//25*a^-5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2)+3//64*pi^(1/2)*a^-5*erf(arcsinh(a*x)^(1/2))+3//64*pi^(1/2)*a^-5*erfi(arcsinh(a*x)^(1/2))+-3//50*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2)+-1//384*3^(1/2)*pi^(1/2)*a^-5*erf(3^(1/2)*arcsinh(a*x)^(1/2))+-1//384*3^(1/2)*pi^(1/2)*a^-5*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+2//25*a^-3*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2)+3//16000*5^(1/2)*pi^(1/2)*a^-5*erf(5^(1/2)*arcsinh(a*x)^(1/2))+3//16000*5^(1/2)*pi^(1/2)*a^-5*erfi(5^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^3*arcsinh(a*x)^3//2, x) == :(-3//32*a^-4*arcsinh(a*x)^3//2+1//4*x^4*arcsinh(a*x)^3//2+-3//2048*pi^(1/2)*a^-4*erf(2*arcsinh(a*x)^(1/2))+3//2048*pi^(1/2)*a^-4*erfi(2*arcsinh(a*x)^(1/2))+-3//32*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2)+-3//256*2^(1/2)*pi^(1/2)*a^-4*erfi(2^(1/2)*arcsinh(a*x)^(1/2))+3//256*2^(1/2)*pi^(1/2)*a^-4*erf(2^(1/2)*arcsinh(a*x)^(1/2))+9//64*x*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2))
@test integrate(x^2*arcsinh(a*x)^3//2, x) == :(1//3*x^3*arcsinh(a*x)^3//2+-3//32*pi^(1/2)*a^-3*erf(arcsinh(a*x)^(1/2))+-3//32*pi^(1/2)*a^-3*erfi(arcsinh(a*x)^(1/2))+1//3*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2)+-1//6*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2)+1//288*3^(1/2)*pi^(1/2)*a^-3*erf(3^(1/2)*arcsinh(a*x)^(1/2))+1//288*3^(1/2)*pi^(1/2)*a^-3*erfi(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x*arcsinh(a*x)^3//2, x) == :((1/2)*x^2*arcsinh(a*x)^3//2+1//4*a^-2*arcsinh(a*x)^3//2+-3//8*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2)+-3//128*2^(1/2)*pi^(1/2)*a^-2*erf(2^(1/2)*arcsinh(a*x)^(1/2))+3//128*2^(1/2)*pi^(1/2)*a^-2*erfi(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(arcsinh(a*x)^3//2, x) == :(x*arcsinh(a*x)^3//2+-3//2*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^(1/2)+3//8*pi^(1/2)*a^-1*erf(arcsinh(a*x)^(1/2))+3//8*pi^(1/2)*a^-1*erfi(arcsinh(a*x)^(1/2)))
@test integrate(x^4*arcsinh(a*x)^5//2, x) == :(1//5*x^5*arcsinh(a*x)^5//2+3//100*x^5*arcsinh(a*x)^(1/2)+-15//128*pi^(1/2)*a^-5*erfi(arcsinh(a*x)^(1/2))+-4//15*a^-5*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2+-1//15*a^-2*x^3*arcsinh(a*x)^(1/2)+2//5*x*a^-4*arcsinh(a*x)^(1/2)+15//128*pi^(1/2)*a^-5*erf(arcsinh(a*x)^(1/2))+-5//2304*3^(1/2)*pi^(1/2)*a^-5*erf(3^(1/2)*arcsinh(a*x)^(1/2))+-3//32000*5^(1/2)*pi^(1/2)*a^-5*erfi(5^(1/2)*arcsinh(a*x)^(1/2))+-1//10*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2+2//15*a^-3*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2+3//32000*5^(1/2)*pi^(1/2)*a^-5*erf(5^(1/2)*arcsinh(a*x)^(1/2))+5//2304*3^(1/2)*pi^(1/2)*a^-5*erfi(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^3*arcsinh(a*x)^5//2, x) == :(-225//2048*a^-4*arcsinh(a*x)^(1/2)+-3//32*a^-4*arcsinh(a*x)^5//2+1//4*x^4*arcsinh(a*x)^5//2+15//256*x^4*arcsinh(a*x)^(1/2)+-45//256*a^-2*x^2*arcsinh(a*x)^(1/2)+-15//16384*pi^(1/2)*a^-4*erf(2*arcsinh(a*x)^(1/2))+-15//16384*pi^(1/2)*a^-4*erfi(2*arcsinh(a*x)^(1/2))+-5//32*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2+15//64*x*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2+15//1024*2^(1/2)*pi^(1/2)*a^-4*erf(2^(1/2)*arcsinh(a*x)^(1/2))+15//1024*2^(1/2)*pi^(1/2)*a^-4*erfi(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^2*arcsinh(a*x)^5//2, x) == :(1//3*x^3*arcsinh(a*x)^5//2+5//36*x^3*arcsinh(a*x)^(1/2)+-15//64*pi^(1/2)*a^-3*erf(arcsinh(a*x)^(1/2))+-5//6*x*a^-2*arcsinh(a*x)^(1/2)+5//9*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2+15//64*pi^(1/2)*a^-3*erfi(arcsinh(a*x)^(1/2))+-5//18*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2+-5//1728*3^(1/2)*pi^(1/2)*a^-3*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+5//1728*3^(1/2)*pi^(1/2)*a^-3*erf(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x*arcsinh(a*x)^5//2, x) == :((1/2)*x^2*arcsinh(a*x)^5//2+1//4*a^-2*arcsinh(a*x)^5//2+15//32*x^2*arcsinh(a*x)^(1/2)+15//64*a^-2*arcsinh(a*x)^(1/2)+-15//512*2^(1/2)*pi^(1/2)*a^-2*erf(2^(1/2)*arcsinh(a*x)^(1/2))+-15//512*2^(1/2)*pi^(1/2)*a^-2*erfi(2^(1/2)*arcsinh(a*x)^(1/2))+-5//8*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2)
@test integrate(arcsinh(a*x)^5//2, x) == :(x*arcsinh(a*x)^5//2+15//4*x*arcsinh(a*x)^(1/2)+-15//16*pi^(1/2)*a^-1*erfi(arcsinh(a*x)^(1/2))+-5//2*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^3//2+15//16*pi^(1/2)*a^-1*erf(arcsinh(a*x)^(1/2)))
@test integrate(x^4*arcsinh(a*x)^-1//2, x) == :(1//16*pi^(1/2)*a^-5*erf(arcsinh(a*x)^(1/2))+1//16*pi^(1/2)*a^-5*erfi(arcsinh(a*x)^(1/2))+-1//32*3^(1/2)*pi^(1/2)*a^-5*erf(3^(1/2)*arcsinh(a*x)^(1/2))+-1//32*3^(1/2)*pi^(1/2)*a^-5*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+1//160*5^(1/2)*pi^(1/2)*a^-5*erf(5^(1/2)*arcsinh(a*x)^(1/2))+1//160*5^(1/2)*pi^(1/2)*a^-5*erfi(5^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^3*arcsinh(a*x)^-1//2, x) == :(-1//32*pi^(1/2)*a^-4*erf(2*arcsinh(a*x)^(1/2))+1//32*pi^(1/2)*a^-4*erfi(2*arcsinh(a*x)^(1/2))+-1//16*2^(1/2)*pi^(1/2)*a^-4*erfi(2^(1/2)*arcsinh(a*x)^(1/2))+1//16*2^(1/2)*pi^(1/2)*a^-4*erf(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^2*arcsinh(a*x)^-1//2, x) == :(-1//8*pi^(1/2)*a^-3*erf(arcsinh(a*x)^(1/2))+-1//8*pi^(1/2)*a^-3*erfi(arcsinh(a*x)^(1/2))+1//24*3^(1/2)*pi^(1/2)*a^-3*erf(3^(1/2)*arcsinh(a*x)^(1/2))+1//24*3^(1/2)*pi^(1/2)*a^-3*erfi(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x*arcsinh(a*x)^-1//2, x) == :(-1//8*2^(1/2)*pi^(1/2)*a^-2*erf(2^(1/2)*arcsinh(a*x)^(1/2))+1//8*2^(1/2)*pi^(1/2)*a^-2*erfi(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(arcsinh(a*x)^-1//2, x) == :((1/2)*pi^(1/2)*a^-1*erf(arcsinh(a*x)^(1/2))+(1/2)*pi^(1/2)*a^-1*erfi(arcsinh(a*x)^(1/2)))
@test integrate(x^4*arcsinh(a*x)^-3//2, x) == :(-1//8*pi^(1/2)*a^-5*erf(arcsinh(a*x)^(1/2))+1//8*pi^(1/2)*a^-5*erfi(arcsinh(a*x)^(1/2))+-2*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-3//16*3^(1/2)*pi^(1/2)*a^-5*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+-1//16*5^(1/2)*pi^(1/2)*a^-5*erf(5^(1/2)*arcsinh(a*x)^(1/2))+1//16*5^(1/2)*pi^(1/2)*a^-5*erfi(5^(1/2)*arcsinh(a*x)^(1/2))+3//16*3^(1/2)*pi^(1/2)*a^-5*erf(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^3*arcsinh(a*x)^-3//2, x) == :(1//4*pi^(1/2)*a^-4*erf(2*arcsinh(a*x)^(1/2))+1//4*pi^(1/2)*a^-4*erfi(2*arcsinh(a*x)^(1/2))+-2*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-1//4*2^(1/2)*pi^(1/2)*a^-4*erf(2^(1/2)*arcsinh(a*x)^(1/2))+-1//4*2^(1/2)*pi^(1/2)*a^-4*erfi(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^2*arcsinh(a*x)^-3//2, x) == :(-1//4*pi^(1/2)*a^-3*erfi(arcsinh(a*x)^(1/2))+1//4*pi^(1/2)*a^-3*erf(arcsinh(a*x)^(1/2))+-2*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-1//4*3^(1/2)*pi^(1/2)*a^-3*erf(3^(1/2)*arcsinh(a*x)^(1/2))+1//4*3^(1/2)*pi^(1/2)*a^-3*erfi(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x*arcsinh(a*x)^-3//2, x) == :((1/2)*2^(1/2)*pi^(1/2)*a^-2*erf(2^(1/2)*arcsinh(a*x)^(1/2))+(1/2)*2^(1/2)*pi^(1/2)*a^-2*erfi(2^(1/2)*arcsinh(a*x)^(1/2))+-2*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2)
@test integrate(arcsinh(a*x)^-3//2, x) == :(pi^(1/2)*a^-1*erfi(arcsinh(a*x)^(1/2))+-1*pi^(1/2)*a^-1*erf(arcsinh(a*x)^(1/2))+-2*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2)
@test integrate(x^4*arcsinh(a*x)^-5//2, x) == :(-20//3*x^5*arcsinh(a*x)^-1//2+-16//3*a^-2*x^3*arcsinh(a*x)^-1//2+1//12*pi^(1/2)*a^-5*erf(arcsinh(a*x)^(1/2))+1//12*pi^(1/2)*a^-5*erfi(arcsinh(a*x)^(1/2))+-3//8*3^(1/2)*pi^(1/2)*a^-5*erf(3^(1/2)*arcsinh(a*x)^(1/2))+-3//8*3^(1/2)*pi^(1/2)*a^-5*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+-2//3*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3//2+5//24*5^(1/2)*pi^(1/2)*a^-5*erf(5^(1/2)*arcsinh(a*x)^(1/2))+5//24*5^(1/2)*pi^(1/2)*a^-5*erfi(5^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^3*arcsinh(a*x)^-5//2, x) == :(-16//3*x^4*arcsinh(a*x)^-1//2+-4*a^-2*x^2*arcsinh(a*x)^-1//2+-2//3*pi^(1/2)*a^-4*erf(2*arcsinh(a*x)^(1/2))+2//3*pi^(1/2)*a^-4*erfi(2*arcsinh(a*x)^(1/2))+-2//3*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3//2+-1//3*2^(1/2)*pi^(1/2)*a^-4*erfi(2^(1/2)*arcsinh(a*x)^(1/2))+1//3*2^(1/2)*pi^(1/2)*a^-4*erf(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^2*arcsinh(a*x)^-5//2, x) == :(-4*x^3*arcsinh(a*x)^-1//2+-8//3*x*a^-2*arcsinh(a*x)^-1//2+-1//6*pi^(1/2)*a^-3*erf(arcsinh(a*x)^(1/2))+-1//6*pi^(1/2)*a^-3*erfi(arcsinh(a*x)^(1/2))+(1/2)*3^(1/2)*pi^(1/2)*a^-3*erf(3^(1/2)*arcsinh(a*x)^(1/2))+(1/2)*3^(1/2)*pi^(1/2)*a^-3*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+-2//3*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3//2)
@test integrate(x*arcsinh(a*x)^-5//2, x) == :(-8//3*x^2*arcsinh(a*x)^-1//2+-4//3*a^-2*arcsinh(a*x)^-1//2+-2//3*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3//2+-2//3*2^(1/2)*pi^(1/2)*a^-2*erf(2^(1/2)*arcsinh(a*x)^(1/2))+2//3*2^(1/2)*pi^(1/2)*a^-2*erfi(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(arcsinh(a*x)^-5//2, x) == :(-4//3*x*arcsinh(a*x)^-1//2+-2//3*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-3//2+2//3*pi^(1/2)*a^-1*erf(arcsinh(a*x)^(1/2))+2//3*pi^(1/2)*a^-1*erfi(arcsinh(a*x)^(1/2)))
@test integrate(x^4*arcsinh(a*x)^-7//2, x) == :(-4//3*x^5*arcsinh(a*x)^-3//2+-16//15*a^-2*x^3*arcsinh(a*x)^-3//2+-1//30*pi^(1/2)*a^-5*erf(arcsinh(a*x)^(1/2))+1//30*pi^(1/2)*a^-5*erfi(arcsinh(a*x)^(1/2))+-40//3*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-32//5*a^-3*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-9//20*3^(1/2)*pi^(1/2)*a^-5*erfi(3^(1/2)*arcsinh(a*x)^(1/2))+-5//12*5^(1/2)*pi^(1/2)*a^-5*erf(5^(1/2)*arcsinh(a*x)^(1/2))+-2//5*a^-1*x^4*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-5//2+5//12*5^(1/2)*pi^(1/2)*a^-5*erfi(5^(1/2)*arcsinh(a*x)^(1/2))+9//20*3^(1/2)*pi^(1/2)*a^-5*erf(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x^3*arcsinh(a*x)^-7//2, x) == :(-16//15*x^4*arcsinh(a*x)^-3//2+-4//5*a^-2*x^2*arcsinh(a*x)^-3//2+16//15*pi^(1/2)*a^-4*erf(2*arcsinh(a*x)^(1/2))+16//15*pi^(1/2)*a^-4*erfi(2*arcsinh(a*x)^(1/2))+-128//15*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-16//5*x*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-4//15*2^(1/2)*pi^(1/2)*a^-4*erf(2^(1/2)*arcsinh(a*x)^(1/2))+-4//15*2^(1/2)*pi^(1/2)*a^-4*erfi(2^(1/2)*arcsinh(a*x)^(1/2))+-2//5*a^-1*x^3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-5//2)
@test integrate(x^2*arcsinh(a*x)^-7//2, x) == :(-4//5*x^3*arcsinh(a*x)^-3//2+-16//15*a^-3*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-8//15*x*a^-2*arcsinh(a*x)^-3//2+-1//15*pi^(1/2)*a^-3*erfi(arcsinh(a*x)^(1/2))+1//15*pi^(1/2)*a^-3*erf(arcsinh(a*x)^(1/2))+-24//5*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-3//5*3^(1/2)*pi^(1/2)*a^-3*erf(3^(1/2)*arcsinh(a*x)^(1/2))+-2//5*a^-1*x^2*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-5//2+3//5*3^(1/2)*pi^(1/2)*a^-3*erfi(3^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(x*arcsinh(a*x)^-7//2, x) == :(-8//15*x^2*arcsinh(a*x)^-3//2+-4//15*a^-2*arcsinh(a*x)^-3//2+-32//15*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-2//5*x*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-5//2+8//15*2^(1/2)*pi^(1/2)*a^-2*erf(2^(1/2)*arcsinh(a*x)^(1/2))+8//15*2^(1/2)*pi^(1/2)*a^-2*erfi(2^(1/2)*arcsinh(a*x)^(1/2)))
@test integrate(arcsinh(a*x)^-7//2, x) == :(-4//15*x*arcsinh(a*x)^-3//2+-8//15*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-1//2+-4//15*pi^(1/2)*a^-1*erf(arcsinh(a*x)^(1/2))+-2//5*a^-1*(1+a^2*x^2)^(1/2)*arcsinh(a*x)^-5//2+4//15*pi^(1/2)*a^-1*erfi(arcsinh(a*x)^(1/2)))
@test integrate(x^4*arcsinh(a*x)^n, x) == :(-1//16*a^-5*SpecialFunctions.gamma(1+n,arcsinh(a*x))+-1//32*5^(-1+-1n)*a^-5*SpecialFunctions.gamma(1+n,5*arcsinh(a*x))+1//32*3^(-1n)*a^-5*SpecialFunctions.gamma(1+n,3*arcsinh(a*x))+1//16*a^-5*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-1*arcsinh(a*x))+-1//32*3^(-1n)*a^-5*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-3*arcsinh(a*x))+1//32*5^(-1+-1n)*a^-5*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-5*arcsinh(a*x)))
@test integrate(x^3*arcsinh(a*x)^n, x) == :(2^(-6+-2n)*a^-4*SpecialFunctions.gamma(1+n,4*arcsinh(a*x))+-1*2^(-4+-1n)*a^-4*SpecialFunctions.gamma(1+n,2*arcsinh(a*x))+2^(-6+-2n)*a^-4*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-4*arcsinh(a*x))+-1*2^(-4+-1n)*a^-4*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-2*arcsinh(a*x)))
@test integrate(x^2*arcsinh(a*x)^n, x) == :(1//8*a^-3*SpecialFunctions.gamma(1+n,arcsinh(a*x))+-1//8*3^(-1+-1n)*a^-3*SpecialFunctions.gamma(1+n,3*arcsinh(a*x))+-1//8*a^-3*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-1*arcsinh(a*x))+1//8*3^(-1+-1n)*a^-3*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-3*arcsinh(a*x)))
@test integrate(x*arcsinh(a*x)^n, x) == :(2^(-3+-1n)*a^-2*SpecialFunctions.gamma(1+n,2*arcsinh(a*x))+2^(-3+-1n)*a^-2*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-2*arcsinh(a*x)))
@test integrate(arcsinh(a*x)^n, x) == :(-1//2*a^-1*SpecialFunctions.gamma(1+n,arcsinh(a*x))+(1/2)*a^-1*(-1*arcsinh(a*x))^(-1n)*arcsinh(a*x)^n*SpecialFunctions.gamma(1+n,-1*arcsinh(a*x)))
@test integrate(x^2*(a+b*arcsinh(c*x))^(1/2), x) == :(1//3*x^3*(a+b*arcsinh(c*x))^(1/2)+-1//16*pi^(1/2)*b^(1/2)*c^-3*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+1//16*pi^(1/2)*b^(1/2)*c^-3*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+-1//144*3^(1/2)*pi^(1/2)*b^(1/2)*c^-3*erfi(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-3*a*b^-1)+1//144*3^(1/2)*pi^(1/2)*b^(1/2)*c^-3*erf(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(3*a*b^-1))
@test integrate(x*(a+b*arcsinh(c*x))^(1/2), x) == :((1/2)*x^2*(a+b*arcsinh(c*x))^(1/2)+1//4*c^-2*(a+b*arcsinh(c*x))^(1/2)+-1//32*2^(1/2)*pi^(1/2)*b^(1/2)*c^-2*erf(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(2*a*b^-1)+-1//32*2^(1/2)*pi^(1/2)*b^(1/2)*c^-2*erfi(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-2*a*b^-1))
@test integrate((a+b*arcsinh(c*x))^(1/2), x) == :(x*(a+b*arcsinh(c*x))^(1/2)+-1//4*pi^(1/2)*b^(1/2)*c^-1*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+1//4*pi^(1/2)*b^(1/2)*c^-1*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1))
@test integrate(x^2*(a+b*arcsinh(c*x))^3//2, x) == :(1//3*x^3*(a+b*arcsinh(c*x))^3//2+1//3*b*c^-3*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^(1/2)+-3//32*pi^(1/2)*b^3//2*c^-3*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+-3//32*pi^(1/2)*b^3//2*c^-3*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+-1//6*b*c^-1*x^2*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^(1/2)+1//288*3^(1/2)*pi^(1/2)*b^3//2*c^-3*erf(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(3*a*b^-1)+1//288*3^(1/2)*pi^(1/2)*b^3//2*c^-3*erfi(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-3*a*b^-1))
@test integrate(x*(a+b*arcsinh(c*x))^3//2, x) == :((1/2)*x^2*(a+b*arcsinh(c*x))^3//2+1//4*c^-2*(a+b*arcsinh(c*x))^3//2+-3//8*b*x*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^(1/2)+-3//128*2^(1/2)*pi^(1/2)*b^3//2*c^-2*erf(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(2*a*b^-1)+3//128*2^(1/2)*pi^(1/2)*b^3//2*c^-2*erfi(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-2*a*b^-1))
@test integrate((a+b*arcsinh(c*x))^3//2, x) == :(x*(a+b*arcsinh(c*x))^3//2+-3//2*b*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^(1/2)+3//8*pi^(1/2)*b^3//2*c^-1*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+3//8*pi^(1/2)*b^3//2*c^-1*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1))
@test integrate(x^2*(a+b*arcsinh(c*x))^5//2, x) == :(1//3*x^3*(a+b*arcsinh(c*x))^5//2+5//36*b^2*x^3*(a+b*arcsinh(c*x))^(1/2)+-5//6*x*b^2*c^-2*(a+b*arcsinh(c*x))^(1/2)+5//9*b*c^-3*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^3//2+-15//64*pi^(1/2)*b^5//2*c^-3*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+-5//18*b*c^-1*x^2*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^3//2+15//64*pi^(1/2)*b^5//2*c^-3*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+-5//1728*3^(1/2)*pi^(1/2)*b^5//2*c^-3*erfi(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-3*a*b^-1)+5//1728*3^(1/2)*pi^(1/2)*b^5//2*c^-3*erf(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(3*a*b^-1))
@test integrate(x*(a+b*arcsinh(c*x))^5//2, x) == :((1/2)*x^2*(a+b*arcsinh(c*x))^5//2+1//4*c^-2*(a+b*arcsinh(c*x))^5//2+15//32*b^2*x^2*(a+b*arcsinh(c*x))^(1/2)+15//64*b^2*c^-2*(a+b*arcsinh(c*x))^(1/2)+-5//8*b*x*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^3//2+-15//512*2^(1/2)*pi^(1/2)*b^5//2*c^-2*erf(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(2*a*b^-1)+-15//512*2^(1/2)*pi^(1/2)*b^5//2*c^-2*erfi(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-2*a*b^-1))
@test integrate((a+b*arcsinh(c*x))^5//2, x) == :(x*(a+b*arcsinh(c*x))^5//2+15//4*x*b^2*(a+b*arcsinh(c*x))^(1/2)+-5//2*b*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^3//2+-15//16*pi^(1/2)*b^5//2*c^-1*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+15//16*pi^(1/2)*b^5//2*c^-1*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1))
@test integrate(x^2*(a+b*arcsinh(c*x))^-1//2, x) == :(-1//8*pi^(1/2)*b^-1//2*c^-3*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+-1//8*pi^(1/2)*b^-1//2*c^-3*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+1//24*3^(1/2)*pi^(1/2)*b^-1//2*c^-3*erf(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(3*a*b^-1)+1//24*3^(1/2)*pi^(1/2)*b^-1//2*c^-3*erfi(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-3*a*b^-1))
@test integrate(x*(a+b*arcsinh(c*x))^-1//2, x) == :(-1//8*2^(1/2)*pi^(1/2)*b^-1//2*c^-2*erf(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(2*a*b^-1)+1//8*2^(1/2)*pi^(1/2)*b^-1//2*c^-2*erfi(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-2*a*b^-1))
@test integrate((a+b*arcsinh(c*x))^-1//2, x) == :((1/2)*pi^(1/2)*b^-1//2*c^-1*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+(1/2)*pi^(1/2)*b^-1//2*c^-1*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1))
@test integrate(x^2*(a+b*arcsinh(c*x))^-3//2, x) == :(-2*b^-1*c^-1*x^2*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-1//2+-1//4*pi^(1/2)*b^-3//2*c^-3*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+1//4*pi^(1/2)*b^-3//2*c^-3*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+-1//4*3^(1/2)*pi^(1/2)*b^-3//2*c^-3*erf(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(3*a*b^-1)+1//4*3^(1/2)*pi^(1/2)*b^-3//2*c^-3*erfi(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-3*a*b^-1))
@test integrate(x*(a+b*arcsinh(c*x))^-3//2, x) == :(-2*x*b^-1*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-1//2+(1/2)*2^(1/2)*pi^(1/2)*b^-3//2*c^-2*erf(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(2*a*b^-1)+(1/2)*2^(1/2)*pi^(1/2)*b^-3//2*c^-2*erfi(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-2*a*b^-1))
@test integrate((a+b*arcsinh(c*x))^-3//2, x) == :(-2*b^-1*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-1//2+pi^(1/2)*b^-3//2*c^-1*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+-1*pi^(1/2)*b^-3//2*c^-1*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1))
@test integrate(x^2*(a+b*arcsinh(c*x))^-5//2, x) == :(-4*b^-2*x^3*(a+b*arcsinh(c*x))^-1//2+-8//3*x*b^-2*c^-2*(a+b*arcsinh(c*x))^-1//2+-2//3*b^-1*c^-1*x^2*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-3//2+-1//6*pi^(1/2)*b^-5//2*c^-3*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+-1//6*pi^(1/2)*b^-5//2*c^-3*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+(1/2)*3^(1/2)*pi^(1/2)*b^-5//2*c^-3*erf(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(3*a*b^-1)+(1/2)*3^(1/2)*pi^(1/2)*b^-5//2*c^-3*erfi(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-3*a*b^-1))
@test integrate(x*(a+b*arcsinh(c*x))^-5//2, x) == :(-8//3*b^-2*x^2*(a+b*arcsinh(c*x))^-1//2+-4//3*b^-2*c^-2*(a+b*arcsinh(c*x))^-1//2+-2//3*x*b^-1*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-3//2+-2//3*2^(1/2)*pi^(1/2)*b^-5//2*c^-2*erf(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(2*a*b^-1)+2//3*2^(1/2)*pi^(1/2)*b^-5//2*c^-2*erfi(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-2*a*b^-1))
@test integrate((a+b*arcsinh(c*x))^-5//2, x) == :(-4//3*x*b^-2*(a+b*arcsinh(c*x))^-1//2+-2//3*b^-1*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-3//2+2//3*pi^(1/2)*b^-5//2*c^-1*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+2//3*pi^(1/2)*b^-5//2*c^-1*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1))
@test integrate(x^2*(a+b*arcsinh(c*x))^-7//2, x) == :(-4//5*b^-2*x^3*(a+b*arcsinh(c*x))^-3//2+-16//15*b^-3*c^-3*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-1//2+-8//15*x*b^-2*c^-2*(a+b*arcsinh(c*x))^-3//2+-24//5*b^-3*c^-1*x^2*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-1//2+-2//5*b^-1*c^-1*x^2*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-5//2+-1//15*pi^(1/2)*b^-7//2*c^-3*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1)+1//15*pi^(1/2)*b^-7//2*c^-3*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+-3//5*3^(1/2)*pi^(1/2)*b^-7//2*c^-3*erf(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(3*a*b^-1)+3//5*3^(1/2)*pi^(1/2)*b^-7//2*c^-3*erfi(3^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-3*a*b^-1))
@test integrate(x*(a+b*arcsinh(c*x))^-7//2, x) == :(-8//15*b^-2*x^2*(a+b*arcsinh(c*x))^-3//2+-4//15*b^-2*c^-2*(a+b*arcsinh(c*x))^-3//2+-32//15*x*b^-3*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-1//2+-2//5*x*b^-1*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-5//2+8//15*2^(1/2)*pi^(1/2)*b^-7//2*c^-2*erf(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(2*a*b^-1)+8//15*2^(1/2)*pi^(1/2)*b^-7//2*c^-2*erfi(2^(1/2)*b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-2*a*b^-1))
@test integrate((a+b*arcsinh(c*x))^-7//2, x) == :(-4//15*x*b^-2*(a+b*arcsinh(c*x))^-3//2+-8//15*b^-3*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-1//2+-2//5*b^-1*c^-1*(1+c^2*x^2)^(1/2)*(a+b*arcsinh(c*x))^-5//2+-4//15*pi^(1/2)*b^-7//2*c^-1*erf(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(a*b^-1)+4//15*pi^(1/2)*b^-7//2*c^-1*erfi(b^-1//2*(a+b*arcsinh(c*x))^(1/2))*exp(-1*a*b^-1))

max_stars_repo_path: test/7 Inverse hyperbolic functions/7.1 Inverse hyperbolic sine/7.1.2 (d x)^m (a+b arcsinh(c x))^n.jl


text:
module BrokemiaHelperTrollStrawberry

using ..Ahorn, Maple

@mapdef Entity "BrokemiaHelper/trollStrawberry" TrollStrawberry(x::Integer, y::Integer, winged::Bool=false, moon::Bool=false, nodes::Array{Tuple{Integer, Integer}, 1}=Tuple{Integer, Integer}[])

const placements = Ahorn.PlacementDict(
    "Troll Strawberry (BrokemiaHelper)" => Ahorn.EntityPlacement(
        TrollStrawberry
    ),
    "Troll Space Berry (BrokemiaHelper)" => Ahorn.EntityPlacement(
        TrollStrawberry,
        "point",
        Dict{String, Any}(
            "moon" => true
        )
    ),
    "Troll Strawberry (Winged) (BrokemiaHelper)" => Ahorn.EntityPlacement(
        TrollStrawberry,
        "point",
        Dict{String, Any}(
            "winged" => true
        )
    ),
)

# name, winged, has pips, moon
sprites = Dict{Tuple{String, Bool, Bool, Bool}, String}(
    ("BrokemiaHelper/trollStrawberry", false, false, false) => "collectables/strawberry/normal00",
    ("BrokemiaHelper/trollStrawberry", true, false, false) => "collectables/strawberry/wings01",
    ("BrokemiaHelper/trollStrawberry", false, true, false) => "collectables/ghostberry/idle00",
    ("BrokemiaHelper/trollStrawberry", true, true, false) => "collectables/ghostberry/wings01",

    ("BrokemiaHelper/trollStrawberry", false, false, true) => "collectables/moonBerry/normal00",
    ("BrokemiaHelper/trollStrawberry", true, false, true) => "collectables/moonBerry/ghost00",
    ("BrokemiaHelper/trollStrawberry", false, true, true) => "collectables/moonBerry/ghost00",
    ("BrokemiaHelper/trollStrawberry", true, true, true) => "collectables/moonBerry/ghost00",
)

fallback = "collectables/strawberry/normal00"

Ahorn.nodeLimits(entity::TrollStrawberry) = 0, -1

function Ahorn.selection(entity::TrollStrawberry)
    x, y = Ahorn.position(entity)

    nodes = get(entity.data, "nodes", ())
    winged = get(entity.data, "winged", false)
    moon = get(entity.data, "moon", false)
    hasPips = length(nodes) > 0

    sprite = sprites[(entity.name, winged, hasPips, moon)]
    seedSprite = "collectables/strawberry/seed00"

    res = Ahorn.Rectangle[Ahorn.getSpriteRectangle(sprite, x, y)]

    for node in nodes
        nx, ny = node

        push!(res, Ahorn.getSpriteRectangle(seedSprite, nx, ny))
    end

    return res
end

function Ahorn.renderSelectedAbs(ctx::Ahorn.Cairo.CairoContext, entity::TrollStrawberry)
    x, y = Ahorn.position(entity)

    for node in get(entity.data, "nodes", ())
        nx, ny = node

        Ahorn.drawLines(ctx, Tuple{Number, Number}[(x, y), (nx, ny)], Ahorn.colors.selection_selected_fc)
    end
end

function Ahorn.renderAbs(ctx::Ahorn.Cairo.CairoContext, entity::TrollStrawberry, room::Maple.Room)
    x, y = Ahorn.position(entity)

    nodes = get(entity.data, "nodes", ())
    winged = get(entity.data, "winged", false)
    moon = get(entity.data, "moon", false)
    hasPips = length(nodes) > 0

    sprite = sprites[(entity.name, winged, hasPips, moon)]
    seedSprite = "collectables/strawberry/seed00"

    for node in nodes
        nx, ny = node

        Ahorn.drawSprite(ctx, seedSprite, nx, ny)
    end

    Ahorn.drawSprite(ctx, sprite, x, y)
end

end

max_stars_repo_name: Brokemia/BrokemiaHelper

max_issues_repo_name: Brokemia/BrokemiaHelper

max_forks_repo_name: Brokemia/BrokemiaHelper


text:
# Test replay for loop

using Turing
using ForwardDiff: Dual

# Generate synthesised data
xs = rand(Normal(0.5, 1), 100)

# Define model
@model priorsinarray(xs) = begin
  priors = Vector{Real}(undef, 2)
  priors[1] ~ InverseGamma(2, 3)
  priors[2] ~ Normal(0, sqrt(priors[1]))
  for i = 1:length(xs)
    xs[i] ~ Normal(priors[2], sqrt(priors[1]))
  # for x in xs
    # x ~ Normal(priors[2], sqrt(priors[1]))
  end
  priors
end

# Sampling
chain = sample(priorsinarray(xs), HMC(10, 0.01, 10))


text:
using Temporal, Indicators

# download historical prices for crude oil futures and subset
X = quandl("CHRIS/CME_CL1")
subset = "2012/"
x = cl(X)[subset]
x.fields[1] = :CrudeFutures

# merge with some technical indicators
D = [x sma(x,n=200) ema(x,n=50)]

# visualize the multivariate time series object
using Plots
plotlyjs()
ℓ = @layout [ a{0.7h}; b{0.3h} ]
plot(D, c=[:black :orange :cyan], w=[4 2 2], layout=ℓ, subplot=1)
plot!(wma(x,n=25), c=:red, w=2, subplot=1)
bar!(X["2012/",:Volume], c=:grey, alpha=0.5, layout=ℓ, subplot=2)


text:
@testset "Grid" begin
    win = Window("Grid test", 1280, 720) do
        a = button"a"
        b = button"b"
        c = button"c"
        d = button"d"
        e = button"e"
        f = button"f"
        Grid(@homogeneous, [
            a → 2:2     b ↓ 2
            c     d     e
                f → 3
        ])
    end

    showall(win)
    destroy(win)
end

@testset "Grid" begin
    win = Window("Grid test", 1280, 720) do
        a = button"a"
        b = button"b"
        c = button"c"
        d = button"d"
        e = button"e"
        f = button"f"
        Grid(@homogeneous) do
        [
            a → 2:2     b ↓ 2
            c     d     e
                f → 3
        ]
        end
    end

    showall(win)
    destroy(win)
end


text:
module CellwiseValuesTests

using CellwiseValues
using Test

include("CellValuesMocks.jl")

include("MapsMocks.jl")

@time @testset "CellValuesMocks" begin include("CellValuesMocksTests.jl") end

@time @testset "MapsMocks" begin include("MapsMocksTests.jl") end

@time @testset "Gallery" begin include("GalleryTests.jl") end

@time @testset "Kernels" begin include("KernelsTests.jl") end

@time @testset "CellNumberApply" begin include("CellNumberApplyTests.jl") end

@time @testset "CachedArrays" begin include("CachedArraysTests.jl") end

@time @testset "CellArrayApply" begin include("CellArrayApplyTests.jl") end

@time @testset "MapApply" begin include("MapApplyTests.jl") end

@time @testset "CellMapApply" begin include("CellMapApplyTests.jl") end

end # module CellwiseValuesTests


text:
@with_kw struct Medium{Tϵ,Tμ}
    epsilon_model::Tϵ = 1.0 * I(3)
    mu_model::Tμ = 1.0 * I(3)
end

include("./Materials/Vecfit.jl")
include("./Materials/NKTable.jl")
include("./Materials/SusceptibilityTypes.jl")
include("./Materials/DispersionModels.jl")
include("./Materials/PoleResidueDispersionModel.jl")
include("./Materials/MaterialLibrary.jl")

epsilon(medium::Medium,freq) = epsilon(medium.epsilon_model,freq)
mu(medium::Medium,freq) = mu(medium.epsilon_model,freq)

epsilon(medium::Medium{<: AbstractMatrix,<:Any},freq) = medium.epsilon_model
mu(medium::Medium{<: Any,<: AbstractMatrix},freq) = medium.mu_model
epsilon(medium::Medium{<: Number,<:Any},freq) = medium.epsilon_model * I(3)
mu(medium::Medium{<: Any,<: Number},freq) = medium.mu_model * I(3)


text:
# short named functions, not flexible, bad assumptions or improper namings might be commited

function convolution( image::Array{T1,N}, kernel::Array{T2,N}; typ=Float32 ) where {T1<:Real,T2<:Real,N}
	return FFTConvolution( image, kernel, typ=typ );
end

function convolution_b( image::Array{T1,2}, kernel::Array{T2,2}; typ=Float32 ) where {T1<:Real,T2<:Real}
	return FFTConvolution_b( image, kernel, typ=typ );
end

function smooth( image::Array{T1,2}, size ) where {T1<:Real}
	if size == 0
		return image
	end
	meanKern = meanKernel( size );
	return FFTConvolution( image, meanKern )
end

function gradient( image::Array{T1,2}; kernel="Prewitt" ) where {T1<:Real}

	kh = ( kernel=="Sobel" ) ? Sobel_h() : Prewitt_h();
    kv = ( kernel=="Sobel" ) ? Sobel_v() : Prewitt_v();

	Gy = convolution( image, kh )
	Gx = convolution( image, kv )

	return Gy[2:end-1,2:end-1], Gx[2:end-1,2:end-1]
end

# smoothing kernel

function meanKernel( size::Integer; typ=Float32 )
	return ones( typ, size, size )./( size*size )
end

# edge kernels

# Prewitt, separable
function Prewitt_h( ; typ=Float32 )
	p1, z0, n1 = typ.( ( 1, 0, -1 ) )
	return [ p1 z0 n1; p1 z0 n1; p1 z0 n1 ]
end

function Prewitt_v( ; typ=Float32 )
	p1, z0, n1 = typ.( ( 1, 0, -1 ) )
	return [ p1 p1 p1; z0 z0 z0; n1 n1 n1 ]
end

# Sobel, separable
function Sobel_h( ; typ=Float32 )
	p1, p2, z0, n1, n2 = typ.( ( 1, 2, 0, -1, -2 ) )
	return [ p1 z0 n1; p2 z0 n2; p1 z0 n1 ]
end

function Sobel_v( ; typ=Float32 )
	p1, p2, z0, n1, n2 = typ.( ( 1, 2, 0, -1, -2 ) )
	return [ p1 p2 p1; z0 z0 z0; n1 n2 n1 ]
end

max_stars_repo_name: BrucePBon/ImageAnalysis

max_issues_repo_name: BrucePBon/ImageAnalysis

max_forks_repo_name: BrucePBon/ImageAnalysis


text:
testOnAllBackends("Reduction") do af
	println("\tmax")
	afArr = array(af, [[1.0f0, 2.0f0] [4.0f0, 3.0f0]])

	@test host(max(afArr)) == Float32[2.0 4.0]
	@test host(max(afArr, 0)) == Float32[2.0 4.0]
	@test host(max(afArr, 1)) == Float32[4.0f0, 3.0f0]
	@test host(max(afArr, 2)) == [[1.0f0, 2.0f0] [4.0f0, 3.0f0]]

	println("\tmin")
	@test min(Float32, afArr) == 1.0f0

	println("\timax")
	result = imax(afArr, 0)
	@test host(result[1]) == Float32[2.0 4.0]
	@test host(result[2]) == UInt32[1 0]

	println("\timax")
	result = imax(Float32, afArr)
	@test result == (4.0,0x00000002)

	afArr = array(af, [1 2 3 4 5])

	println("\tmin")
	@test host(min(afArr)) == [1]
	@test host(min(afArr)) == [1]
end

max_stars_repo_name: unbornchikken/julia-ml-proto

max_issues_repo_name: unbornchikken/julia-ml-proto

max_forks_repo_name: unbornchikken/julia-ml-proto


text:
using Documenter
using QuadraticAssignmentProblem

makedocs(
	sitename="QuadraticAssignmentProblem.jl",
	pages = [
		"index.md",
		"solvers.md",
		"generators.md",
		"util.md",
	],
)

deploydocs(
	repo = "github.com/flixpar/QuadraticAssignmentProblem.jl.git",
	devbranch = "main",
)


text:
using Pkg, Test, DrWatson
using LibGit2
LibGit2.default_signature() = LibGit2.Signature("TEST", "TEST@TEST.COM", round(time(), 0), 0)
global_user_name = LibGit2.getconfig("user.name", "")
global_user_email = LibGit2.getconfig("user.email", "")

cd(@__DIR__)
path = "test_project"
name = "lala"

Pkg.activate()
@show Base.active_project()
@show Base.load_path_expand("@v$(VERSION.major).$(VERSION.minor)")
# @test DrWatson.is_standard_julia_project() # we cant test this on CI

initialize_project(path, force = true)
repo = LibGit2.GitRepo(path)
@test LibGit2.getconfig(repo, "user.name", "") == global_user_name
@test LibGit2.getconfig(repo, "user.email", "") == global_user_email

cd(path) do
    @test DrWatson.default_name_from_path(".") == path
end

@test !DrWatson.is_standard_julia_project()

@test projectname() == path
@test typeof(findproject(@__DIR__)) == String
@test ispath(joinpath(path, "src"))
@test ispath(joinpath(path, "data", "exp_raw"))

@test ispath(projectdir("data"))
@test isfile(joinpath(path, ".gitignore"))
@test uperm(joinpath(path, ".gitignore")) == 0x06
@test isfile(joinpath(path, "README.md"))
@test isfile(joinpath(path, "Project.toml"))
@test uperm(joinpath(path, "intro.jl")) == 0x06

for dir_type in ("data", "src", "plots", "papers", "scripts")
    fn = Symbol(dir_type * "dir")
    @eval begin
        @test $fn() == joinpath(projectdir(), $dir_type)
        @test endswith($fn("a"), joinpath($dir_type, "a"))
        @test endswith($fn(joinpath("a", "b")), joinpath($dir_type, joinpath("a", "b")))
        @test endswith($fn("a", "b"), joinpath($dir_type, joinpath("a", "b")))
        @test endswith($fn("a", "b", joinpath("c", "d")), joinpath($dir_type, joinpath("a", "b", "c", "d")))
    end
end

@test_throws ErrorException initialize_project(path, name)

initialize_project(path, name; force = true, authors = ["George", "Nick"])
repo = LibGit2.GitRepo(path)
@test LibGit2.getconfig(repo, "user.name", "") == global_user_name
@test LibGit2.getconfig(repo, "user.email", "") == global_user_email
# test gitdescribe:
com = gitdescribe(path)
@test !occursin('-', com) # no dashes = no git describe

@test projectname() == name
@test ispath(joinpath(path, "src"))
@test ispath(joinpath(path, "data", "exp_raw"))
z = read(joinpath(path, "Project.toml"), String)
@test occursin("[\"George\", \"Nick\"]", z)
z = read(joinpath(path, "intro.jl"), String)
@test occursin("@quickactivate", z)

initialize_project(path, name; force = true, authors = "Sophia", git = false)
@test !isdir(joinpath(path, ".git"))
z = read(joinpath(path, "Project.toml"), String)
@test occursin("[\"Sophia\"]", z)

# test whether a DrWatson version is added to compat
@test occursin("DrWatson =", z)

# here we test quickactivate
quickactivate(path)
@test projectname() == name

cd(path)
@test findproject(pwd()) == pwd()
cd()

# Test templates
t1 = ["data", "documents" => ["a", "b"]]
initialize_project(path, name; force = true, git = false, template = t1)

@test ispath(joinpath(path, "data"))
@test ispath(joinpath(path, "documents"))
@test ispath(joinpath(path, "documents", "a"))
@test !ispath(joinpath(path, "src"))

@info "I am now attempting to delete path."
rm(joinpath(@__DIR__, path); recursive = true, force = true)
@info "I have called the `rm` function."
@test !isdir(joinpath(@__DIR__, path))
@info "`isdir` test also passed."


text:
module ViscFoil

import ..MathTools: midpair_map, forward_difference, forward_sum, weighted_vector

import ..Laplace: Uniform2D, velocity

import ..PanelGeometry: AbstractPanel, AbstractPanel2D, Panel2D, WakePanel2D, distance, panel_length, panel_angle, panel_tangent, panel_points, panel_location, collocation_point

import ..DoubletSource: doublet_matrix, source_matrix, source_strengths, boundary_vector, solve_linear, lift_coefficient

import ..LinearVortexSource: vortex_influence_matrix, source_influence_matrix, linear_vortex_matrix, linear_source_matrix, neumann_boundary_condition

using NLsolve
using LineSearches: BackTracking
using ForwardDiff
using LinearAlgebra

include("closure_relations.jl")

reynolds_number(U, L, ν)    = U * L / ν
δ_star(m, U_e)              = m / U_e             # δ* = m/U_e
shape_parameter(m, U_e, θ)  = δ_star(m, U_e) / θ  # H = δ*/θ

include("boundary_layer.jl")

## Inviscid doublet-source solution and edge velocities
#============================================#

function solve_inviscid_doublets(panels, wakes, u)
    # Inviscid solution
    all_panels      = [ panels; wakes ]
    foil_doublets   = doublet_matrix(panels, panels)
    all_sources     = source_matrix(panels, all_panels)
    A_inv           = foil_doublets^(-1)
    P               = -A_inv * all_sources

    # Mass defect block computation
    all_lengths = panel_length.(all_panels)         #  N + N_w
    B           = source_matrix(wakes, all_panels)  # (N_w, N + N_w)
    A_w         = doublet_matrix(wakes, panels)     # (N_w, N)
    dKds        = -midpair_map(-, defect_block(P, A_w, B)) ./ all_lengths
    D           = dKds ./ all_lengths'

    # Inviscid velocities
    φs          = A_inv * boundary_vector(panels, u, (0., 0.))
    q0s, Δrs    = tangential_velocities(panels, φs, u, false)
    U_invs      = [ q0s; Ref(u) .+ panel_tangent.(wakes) ]

    U_invs, D, all_lengths
end

# Inviscid linear vortex solution and edge velocities
#============================================#

function solve_inviscid_vortices(panels, wakes, u)
    # Inviscid solution
    all_panels      = [ panels; wakes ]
    foil_vortices   = vortex_influence_matrix(panels)
    all_sources     = source_influence_matrix(panels, all_panels)
    A_inv           = foil_vortices^(-1)
    P               = -A_inv * all_sources

    # Mass defect block computation
    all_lengths     = panel_length.(all_panels)                 # Foil and Wake: N + N_w
    B               = linear_source_matrix(wakes, all_panels)
    A_w             = linear_vortex_matrix(wakes, panels)
    C               = defect_block(P, A_w, B)[:,1:end-1]
    D               = C ./ all_lengths'

    # Inviscid velocities
    U_inv_f     = A_inv * neumann_boundary_condition(panels, u) # Foil: N + 1
    U_inv_w     = neumann_boundary_condition(wakes, u)          # Wake: N_w + 1
    U_invs      = [ U_inv_f[1:end-1]; U_inv_w ]                 # Foil and wake: N + N_w + 2

    U_invs, D, all_lengths
end

## Defect formulation
#============================================#

defect_block(P, Aw, B)         = [ P; Aw * P + B ]
edge_velocities(ms, D, U_invs) = U_invs + D * ms

## Newton setup
#============================================#

function solve_system(x_in, panels, all_lengths, C, U_invs, n_crit)
    # Number of nodes
    n  = length(all_lengths)

    # Segregating into inputs
    ms = x_in[1:n+1] # N + N_w + 1
    θs = x_in[n+2:2n+1] # N + N_w
    Ts = x_in[2n+2:end] # N + N_w

    # Forward differencing mass defects
    Δms  = forward_difference(ms) # N + N_w + 1 -> N + N_w

    # println(size(U_invs), size(ms), size(θs), size(Ts))
    # println(size(Δms), size(all_lengths))

    # Compute edge velocities
    σs      = Δms ./ all_lengths
    Us      = abs.(edge_velocities(σs, C, U_invs))
    δ_stars = @. abs(ms[1:end-1] / Us[1:end-1])     # N + Nw
    ΔXs     = all_lengths

    # Constants
    a = 330
    ν = 1.5e-5

    # Trailing edge initial conditions for θ and δ*

    # Initial wake shear coefficient
    # c_τ_wake = c_τ

    # Evaluate residuals
    # R1, R2, R3 =

    R = boundary_layer_finite_difference(Us[1:end-1], δ_stars, θs, Ts, ΔXs, panels, n_crit, a, ν)[:]

    # [ R1; R2; R3 ]
end

function solve_viscous_case(panels, wakes, uniform :: Uniform2D)
    u = velocity(uniform)
    α = uniform.angle

    # Evaluate inviscid edge velocities and mass defect matrix
    #======================================================#

    ## Doublet-source panel method schema
    # U_invs, D, all_lengths = solve_inviscid_doublets(panels, wakes, u)

    ## Linear vortex-source panel method schema
    U_invs, D, all_lengths = solve_inviscid_vortices(panels, wakes, u)

    @show U_invs

    # Ugly tagging and setup
    #======================================================#

    # tags    = [ fill(typeof(panels[1]), length(panels)) ; # Foil panels
                # fill(typeof(wakes[1] ), length(wakes) ) ] # Wake panels
    n_crit  = 9 # Critical amplification ratio for Tollmien-Schlichting waves to transition

    # Initialize variables
    num_nodes   = length(panels) + length(wakes)                        # N + N_w
    ms          = U_invs ./ [ all_lengths; all_lengths[end] ] .* 0.01   # N + N_w + 1
    θs          = fill(0.1, num_nodes)                                  # N + N_w
    ns          = fill(6.0, num_nodes)                                  # N + N_w
    x0          = [ ms; θs; ns ] # Is there any better way to guess than the heuristic?

    # Solving system
    #======================================================#

    # R  = zeros(num_nodes * num_vars + 1)
    system(x)   = solve_system(x, [panels; wakes], all_lengths, D, U_invs, n_crit)
    state       = nlsolve(system,
                          x0,
                          iterations = 20,
                        #   autodiff = :forward,
                          show_trace = true,
                          # extended_trace = true,
                          store_trace = true,
                          method = :newton,
                          linesearch = BackTracking())
end

end

# if writer
#  open("state_variables.txt", "w") do io
#  write(io, "Iteration $n \n")
#  write(io, "Solving system... \n")
#  write(io, "ms: $ms \n")
#  write(io, "θs: $θs \n")
#  write(io, "Ue/V∞: $(ues ./ norm(u)) \n")
#  write(io, "δ*: $δ_stars \n")
#  write(io, "H: $Hs \n")
#  write(io, "H*: $H_stars \n")
#  write(io, "Cfs: $cfs \n")
#  end;
# end

# NOTE: central differencing has different endpoints for all_panels
# foil_lengths = panel_length.(panels)  # N  -> N
# dP  = -midpair_map(-, P) # (N, N + N_w)  -> (N, N + N_w)

# Constructing forward differences for mass defect
# foil_lengths = distance.(panels[1:end-1], panels[2:end])  # N  -> N - 1
# all_lengths  = distance.(all_panels[1:end-1], all_panels[2:end])  # N + N_w  -> N + N_w - 1
# dP   = P[2:end,:] .- P[1:end-1,:]  # (N, N + N_w)  -> (N - 1, N + N_w)


text:
using RecipesBase

@recipe function plot(f_ts::TimeSeries, ii::Vararg)
    tmp = get_coords(f_ts,ii...)
    f   = f_ts[ii...]

    # we want to select only those that are *not* Numbers (ie, Arrays or Ranges)
    idx = .!isa.(tmp, Number)
    idx = [idx...]
    coord = [tmp...]

    xx = coord[idx]

    xx_f = [xx..., f]

    match_dimensions := true

    (xx_f...,)
end


text:
using DataFrames, GoogleCharts, Dates
render = identity

year_sales_expenses = DataFrame(
    Year     = map(string, 2004:2007),
    Sales    = [1000, 1170, 660, 1030],
    Expenses = [400, 460,1120, 540]
)

## Area Chart

area_data = year_sales_expenses

options = [
           :title => "Company Performance",
           :hAxis => [:title => "Year",  :titleTextStyle => [:color => "red"]]
           ];
chart = area_chart(area_data, options)
render(chart)
## or
area_chart(area_data, title="Company Performance", haxis=[:title => "Year",  :titleTextStyle => [:color => "red"]])

## Bar Chart
bar_data = area_data
chart = bar_chart(bar_data, options)
render(chart)

## Bubble Chart

bubble_data = DataFrame(
    ID              = ["CAN","DEU","DNK"],
    Life_Expectancy = [80.66, 79.84, 78.6],
    Fertility_Rate  = [1.67, 1.36, 1.84],
    Region          = ["North America", "Europe", "Europe"],
    Population      = [33739900, 81902307, 5523095]
)

options = [
           :title => "Correlation between life expectancy, fertility rate and population of some world countries (2010)",
           :hAxis => [:title => "Life Expectancy"],
           :vAxis => [:title => "Fertility Rate"],
           :bubble=> [:textStyle => [:fontSize => 11]]
           ];

chart = bubble_chart(bubble_data, options)
render(chart)
## or
bubble_chart(bubble_data,
           title = "Correlation between life expectancy, fertility rate and population of some world countries (2010)",
           hAxis = [:title => "Life Expectancy"],
           vAxis = [:title => "Fertility Rate"],
           bubble= [:textStyle => [:fontSize => 11]]
           )

## candlestick_chart,
candle_data = DataFrame(
    days    = ["Mon", "Tue", "Wed", "Thu", "Fri"],
    low     = [ 20, 28, 38, 45, 50],
    opening = [ 31, 50, 55, 77, 80],
    closing = [ 50, 55, 77, 80, 50],
    high    = [ 77, 77, 96, 90, 90]
)

chart = candlestick_chart(candle_data, Dict())
render(chart)

## column_chart,
column_data = year_sales_expenses
options = [:title => "Company performance",
           :hAxis => [:title=> "Year", :titleTextStyle=> [:color => "red"]]]

chart = column_chart(column_data, options)
render(chart)
## combo_chart,

combo_data = DataFrame(
    Month = ["2004/05","2005/06","2006/07","2007/08","2008/09"],
    Bolivia = [165, 135, 157, 139, 136],
    Madagascar = [938, 1120, 1167, 1110, 691],
    PapauNewGuinea = [522, 599, 587, 615, 629],
    Rwand = [998, 1268, 807, 968, 1026],
    Average = [614.6, 682, 623, 609.4, 569.6]
)

options = [
           :title => "Monthly Coffee Production by Country",
           :vAxis=> [:title=> "Cups"],
           :hAxis=> [:title=> "Month"],
           :seriesType=> "bars",
           :series=> ["{}","{}","{}","{}",[:type=> "line"]]
        ];
chart = combo_chart(combo_data, options)
render(chart)
## gauge_chart,
 gauge_data = DataFrame(
     Label=["Memory", "CPU", "Network"],
     Value = [80, 55, 68]
     )

options = [
           :width=> 400, :height=> 120,
           :redFrom=> 90, :redTo=> 100,
           :yellowFrom=>75, :yellowTo=> 90,
           :minorTicks=> 5
        ]
chart = gauge_chart(gauge_data, options)
render(chart)
## geo_chart,

geo_data = DataFrame(
    Country = ["Germany", "United States", "Brazil", "Canada", "France", "RU"],
    Popularity = [200, 300, 400, 500, 600, 700]
)
options = Dict()
chart = geo_chart(geo_data, options)
render(chart)

## Line Chart
line_data = area_data
options = [:title => "Company Performance"]
chart = line_chart(line_data, options)
render(chart)

## pie_chart,
pie_data = DataFrame(
    Task = ["Work", "Eat", "Commute", "Watch TV", "Sleep"],
    HoursPerDay = [11,2,2,2,7]
)
options = [:title => "My Daily Activities"]
chart = pie_chart(pie_data, options)
render(chart)

## Scatter Chart

scatter_data = DataFrame(
    Age = [8,4,11,4,3,6.5],
    Weight = [12, 5.5, 14, 5, 3.5, 7]
)
options = [:title => "Age vs. Weight comparison",
           :hAxis =>  [:title => "Age", :minValue => 0, :maxValue => 15],
           :vAxis => [:title => "Weight", :minValue => 0, :maxValue => 15]
]

chart = scatter_chart(scatter_data, options)
render(chart)

## stepped_area__chart,

stepped_area_data = DataFrame(
                              Director = ["Alfred Hitchcock (1935)", "Ralph Thomas (1959)","Don Sharp (1978)", "James Hawes (2008)"],
                              RottenTomatoes = [8.4, 6.9, 6.5, 4.4],
                              IMDB = [7.9, 6.5, 6.4, 6.2]
                              )
options = [:title=>"The decline of 'The 39 Steps'", :vAxis => [:title=>"Accumulated Rating"], :isStacked => true]
chart = stepped_area_chart(stepped_area_data, options)
render(chart)
## table_chart,
### XXX Need a way to do value/format for Salary, but perhaps this is best done in julia?
table_data = DataFrame(
    Name = ["Mike", "Jim", "Alice", "Bob"],
    Salary = [10000, 8000, 12500, 7000],
    FullTimeEmployee = [true, false, true, true]
)
options = [:showRowNumber => true]
chart = table_chart(table_data, options)
render(chart)

## tree_chart,
tree_data = DataFrame(
                      Location = ["Global", "America","Europe","Asia","Australia","Africa","Brazil","USA","Mexico","Canada","France","Germany","Sweden","Italy","UK","China","Japan","India","Laos","Mongolia","Israel","Iran","Pakistan","Egypt","S. Africa","Sudan","Congo","Zair"],
                      Parent = [nothing, "Global","Global","Global","Global","Global","America","America","America","America","Europe","Europe","Europe","Europe","Europe","Asia","Asia","Asia","Asia","Asia","Asia","Asia","Asia","Africa","Africa","Africa","Africa","Africa"],
                      MarketTradeVolume_Size = [0,0,0,0,0,0,11,52,24,16,42,31,22,17,21,36,20,40,4,1,12,18,11,21,30,12,10,8],
                      MarketIncreaseDecrease_color = [0,0,0,0,0,0,10,31,12,-23,-11,-2,-13,4,-5,4,-12,63,34,-5,24,13,-52,0,43,2,12,10]
)
options = [
          :minColor=> "#f00",
          :midColor=> "#ddd",
          :maxColor=> "#0d0",
          :headerHeight=> 15,
          :fontColor=> "black",
          :showScale=> true
           ]
chart = tree_chart(tree_data, options)
render(chart)

## annotated_time_line,
## extra hassle to get ymd into data frame
annotated_data = DataFrame()
annotated_data[:Year] = [Date(2008, 1, i) for i in 1:6]

tmp = DataFrame(
                SoldPencils = [30000, 14045, 55022,75284, 41476, 33322],
                Title1 = [nothing,nothing,nothing,nothing,"bought pens",nothing],
                Text1 = [nothing,nothing,nothing,nothing,"bought 200k pens",nothing],
                SoldPens = [40675, 20374,50766, 14334, 66467, 39643],
                title2 = [nothing,nothing,nothing,"Out of Stock",nothing, nothing],
                text2 = [nothing,nothing,nothing,"Ran out of stock on pens at 4pm",nothing, nothing]
                )
annotated_data = vcat(annotated_data, tmp)
options = [:displayAnnotations=>true]
chart = annotated_time_line(annotated_data, options)
render(chart)

## intensity_map,

## Motion chart: Doesn't render locally without some adjustments...
## http://helpx.adobe.com/flash-player/kb/communicate-internet-flash-content.html
d = DataFrame()
d[:Fruit] = ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"]
j1, j2 = Date(1988, 1, 1), Date(1989, 1, 1)
d[:Date] = [j1, j1, j1, j2, j2, j2]
d[:Sales] = [1000, 1150, 300, 1200, 750, 788]
d[:Expenses] = [300, 200, 250, 400, 150, 617]
e,w = "East", "West"
d[:Location] = [e, w, w, e, w, w]

chart = motion_chart(d, nothing)
render(chart)

## org_chart,

org_data = DataFrame(
    Name = ["Mike", "Jim", "Alice", "Bob", "Carol"],
    Manager = ["", "Mike", "Mike", "Jim", "Bob"],
    Tooltip = ["The presidient", "VP", "", "Bob Sponge", ""]
)

options = [:allowHtml=>true]
chart = org_chart(org_data, options)
render(chart)

## image_spark_line ## Deprecated by google
spark_data = DataFrame(
    Revenue = [435, 438, 512, 460, 491, 387, 552,511, 505, 509],
    Licenses = [132, 131, 137, 142, 140, 139, 147, 146, 151, 149],
)

options = [:width=> 120, :height=> 40, :showAxisLines=> false,  :showValueLabels=> false, :labelPosition=> "left"]

chart = image_spark_line(spark_data, options)
render(chart)

## Our plot interface
plot(sin, 0, 2pi)
plot([sin, u -> cos(u) > 0 ? 0.0 : NaN], 0, 2pi, [:lineWidth=>5,
	                                        :title=>"A function and where its derivative is positive",
						:vAxis=>[:minValue => -1.2, :maxValue => 1.2]
						])
plot([sin, u -> cos(u) > 0 ? sin(u) : NaN], 0, 2pi, [:lineWidth=>5,
	                                        :title=>"A function and where its derivative is positive",
						:vAxis=>[:minValue => -1.2, :maxValue => 1.2]
						])

## stupid boxplot interface
x = randn(20)
y = rand(20)
boxplot(x)
## might swap x and y order
boxplot([:x => x, :y=>y])
## a bit better
d = DataFrame(data=[x, y],
              nms=reshape([repmat(["x"], length(x),1), repmat(["y"], length(y),1)], length([x,y]))
              )
gp = groupby(d, :nms)
boxplot(gp)

## histogram
histogram(x)
histogram(x, n=50)

## From the README

## parametric plots
plot((x -> sin(2x), cos), 0, 2pi)

## scatter plots
x = linspace(0, 1., 20)
y = rand(20)
scatter(x, y)

using RDatasets
mtcars = dataset("datasets", "mtcars")
scatter(:WT, :MPG, mtcars)

iris = dataset("datasets", "iris")
d=iris[:, [2,3,5]]          ## in the order  "x, y, grouping factor"
gp = groupby(d, :Species)
scatter(gp)

## surface plots (YMMV)
#surfaceplot((x,y) -> x^2 + y^2, linspace(0,1,20), linspace(0,2,20))


text:
"""
LX_NAME_PAT

Regex to find the name in a new command within a brace block. For example:
    \\newcommand{\\com}[2]{def}
will give as first capture group `\\com`.
"""
const LX_NAME_PAT = r"^\s*(\\[a-zA-Z]+)\s*$"

"""
LX_NARG_PAT

Regex to find the number of argument in a new command (if it is given). For example:
    \\newcommand{\\com}[2]{def}
will give as second capture group `2`. If there are no number of arguments, the second capturing
group will be `nothing`.
"""
const LX_NARG_PAT = r"\s*(\[\s*(\d)\s*\])?\s*"

"""
LX_TOKENS

List of names of latex tokens. (See markdown tokens)
"""
const LX_TOKENS = (:LX_BRACE_OPEN, :LX_BRACE_CLOSE, :LX_COMMAND)

"""
$(TYPEDEF)

Structure to keep track of the definition of a latex command declared via a
`\newcommand{\name}[narg]{def}`.

NOTE: mutable so that we can modify the `from` element to mark it as zero when the command has been
defined in the context of what we're currently parsing.
"""
mutable struct LxDef
    name::String
    narg::Int
    def ::AS
    # location of the definition > only things that can be mutated via pastdef!
    from::Int
    to  ::Int
end
# if offset unspecified, start from basically -∞ (configs etc)
function LxDef(name::String, narg::Int, def::AS)
    o = OFFSET_GLOB_LXDEFS[] += 5 # we don't care just fwd a bit
    LxDef(name, narg, def, o, o + 3) # we also don't care YOLO
end

from(lxd::LxDef) = lxd.from
to(lxd::LxDef)   = lxd.to

"""
pastdef(λ)

Convenience function to mark a definition as having been defined in the context i.e.: earlier than
any other definition appearing in the current page.
"""
pastdef(λ::LxDef) = LxDef(λ.name, λ.narg, λ.def)

"""
$(TYPEDEF)

A `LxCom` has a similar content as a `Block`, with the addition of the definition and a vector of
brace blocks.
"""
struct LxCom <: AbstractBlock
    ss    ::SubString       # \\command
    lxdef ::Ref{LxDef}      # definition of the command
    braces::Vector{OCBlock} # relevant {...} associated with the command
end
LxCom(ss, def) = LxCom(ss, def, Vector{OCBlock}())
from(lxc::LxCom) = from(lxc.ss)
to(lxc::LxCom) = to(lxc.ss)

"""
$(SIGNATURES)

For a given `LxCom`, retrieve the definition attached to the corresponding `LxDef` via the
reference.
"""
getdef(lxc::LxCom) = getindex(lxc.lxdef).def

"""
$(TYPEDEF)

Convenience structure to keep track of the latex commands and braces.
"""
struct LxContext
    lxcoms::Vector{LxCom}
    lxdefs::Vector{LxDef}
    bblocks::Vector{OCBlock}
end


text:
using Pkg

currentpath = splitpath(pwd())
moduledir = joinpath(currentpath[1:end - 1]...)

Pkg.develop(PackageSpec(path=moduledir))

using Documenter

makedocs(sitename="CooperativeGames.jl")