text:
using Test, Pkg
using CairoMakie
path = normpath(joinpath(dirname(pathof(AbstractPlotting)), "..", "test", "ReferenceTests"))
Pkg.develop(PackageSpec(path=path))
using ReferenceTests
using ReferenceTests: nice_title
CairoMakie.activate!(type = "png")

excludes = Set((
    "Colored Mesh",
    "Line GIF",
    "Streamplot animation",
    "Line changing colour",
    "Axis + Surface",
    "Streamplot 3D",
    "Meshscatter Function",
    "Hollow pie chart",
    "Record Video",
    "Image on Geometry (Earth)",
    "Comparing contours, image, surfaces and heatmaps",
    "Textured Mesh",
    "Simple pie chart",
    "Animated surface and wireframe",
    "Open pie chart",
    "image scatter",
    "surface + contour3d",
    "Orthographic Camera",
    "Legend",
    "rotation",
    "3D Contour with 2D contour slices",
    "Surface with image",
    "Test heatmap + image overlap",
    "Text Annotation",
    "step-2",
    "FEM polygon 2D.png",
    "Text rotation",
    "Image on Surface Sphere",
    "FEM mesh 2D",
    "Hbox",
    "Stars",
    "Subscenes",
    "Arrows 3D",
    "Layouting",
    # sigh this is actually super close,
    # but doesn't interpolate the values inside the
    # triangles, so looks pretty different
    "FEM polygon 2D",
    "Connected Sphere"
))

database = ReferenceTests.load_database()

filter!(database) do (name, entry)
    !(entry.title in excludes) &&
    !(:volume in entry.used_functions) &&
    !(:volume! in entry.used_functions) &&
    !(:uv_mesh in entry.used_functions) &&
    nice_title(entry) !== "short_tests_90" &&
    nice_title(entry) !== "short_tests_111" &&
    nice_title(entry) !== "short_tests_35"
end

recorded = joinpath(@__DIR__, "recorded")
rm(recorded; force=true, recursive=true); mkdir(recorded)
ReferenceTests.record_tests(database; recording_dir=recorded)
ReferenceTests.reference_tests(recorded)


text:
export l2_func, l2_grad!, huber_func, huber_grad!

###########################################################
# l2 penalty
function l2_func(r)
    T = real(eltype(r))
    return sum(abs2,r)*T(0.5)
end

function l2_grad!(r)
    conj!(r)
    T = eltype(r)
    BLAS.scal!(length(r),T(0.5),r,1)
end

###########################################################
# Huber penalty
function huber_func(r,kappa)
    T = real(eltype(r))
    val = T(0.0)
    Thalf = T(0.5)
    @inbounds for i in eachindex(r)
        ri = r[i];
        rho = abs(ri);
        val += rho <= kappa ? Thalf*rho^2 : kappa*rho - Thalf*kappa^2
    end
    return val
end

function huber_grad!(r,kappa)
    T = real(eltype(r))
    Thalf = T(0.5)
    Thalfkappa = Thalf*kappa
    @inbounds for i in eachindex(r)
        ri = r[i]
        rho = abs(ri);
        r[i] = rho <= kappa ? Thalf*conj(ri) : (Thalfkappa/rho)*conj(ri);
    end
end

ext: jl


text: Dict{String, Any}("foo" => Any[Dict{String, Any}("bar" => Dict{String, Any}("value" => "\"{{baz}}\"", "type" => "string"))])


text:
dom = Domain(1000.:1:8000)
iter=10_000

c = emline(4862)
test_component(c, dom, iter=iter)
c.profile = :Lorentzian
test_component(c, dom, iter=iter)

c = powerlaw(4862)
test_component(c, dom, iter=iter)

c = hostgalaxy("Ell5")
test_component(c, dom, iter=iter)

c = ironopt_broad(3000.)
test_component(c, dom, iter=iter)

c = ironopt_narrow(800.)
test_component(c, dom, iter=iter)

c = ironuv(30000.)
test_component(c, dom, iter=iter)


text:
using Test
using Random: seed!
using StaticArrays: SVector
using QuantumLattices.Essentials.Spatials
using QuantumLattices.Interfaces: decompose,rank,dimension,kind,expand,reset!
using QuantumLattices.Prerequisites: Float
using QuantumLattices.Prerequisites.SimpleTrees: leaves

@testset "distance" begin
    @test distance([0.0,0.0],[1.0,1.0])≈sqrt(2.0)
end

@testset "azimuthd" begin
    @test azimuthd([+1.0])≈0.0
    @test azimuthd([-1.0])≈180.0
    @test azimuthd([+1.0,+1.0])≈45.0
    @test azimuthd([-1.0,-1.0])≈225.0
    @test azimuthd([+1.0,+1.0,-2.0])≈45.0
    @test azimuthd([+1.0,-1.0,+2.0])≈315.0
end

@testset "azimuth" begin
    @test azimuth([+1.0])≈0.0
    @test azimuth([-1.0])≈pi
    @test azimuth([+1.0,+1.0])≈1//4*pi
    @test azimuth([-1.0,-1.0])≈5//4*pi
    @test azimuth([+1.0,+1.0,-2.0])≈1//4*pi
    @test azimuth([+1.0,-1.0,+2.0])≈7//4*pi
end

@testset "polard" begin
    @test polard([1.0,0.0,1.0])≈45.0
end

@testset "polard" begin
    @test polar([1.0,0.0,1.0])≈1//4*pi
end

@testset "volume" begin
    @test volume([1,0],[0,1],[1,1])==0
    @test volume([1,0,0],[0,1,0],[0,0,1])==1
end

@testset "isparallel" begin
    @test isparallel([0.0,0.0],[1.0,1.0])==1
    @test isparallel([2.0,2.0],[1.0,1.0])==1
    @test isparallel([-2.0,-2.0],[1.0,1.0])==-1
    @test isparallel([1.0,-1.0],[1.0,1.0])==0
end

@testset "isonline" begin
    seed!()
    p1,p2=[0.0,0.0],[1.0,1.0]
    @test isonline([0.0,0.0],p1,p2,ends=(true,rand(Bool)))==true
    @test isonline([0.0,0.0],p1,p2,ends=(false,rand(Bool)))==false
    @test isonline([1.0,1.0],p1,p2,ends=(rand(Bool),true))==true
    @test isonline([1.0,1.0],p1,p2,ends=(rand(Bool),false))==false
    @test isonline([0.5,0.5],p1,p2,ends=(rand(Bool),rand(Bool)))==true
    @test isonline([1.1,1.1],p1,p2,ends=(rand(Bool),rand(Bool)))==false
end

@testset "decompose" begin
    a,c=randn(3),randn()
    @test all(decompose(c*a,a).≈(c,))

    a1,a2=randn(2),randn(2)
    c1,c2=randn(2)
    @test all(decompose(c1*a1+c2*a2,a1,a2).≈(c1,c2))

    a1,a2=randn(3),randn(3)
    c1,c2=randn(2)
    @test all(decompose(c1*a1+c2*a2,a1,a2).≈(c1,c2))

    a1,a2,a3=randn(3),randn(3),randn(3)
    c1,c2,c3=randn(3)
    @test all(decompose(c1*a1+c2*a2+c3*a3,a1,a2,a3).≈(c1,c2,c3))
end

@testset "isintratriangle" begin
    seed!()
    p1,p2,p3=[-1.0,0.0],[0.0,1.0],[1.0,0.0]
    for (i,p) in enumerate((p1,p2,p3))
        @test isintratriangle(p,p1,p2,p3,vertexes=Tuple(j==i ? true : rand(Bool) for j=1:3),edges=(rand(Bool),rand(Bool),rand(Bool)))==true
        @test isintratriangle(p,p1,p2,p3,vertexes=Tuple(j==i ? false : rand(Bool) for j=1:3),edges=(rand(Bool),rand(Bool),rand(Bool)))==false
    end
    for (i,p) in enumerate(((p1+p2)/2,(p2+p3)/2,(p3+p1)/2))
        @test isintratriangle(p,p1,p2,p3,vertexes=(rand(Bool),rand(Bool),rand(Bool)),edges=Tuple(j==i ? true : rand(Bool) for j=1:3))==true
        @test isintratriangle(p,p1,p2,p3,vertexes=(rand(Bool),rand(Bool),rand(Bool)),edges=Tuple(j==i ? false : rand(Bool) for j=1:3))==false
    end
    @assert isintratriangle([0.0,0.5],p1,p2,p3,vertexes=(rand(Bool),rand(Bool),rand(Bool)),edges=(rand(Bool),rand(Bool),rand(Bool)))==true
    @assert isintratriangle([0.0,1.5],p1,p2,p3,vertexes=(rand(Bool),rand(Bool),rand(Bool)),edges=(rand(Bool),rand(Bool),rand(Bool)))==false
end

@testset "issubordinate" begin
    @test issubordinate([2.0],[[1.0]])==true
    @test issubordinate([1.5],[[1.0]])==false
    @test issubordinate([0.5,3.5],[[0.5,0.5],[-0.5,0.5]])==true
    @test issubordinate([0.5,3.0],[[0.5,0.5],[-0.5,0.5]])==false
    @test issubordinate([4.0,4.0,4.0],[[1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,1.0]])==true
    @test issubordinate([4.0,4.0,2.5],[[1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,1.0]])==false
end

@testset "reciprocals" begin
    @test reciprocals([[1.0]])≈[[1.0]]*2pi
    @test reciprocals([[1.0,0.0],[0.0,1.0]])≈[[1.0,0.0],[0.0,1.0]]*2pi
    @test reciprocals([[1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,1.0]])≈[[1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,1.0]]*2pi
end

@testset "translate" begin
    @test translate([1.0 2.0; 3.0 4.0],[1.0,2.0])==[2.0 3.0; 5.0 6.0]
end

@testset "rotate" begin
    @test rotate([1.0 2.0; 1.0 2.0],pi/4,axis=([1.0,1.0],(0.0,0.0)))≈[1.0 1.0; 1.0 1.0+√2.0]
    @test rotate(reshape([2.0,2.0,2.0],3,1),pi/12,axis=([0.0,1.0,1.0],(pi/2,0.0)))≈reshape([2.0,1.0+√2/2,1.0+√6/2],3,1)
    @test rotate(reshape([2.0,2.0,2.0],3,1),pi/12,axis=([1.0,0.0,1.0],(pi/2,pi/2)))≈reshape([1.0+√6/2,2.0,1.0+√2/2],3,1)
    @test rotate(reshape([2.0,2.0,2.0],3,1),pi/12,axis=([1.0,1.0,0.0],(0.0,0.0)))≈reshape([1.0+√2/2,1.0+√6/2,2.0],3,1)
end

@testset "tile" begin
    @test tile(reshape([0.0,0.0],2,1),[[1.0,0.0],[0.0,1.0]],((0.5,0.5),(-0.5,-0.5)))==[0.5 -0.5; 0.5 -0.5]
end

@testset "minimumlengths" begin
    @test minimumlengths(reshape([0.0,0.0],2,1),[[1.0,0.0],[0.0,1.0]],7)≈[1.0,√2,2.0,√5,2*√2,3.0,√10]
end

@testset "intralinks" begin
    ps,a1,a2=[0.0 0.5; 0.0 0.5],[1.0,0.0],[0.0,1.0]
    neighbors=Dict(1=>1.0)
    links=[(1,1,1,SVector(0.0,-1.0)),(1,1,1,SVector(-1.0,0.0)),(1,2,2,SVector(0.0,-1.0)),(1,2,2,SVector(-1.0,0.0))]
    @test intralinks(ps,[a1,a2],neighbors)==links
end

@testset "interlinks" begin
    ps1=[0.0 1.0; 0.0 0.0]
    ps2=[0.0 1.0; 1.0 1.0]
    neighbors=Dict(1=>1.0)
    links=[(1,1,1),(1,2,2)]
    @test interlinks(ps1,ps2,neighbors)==links
end

@testset "PID" begin
    @test PID(1)==PID('T',1)==PID(scope='T',site=1)
    @test PID(scope="tz",site=1)|>string=="PID(\"tz\",1)"
    @test fieldnames(PID{String})==(:scope,:site)
end

@testset "Point" begin
    point=Point(PID(0,1),(0.0,0.0),(0.0,0.0))
    @test point==Point(PID(0,1),[0.0,0.0],[0.0,0.0])
    @test isequal(point,Point{2}(PID(0,1),[0.0,0.0],[0.0,0.0]))
    @test point|>length==point|>typeof|>length==1
    @test point|>eltype==point|>typeof|>eltype==Point{2,PID{Int}}
    @test point|>rank==point|>typeof|>rank==1
    @test point|>pidtype==point|>typeof|>pidtype==PID{Int}
    @test point|>dimension==point|>typeof|>dimension==2
    @test point|>kind==point|>typeof|>kind==0
    @test point|>string=="Point(PID(0,1),[0.0,0.0],[0.0,0.0])"
    @test point|>collect==[point]
end

@testset "Bond" begin
    bond=Bond(1,Point(PID(1,1),(0.0,0.0),(0.0,0.0)),Point(PID(1,2),(0.0,1.0),(0.0,1.0)))
    @test bond|>deepcopy==bond
    @test isequal(bond|>deepcopy,bond)
    @test bond|>string=="Bond(1,Point(PID(1,1),[0.0,0.0],[0.0,0.0]),Point(PID(1,2),[0.0,1.0],[0.0,1.0]))"
    @test bond|>reverse==Bond(1,Point(PID(1,2),(0.0,1.0),(0.0,1.0)),Point(PID(1,1),(0.0,0.0),(0.0,0.0)))
    @test bond|>length==bond|>typeof|>length==2
    @test bond|>eltype==bond|>typeof|>eltype==Point{2,PID{Int}}
    @test bond|>rank==bond|>typeof|>rank==2
    @test bond|>pidtype==bond|>typeof|>pidtype==PID{Int}
    @test bond|>dimension==bond|>typeof|>dimension==2
    @test bond|>kind==1
    @test bond|>rcoord==[0.0,1.0]
    @test bond|>icoord==[0.0,1.0]
    @test bond|>isintracell==false
    @test bond|>collect==[Point(PID(1,2),(0.0,1.0),(0.0,1.0)),Point(PID(1,1),(0.0,0.0),(0.0,0.0))]
end

@testset "Lattice" begin
    lattice=Lattice("Tuanzi",[Point(PID(1,1),(0.5,0.5),(0.0,0.0))],vectors=[[1.0,0.0],[0.0,1.0]],neighbors=1)
    @test lattice|>deepcopy==lattice
    @test isequal(lattice|>deepcopy,lattice)
    @test lattice|>string=="Lattice(Tuanzi)\n  with 1 point:\n    Point(PID(1,1),[0.5,0.5],[0.0,0.0])\n  with 2 translation vectors:\n    [1.0,0.0]\n    [0.0,1.0]\n  with 1 order of nearest neighbors:\n    1=>1.0\n"
    @test lattice|>length==1
    @test lattice|>dimension==lattice|>typeof|>dimension==2
    @test lattice|>keytype==lattice|>typeof|>keytype==PID{Int}
    @test lattice|>valtype==lattice|>typeof|>valtype==Point{2,PID{Int}}
    @test lattice[LatticeIndex{'R'}(1)]==lattice[LatticeIndex{'R'}(PID(1,1))]==SVector(0.5,0.5)
    @test lattice[LatticeIndex{'I'}(1)]==lattice[LatticeIndex{'I'}(PID(1,1))]==SVector(0.0,0.0)
    @test lattice[LatticeIndex{'P'}(1)]==lattice[LatticeIndex{'P'}(PID(1,1))]==Point(PID(1,1),(0.5,0.5),(0.0,0.0))
    @test lattice|>nneighbor==1

    zerothbs=[Point(PID(1,1),(0.5,0.5),(0.0,0.0))]
    insidebs=[]
    acrossbs=[  Bond(1,Point(PID(1,1),[0.5,0.5],[0.0,0.0]),Point(PID(1,1),[0.5,-0.5],[0.0,-1.0])),
                Bond(1,Point(PID(1,1),[0.5,0.5],[0.0,0.0]),Point(PID(1,1),[-0.5,0.5],[-1.0,0.0]))
    ]
    @test bonds(lattice,zerothbonds)==zerothbs
    @test bonds(lattice,insidebonds)==insidebs
    @test bonds(lattice,acrossbonds)==acrossbs
    @test setdiff(bonds(lattice),[zerothbs;insidebs;acrossbs])|>length==0

    lattice=Lattice(    "SuperTuanzi",
                        [   Lattice("Tuanzi1",[Point(PID(1,1),(0.0,0.0))],neighbors=0),
                            Lattice("Tuanzi2",[Point(PID(2,1),(0.5,0.5))],neighbors=0),
                            ],
                        vectors=    [[1.0,0.0],[0.0,1.0]],
                        neighbors=  2,
                            )
    @test setdiff(bonds(lattice),bonds(lattice,zerothbonds,insidebonds,acrossbonds))|>length==0
end

@testset "SuperLattice" begin
    lattice=SuperLattice(   "SuperTuanzi",
                            [   Lattice("TuanziSys",[Point(PID(1,1),(0.0,0.0)),Point(PID(1,2),(0.5,0.5))],neighbors=Dict(1=>√2/2)),
                                Lattice("TuanziEnv",[Point(PID(2,1),(-0.05,-0.05)),Point(PID(2,2),(0.55,0.55))],neighbors=Dict{Int,Float}()),
                                ],
                            vectors=[[1.0,0.0],[0.0,1.0]],
                            neighbors=Dict(1=>√2/2,-1=>√2/20)
                        )
    @test latticetype(lattice)==latticetype(typeof(lattice))==Lattice{2,PID{Int}}
    @test setdiff(bonds(lattice),bonds(lattice,zerothbonds,insidebonds,acrossbonds))|>length==0
    @test setdiff(bonds(lattice,insidebonds),bonds(lattice,intrabonds,interbonds))|>length==0
end

@testset "Cylinder" begin
    cylinder=Cylinder{PID{String}}("Tuanzi",[0.0 0.0; 0.0 1.0],SVector(1.0,0.0),vector=[0.0,2.0],neighbors=1)
    insert!(cylinder,"A","B")
    insert!(cylinder,"C3",cut=2,scopes=["C1","C1","C2","C2"])
    @test cylinder.pids==[PID("C1",1),PID("C3",2),PID("C3",1),PID("C1",2),PID("C2",1),PID("C2",2)]
    @test cylinder.rcoords==[-1.0 -1.0 0.0 0.0 1.0 1.0; 0.0 1.0 0.0 1.0 0.0 1.0]
    @test cylinder.icoords==[0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0]
    lattice=cylinder("C1","C2","C3")
    @test lattice.pids==[PID("C1",1),PID("C1",2),PID("C2",1),PID("C2",2),PID("C3",1),PID("C3",2)]
    @test lattice.rcoords==[-1.0 -1.0 0.0 0.0 1.0 1.0; 0.0 1.0 0.0 1.0 0.0 1.0]
    @test lattice.icoords==[0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0]
end

@testset "LatticeBonds" begin
    @test eltype(typeof(allbonds))===AbstractBond
    @test eltype(typeof(zerothbonds))===Point
    @test eltype(typeof(insidebonds))===eltype(typeof(acrossbonds))===Bond
    @test eltype(typeof(intrabonds))===eltype(typeof(interbonds))===Bond
    @test eltype(AbstractLattice{2,PID{Int}},allbonds)==eltype(AbstractLattice{2,PID{Int}},Val(allbonds))==AbstractBond{2,PID{Int}}
    @test eltype(Lattice{3,PID{Char}},zerothbonds)==eltype(Lattice{3,PID{Char}},Val(zerothbonds))==Point{3,PID{Char}}
    @test eltype(Lattice{1,PID{String}},insidebonds)==eltype(Lattice{1,PID{String}},Val(insidebonds))==Bond{1,PID{String}}

    @test expand(Lattice,Val((allbonds,)))==Lattice|>latticebondsstructure|>leaves|>Tuple
    @test expand(Lattice,Val((zerothbonds,)))==(zerothbonds,)
    @test expand(Lattice,Val((insidebonds,)))==(insidebonds,)
    @test expand(Lattice,Val((acrossbonds,)))==(acrossbonds,)

    @test expand(SuperLattice,Val((allbonds,)))==SuperLattice|>latticebondsstructure|>leaves|>Tuple
    @test expand(SuperLattice,Val((zerothbonds,)))==(zerothbonds,)
    @test expand(SuperLattice,Val((insidebonds,)))==(intrabonds,interbonds)
    @test expand(SuperLattice,Val((acrossbonds,)))==(acrossbonds,)
    @test expand(SuperLattice,Val((intrabonds,)))==(intrabonds,)
    @test expand(SuperLattice,Val((interbonds,)))==(interbonds,)
end

@testset "Bonds" begin
    lattice=Lattice("Tuanzi",[Point(PID(1,1),(0.5,0.5),(0.0,0.0))],vectors=[[1.0,0.0],[0.0,1.0]],neighbors=1)
    bs=Bonds(lattice)
    @test bs|>eltype==bs|>typeof|>eltype==AbstractBond{2,PID{Int}}
    @test bs==Bonds(lattice,allbonds) && isequal(bs,Bonds(lattice,allbonds))
    @test bs|>length==3 && bs|>size==(3,)
    @test summary(bs)=="3-element Bonds"
    @test bs|>bondtypes==bs|>typeof|>bondtypes==(zerothbonds,insidebonds,acrossbonds)
    @test bs|>latticetype==bs|>typeof|>latticetype==Lattice{2,PID{Int}}
    @test bs|>rank==bs|>typeof|>rank==3
    @test bs|>collect==bonds(lattice)
    @test bs[1]==bs.bonds[1][1] && bs[2]==bs.bonds[3][1] && bs[3]==bs.bonds[3][2]
    @test filter(allbonds,bs,:include|>Val)==filter((zerothbonds,insidebonds,acrossbonds),bs,:include|>Val)==bs
    @test filter(zerothbonds,bs,:include|>Val)==filter((insidebonds,acrossbonds),bs,:exclude|>Val)==Bonds(lattice,zerothbonds)
    @test filter(insidebonds,bs,:include|>Val)==filter((zerothbonds,acrossbonds),bs,:exclude|>Val)==Bonds(lattice,insidebonds)
    @test filter(acrossbonds,bs,:include|>Val)==filter((zerothbonds,insidebonds),bs,:exclude|>Val)==Bonds(lattice,acrossbonds)
    emptybs=Bonds{(zerothbonds,insidebonds,acrossbonds),Lattice{2,PID{Int}}}((Point{2,PID{Int}}[],Bond{2,PID{Int}}[],Bond{2,PID{Int}}[]))
    @test filter(bond->dimension(bond)==3,bs)==empty!(deepcopy(bs))==empty(bs)==emptybs
    @test reset!(emptybs,lattice)==bs
end


text:
## --- Fitting non-Gaussian distributions

    """
    ```Julia
    bilinear_exponential(x::Number, p::AbstractVector)
    ```
    Evaluate the value of a "bilinear exponential" function defined by the parameters
    `p` at point `x`. This function, which can be used to approximate various asymmetric
    probability distributions found in geochronology, is defined by an exponential
    function with two log-linear segments joined by an `atan` sigmoid:
    ```math
    ℯ^{p_1 + v x_s p_4^2 p_5^2 - (1-v) x_s p_4^2/p_5^2}
    ```
    where
    ```math
    v = 1/2 - atan(x_s)/π
    ```
    is a sigmoid, positive on the left-hand side, and
    ```math
    x_s = (x - p_2)/p_3^2
    ```
    is `x` scaled by mean and variance.

    The elements of the parameter array `p` may be considered to approximately represent\n
        p[1] # pre-exponential (log normaliation constant)
        p[2] # mean (central moment)
        p[3] # standard deviation
        p[4] # sharpness
        p[5] # skew
    """
    function bilinear_exponential(x::Number, p::AbstractVector)
        xs = (x - p[2])/abs2(p[3]) # X scaled by mean and variance
        v = 1/2 - atan(xs)/3.141592653589793 # Sigmoid (positive on LHS)
        shp = abs2(p[4])
        skw = abs2(p[5])
        return exp(p[1] + shp*skw*xs*v - shp/skw*xs*(1-v))
    end
    function bilinear_exponential(x::AbstractVector, p::AbstractVector)
        result = Array{float(eltype(x))}(undef,size(x))
        @turbo for i ∈ eachindex(x)
            xs = (x[i] - p[2])/abs2(p[3]) # X scaled by mean and variance
            v = 1/2 - atan(xs)/3.141592653589793 # Sigmoid (positive on LHS)
            shp = abs2(p[4])
            skw = abs2(p[5])
            result[i] = exp(p[1] + shp*skw*xs*v - shp/skw*xs*(1-v))
        end
        return result
    end

    """
    ```Julia
    bilinear_exponential_ll(x, p)
    ```
    Return the log likelihood corresponding to a `bilinear_exponential` distribution defined
    by the parameters `p` evaluate at point `x`.

    If `x` is provided as a number and `p` as a vector, a single evaluation will
    be returned; if `x` is provided as a vector and `p` as a matrix, the sum
    over all i for each distribution `p[:,i]` evaluated at `x[i]` will be returned
    instead.

    See also `bilinear_exponential`
    """
    function bilinear_exponential_ll(x::Number, p::AbstractVector)
        xs = (x - p[2])/abs2(p[3]) # X scaled by mean and variance
        v = 1/2 - atan(xs)/3.141592653589793 # Sigmoid (positive on LHS)
        shp = abs2(p[4])
        skw = abs2(p[5])
        return p[1] + shp*skw*xs*v - shp/skw*xs*(1-v)
    end
    function bilinear_exponential_ll(x::AbstractVector, p::AbstractMatrix)
        ll = 0.0
        @turbo for i ∈ eachindex(x)
            xs = (x[i]-p[2,i])/abs2(p[3,i]) # X scaled by mean and variance
            v = 1/2 - atan(xs)/3.141592653589793 # Sigmoid (positive on LHS)
            shp = abs2(p[4,i])
            skw = abs2(p[5,i])
            ll += p[1,i] + shp*skw*xs*v - shp/skw*xs*(1-v)
        end
        return ll
    end

    # Interpolate log likelihood from an array
    function interpolate_ll(x::AbstractVector,p::AbstractMatrix)
        ll = 0
        @inbounds for i = 1:length(x)
            ll += linterp_at_index(view(p,:,i), x[i], -Inf)
        end
        return ll
    end

## --- End of File


text:
include("../benchmark.jl")
include("create_report.jl")

overlapping_results = get_CUTEst_results()
#dual_inf_free_results = remove_errors(overlapping_results, [:dual_infeasible,:primal_infeasible])
#overlapping_opt_results = overlap(dual_inf_free_results)
#overlapping_opt_results = restrict_to_set(overlapping_opt_results,[:Optimal])
#overlapping_opt_results = overlap(overlapping_opt_results)

####
#### Lets do an overall summary of the results
####

# i.e. create Table 3 through 5.

# compute median number of iterations

##### Comparison on time to find a KKT point
#####
##### Lets take a look at the problems for which
##### - both solvers return a KKT point with the same objective
#####
#####

using PyPlot
PyPlot.close()
its, best, ratios, times = compute_its_etc(overlapping_results,MAX_IT=3000);
plot_iterations(its, best, ratios, 3000, line_styles, line_colors)
savefig("$folder/iter_curve.pdf")
PyPlot.close()

plot_iteration_ratios(its, best, ratios, line_styles, line_colors)
savefig("$folder/iter_ratios.pdf")
PyPlot.close()

res = all_status(overlapping_results, mode)
its, best, ratios, times = compute_its_etc(res,MAX_IT=3000);

println("number of overlapping results = ", length(res["IPOPT"]))

plot_iteration_ratios(its, best, ratios, line_styles, line_colors)
savefig("$folder/opt_iter_ratios.pdf")
PyPlot.close()

##
## PLOT TIME CURVES
##
best = best_its(times)

min_y = 1.0

ratios = Dict()
y_vals = collect(1:length(best)) / length(best)
for (method_name, val) in its
  ratios[method_name] = times[method_name] ./ best
  semilogx(sort(ratios[method_name]), y_vals, label=method_name, basex=2)
  min_y = min(min_y,sum(ratios[method_name] .== 1.0) / length(best))
end
ax = gca()
ax[:set_xlim]([1.0,2^8.0])
ax[:set_ylim]([min_y,1.0])

#ax[:xaxis][:ticker] = 0.5
#title("Comparsion on 45 CUTEst problems")
xlabel("times ratio to best solver")
ylabel("proportion of problems")

legend()


text:
include("Buffer.jl")
include("SumTree.jl")

import Random
import Base.getindex, Base.size

"""
AbstractExperienceReplay

    Abstract notion of an experience replay buffer for deep reinforcement learning.

"""
abstract type AbstractExperienceReplay end

size(er::AbstractExperienceReplay) = size(er.buffer)
getindex(er::AbstractExperienceReplay, idx) = getindex(er.buffer, idx)
add!(er::AbstractExperienceReplay, experience, args...) = add!(er.buffer, experience)

sample(er::AbstractExperienceReplay, batch_size; rng=Random.GLOBAL_RNG) = nothing

"""
ExperienceReplay
"""
mutable struct ExperienceReplay <: AbstractExperienceReplay
    """Experience Buffer"""
    buffer::CircularBuffer
    ExperienceReplay(size, types; column_names=nothing)= new(
        CircularBuffer(size, types; column_names = column_names))
end

size(er::ExperienceReplay) = size(er.buffer)
getindex(er::ExperienceReplay, idx) = getindex(er.buffer, idx)
add!(er::ExperienceReplay, experience, args...) = add!(er.buffer, experience)

"""
    sample(er, batch_size[; rng])

    Sample from the experience replay buffer a batch of size (batch_size) according to the random number generator (rng).

"""
function sample(er::ExperienceReplay, batch_size; rng=Random.GLOBAL_RNG)
    idx = rand(rng, 1:size(er)[1], batch_size)
    return getrow(er.buffer, idx)
end

"""
    WeightedExperienceReplay

    Samples according to generic weights passed in during experience addition.

"""
mutable struct WeightedExperienceReplay <: AbstractExperienceReplay
    """Experience Buffer"""
    buffer::CircularBuffer
    """managing the weights of the components"""
    sumtree::SumTree
    WeightedExperienceReplay(size, types; column_names=nothing)= new(
        CircularBuffer(size, types; column_names = column_names),
        SumTree{Int64}(size))
end

size(er::WeightedExperienceReplay) = size(er.buffer)
getindex(er::WeightedExperienceReplay, idx) = getindex(er.buffer, idx)
total(er::WeightedExperienceReplay) = total(er.sumtree)
add!(er::WeightedExperienceReplay, experience, args...) = add!(er, experience, args[1])
function add!(er::WeightedExperienceReplay, experience, weight, args...)
    idx = add!(er.buffer, experience)
    add!(er.sumtree, weight, idx)
    return
end

function sample(er::WeightedExperienceReplay, batch_size; rng=Random.GLOBAL_RNG)
    batch_idx, batch_priorities, idx = sample(er.sumtree, batch_size; rng=rng)
    return getrow(er.buffer, idx)
end


text:
using Ft2k, DelimitedFiles, Statistics

lsc = readdlm("/home/ubuntu/.ft2k/data/lifespancohort_feeders_all.csv", ',', String)

# filter to last 24 hours
nowtime  = now(Dates.UTC) - Hour(7)
todayfeedings= Dict()
for (k,v) in fdict
    todayfeedings[k] = filter(p -> p[5] == Date(nowtime), v)
end

x = filter((k,v) -> in(k, lsc), todayfeedings)

# these are somehow not showing up in fdict but should, all starting with 0...
missingids = setdiff(lsc, collect(keys(x)))

# have not yet fed
notfed = filter((k,v) -> length(v) < 1, x)

# remove these from dict
x = filter((k,v) -> !haskey(notfed, k), x)

# creating sorted list of ids with corresponding low diffs
y = []
for (k,v) in x
    push!(y, (mean(map(p -> p[3] - p[2], v)),k))
end
sort(y)


text:
@testset "filter by sample/record index" begin
    # filter samples only specified via integer indices
    vcffile = "test.08Jun17.d8b.vcf.gz"
    samples = nsamples(vcffile)
    records = nrecords(vcffile)
    record_mask = collect(1:records)
    sample_mask = collect(2:(samples - 1))
    des = "filtered.test.08Jun17.d8b.vcf.gz"
    @time VCFTools.filter(vcffile, record_mask, sample_mask, des=des)
    # @code_warntype VCFTools.filter(vcffile, record_mask, sample_mask, des=des)
    @test nsamples(des) == samples - 2
    @test nrecords(des) == records
    X = convert_gt(Float32, vcffile)
    X_filter = convert_gt(Float32, des)
    @test all(X[sample_mask, :] .== X_filter)

    # filter records only specified by bitmasks
    record_mask = trues(records)
    sample_mask = trues(samples)
    record_mask[1] = record_mask[end] = false
    des = "filtered.test.08Jun17.d8b.vcf.gz"
    @time VCFTools.filter(vcffile, record_mask, sample_mask, des=des)
    @test nsamples(des) == samples
    @test nrecords(des) == records - 2
    X = convert_gt(Float32, vcffile)
    X_filter = convert_gt(Float32, des)
    @test all(X[:, record_mask] .== X_filter)

    # filter record and samples together
    record_mask = trues(records)
    sample_mask = trues(samples)
    record_mask[1] = record_mask[end] = false
    sample_mask[1] = sample_mask[end] = false
    des = "filtered.test.08Jun17.d8b.vcf.gz"
    @time VCFTools.filter(vcffile, record_mask, sample_mask, des=des)
    @test nsamples(des) == sum(sample_mask)
    @test nrecords(des) == sum(record_mask)
    X = convert_gt(Float32, vcffile)
    X_filter = convert_gt(Float32, des)
    @test all(X[sample_mask, record_mask] .== X_filter)
end

@testset "mask_gt" begin
    vcffile = "test.08Jun17.d8b.vcf.gz"
    outfile = "masked.test.08Jun17.d8b.vcf.gz"
    samples = nsamples(vcffile)
    records = nrecords(vcffile)
    masks   = falses(records, samples)
    [masks[i, i] = true for i in 1:10]
    @time mask_gt(vcffile, masks, des = outfile)
    # @code_warntype mask_gt(vcffile, masks, des = outfile)
    @test nsamples(outfile) == samples
    @test nrecords(outfile) == records
    X = convert_gt(Float32, vcffile)
    X = copy(X') # need to transpose back to dimension in VCF file
    Xmasked = convert_gt(Float32, outfile)
    Xmasked = copy(Xmasked')
    @test eltype(Xmasked) == Union{Missing, eltype(X)}
    @test all(Xmasked[.!masks] .== X[.!masks])
    @test all(Xmasked[masks] .=== missing)
end

@testset "filter_chr" begin
    vcffile = "test.08Jun17.d8b.vcf.gz"
    outfile = "filtered.chr22.test.08Jun17.d8b.vcf.gz"
    @test filter_chr(vcffile, 22) == 1356
    @test nrecords(outfile) == 1356

    outfile2 = "filtered.chr22:20000000-20020000.test.08Jun17.d8b.vcf.gz"
    @test filter_range("test.08Jun17.d8b.vcf.gz", "22", 20000000, 20020000) == 261
    @test nrecords(outfile2) == 261
end


text:
import .Makie
const GB = Makie.GLMakie.GeometryBasics

get_transform(x::Int) = pos -> CartesianIndex(pos[2], x - pos[1] + 1)
get_center(pos, tile_size, transform) = (transform(pos).I .- (0.5,0.5)) .* reverse(tile_size)
get_box(pos, tile_size, transform) = Makie.FRect2D((transform(pos).I .- (1,1)) .* reverse(tile_size), reverse(tile_size))

get_markersize(object::AbstractObject, tile_size) = reverse(tile_size)

function init_screen(env_node::Makie.Observable{E}; resolution = (720, 720)) where {E<:AbstractGridWorld}
    scene = Makie.Scene(resolution = resolution, raw = true, camera = Makie.campixel!)

    height = get_height(env_node[])
    width = get_width(env_node[])
    tile_inds = CartesianIndices((height, width))

    transform = get_transform(height)

    area = scene.px_area
    tile_size = (GB.widths(area[])[2] / height, GB.widths(area[])[1] / width)

    # 1. paint background
    Makie.poly!(scene, area)

    empty_tiles_node = Makie.lift(env_node) do env
        empty_tiles = filter(pos -> !any(get_world(env)[:, pos]), tile_inds)
        return map(x -> get_center(x, tile_size, transform), empty_tiles)
    end
    Makie.scatter!(scene, empty_tiles_node, color = :white, marker = '.')

    # 2. paint each kind of object
    for object in reverse(get_objects(env_node[]))
        if object === AGENT && hasfield(E, :agent_dir)
            object_node = Makie.lift(env_node) do env
                positions = findall(get_world(env)[object, :, :])
                return broadcast(x -> get_center(x, tile_size, transform), positions)
            end
            agent_char = Makie.lift(env_node) do env
                return get_char(object, get_agent_dir(env))
            end
            Makie.scatter!(scene, object_node, color = get_color(object), marker = agent_char, markersize = get_markersize(object, tile_size))
        else
            object_node = Makie.lift(env_node) do env
                positions = findall(get_world(env)[object, :, :])
                return broadcast(x -> get_center(x, tile_size, transform), positions)
            end
            Makie.scatter!(scene, object_node, color = get_color(object), marker = get_char(object), markersize = get_markersize(object, tile_size))
        end
    end

    # 3. paint agent's view
    if isa(RLBase.StateStyle(env_node[]), RLBase.Observation) && !(isa(env_node[], Snake))
        if hasfield(E, :agent_dir)
            view_boxes_node = Makie.lift(env_node) do env
                positions = filter(pos -> pos in tile_inds, get_grid_inds(get_agent_pos(env).I, get_half_size(env), get_agent_dir(env)))
                return map(pos -> get_box(pos, tile_size, transform), positions)
            end
            Makie.poly!(scene, view_boxes_node, color = "rgba(255,255,255,0.3)")
        else
            view_boxes_node = Makie.lift(env_node) do env
                positions = filter(pos -> pos in tile_inds, get_grid_inds(get_agent_pos(env).I, get_half_size(env)))
                return map(pos -> get_box(pos, tile_size, transform), positions)
            end
            Makie.poly!(scene, view_boxes_node, color = "rgba(255,255,255,0.3)")
        end
    end

    return scene
end

function play(env::AbstractGridWorld;file_name=nothing,frame_rate=24)
    print("""
    Key bindings:
    ←: TurnLeft
    →: TurnRight
    ↑: MoveForward
    w: MoveUp
    s: MoveDown
    a: MoveLeft
    d: MoveRight
    n: NoMove
    p: PickUp
    o: Drop
    r: reset!
    q: Quit
    """)
    env_node = Makie.Node(env)
    scene = init_screen(env_node)
    Makie.display(scene)
    is_quit = Ref(false)

    if !isnothing(file_name)
        vs = Makie.VideoStream(scene)
        Makie.recordframe!(vs)
    end

    Makie.on(scene.events.keyboardbuttons) do b
        if Makie.ispressed(b, Makie.Keyboard.left)
            env(TURN_LEFT)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.right)
            env(TURN_RIGHT)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.up)
            env(MOVE_FORWARD)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.w)
            env(MOVE_UP)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.s)
            env(MOVE_DOWN)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.a)
            env(MOVE_LEFT)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.d)
            env(MOVE_RIGHT)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.n)
            env(NO_MOVE)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.p)
            env(PICK_UP)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.o)
            env(DROP)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.r)
            RLBase.reset!(env)
            env_node[] = env
        elseif Makie.ispressed(b, Makie.Keyboard.q)
            is_quit[] = true
        end
        @show b
        @show RLBase.reward(env)
        @show RLBase.is_terminated(env)
        isnothing(file_name) || Makie.recordframe!(vs)
    end

    try
        while !is_quit[]
            sleep(0.5)
        end
    catch
    end
    isnothing(file_name) || Makie.save(file_name, vs;framerate=frame_rate)
    Makie.GLMakie.destroy!(Makie.GLMakie.global_gl_screen())
end


text:
# Common stuff
## convenient types and type conversion functions

typealias GChars Union{Cchar, Char}
typealias IVec Vector{Cint}
typealias FVec Vector{Float64}
typealias CVec Vector{Cchar}

typealias GCharOrVec Union{Cchar, Char, Vector{Cchar}, Vector{Char}}

typealias Bounds{T<:Real} Union{T, Vector{T}}
typealias CoeffMat Union{Matrix{Float64}, SparseMatrixCSC{Float64}}

cchar(c::Cchar) = c
cchar(c::Char) = convert(Cchar, c)

ivec(v::IVec) = v
fvec(v::FVec) = v
cvec(v::CVec) = v

ivec(v::Vector) = convert(IVec, v)
fvec(v::Vector) = convert(FVec, v)
cvec(v::Vector) = convert(CVec, v)

ivec(v::Int) = Cint[v]
fvec(v::Float64) = Float64[v]
#cvec(v::Vector) = convert(CVec, v)

# cvecx(v, n) and fvecx(v, n)
# converts v into a vector of Cchar or Float64 of length n,
# where v can be either a scalar or a vector of length n.

_chklen(v, n::Integer) = (length(v) == n || error("Inconsistent argument dimensions."))

cvecx(c::GChars, n::Integer) = fill(cchar(c), n)
cvecx(c::Vector{Cchar}, n::Integer) = (_chklen(c, n); c)
cvecx(c::Vector{Char}, n::Integer) = (_chklen(c, n); convert(Vector{Cchar}, c))

fvecx(v::Real, n::Integer) = fill(Float64(v), n)
fvecx(v::Vector{Float64}, n::Integer) = (_chklen(v, n); v)
fvecx{T<:Real}(v::Vector{T}, n::Integer) = (_chklen(v, n); convert(Vector{Float64}, v))

# empty vector & matrix (for the purpose of supplying default arguments)

const emptyfvec = Array(Float64, 0)
const emptyfmat = Array(Float64, 0, 0)

# macro to call a Xpress C functions
macro xprs_ccall(func, args...)
    f = "XPRS$(func)"

    is_unix() && return quote
        ccall(($f,xprs), $(args...))
    end
    is_windows() && return quote
        ccall(($f,xprs), stdcall, $(args...))
    end
end

# Xpress library version
function getlibversion()
    out = Array(Cchar, 16)                                     # "                "
    ret = @xprs_ccall(getversion, Cint, ( Ptr{Cchar},), out)   # ( Cstring,), out)

    numbers = split(unsafe_string(pointer(out)) ,".")

    _major = parse(Int,numbers[1])
    _minor = parse(Int,numbers[2])
    _tech  = parse(Int,numbers[3])

    return  VersionNumber(_major, _minor, _tech)
end

# version need not be export
# one can write Xpress.version to get the version numbers
const version = getlibversion()


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

@test integrate(x^4*(a+b*arcsin(c*x))*(d+e*x^2), x) == :(1//5*d*x^5*(a+b*arcsin(c*x))+1//7*e*x^7*(a+b*arcsin(c*x))+-1//49*b*e*c^-7*(1+-1*c^2*x^2)^7//2+-1//105*b*c^-7*(1+-1*c^2*x^2)^3//2*(15*e+14*d*c^2)+1//35*b*c^-7*(1+-1*c^2*x^2)^(1/2)*(5*e+7*d*c^2)+1//175*b*c^-7*(1+-1*c^2*x^2)^5//2*(15*e+7*d*c^2))
@test integrate(x^3*(a+b*arcsin(c*x))*(d+e*x^2), x) == :(1//4*d*x^4*(a+b*arcsin(c*x))+1//6*e*x^6*(a+b*arcsin(c*x))+-1//96*b*c^-6*(5*e+9*d*c^2)*arcsin(c*x)+1//36*b*e*c^-1*x^5*(1+-1*c^2*x^2)^(1/2)+1//96*b*x*c^-5*(1+-1*c^2*x^2)^(1/2)*(5*e+9*d*c^2)+1//144*b*c^-3*x^3*(1+-1*c^2*x^2)^(1/2)*(5*e+9*d*c^2))
@test integrate(x^2*(a+b*arcsin(c*x))*(d+e*x^2), x) == :(1//3*d*x^3*(a+b*arcsin(c*x))+1//5*e*x^5*(a+b*arcsin(c*x))+-1//45*b*c^-5*(1+-1*c^2*x^2)^3//2*(6*e+5*d*c^2)+1//15*b*c^-5*(1+-1*c^2*x^2)^(1/2)*(3*e+5*d*c^2)+1//25*b*e*c^-5*(1+-1*c^2*x^2)^5//2)
@test integrate(x*(a+b*arcsin(c*x))*(d+e*x^2), x) == :(1//4*e^-1*(d+e*x^2)^2*(a+b*arcsin(c*x))+-1//32*b*c^-4*e^-1*(3*e^2+8*c^4*d^2+8*d*e*c^2)*arcsin(c*x)+1//16*b*x*c^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)+3//32*b*x*c^-3*(1+-1*c^2*x^2)^(1/2)*(e+2*d*c^2))
@test integrate((a+b*arcsin(c*x))*(d+e*x^2), x) == :(d*x*(a+b*arcsin(c*x))+1//3*e*x^3*(a+b*arcsin(c*x))+-1//9*b*e*c^-3*(1+-1*c^2*x^2)^3//2+1//3*b*c^-3*(1+-1*c^2*x^2)^(1/2)*(e+3*d*c^2))
@test integrate(x^-1*(a+b*arcsin(c*x))*(d+e*x^2), x) == :(d*(a+b*arcsin(c*x))*log(x)+(1/2)*e*x^2*(a+b*arcsin(c*x))+b*d*arcsin(c*x)*log(1+-1*exp(2*im*arcsin(c*x)))+-1*b*d*arcsin(c*x)*log(x)+-1//2*im*b*d*arcsin(c*x)^2+-1//2*im*b*d*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-1//4*b*e*c^-2*arcsin(c*x)+1//4*b*e*x*c^-1*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^-2*(a+b*arcsin(c*x))*(d+e*x^2), x) == :(e*x*(a+b*arcsin(c*x))+-1*d*x^-1*(a+b*arcsin(c*x))+b*e*c^-1*(1+-1*c^2*x^2)^(1/2)+-1*b*c*d*arctanh((1+-1*c^2*x^2)^(1/2)))
@test integrate(x^-3*(a+b*arcsin(c*x))*(d+e*x^2), x) == :(e*(a+b*arcsin(c*x))*log(x)+-1//2*d*x^-2*(a+b*arcsin(c*x))+b*e*arcsin(c*x)*log(1+-1*exp(2*im*arcsin(c*x)))+-1*b*e*arcsin(c*x)*log(x)+-1//2*im*b*e*arcsin(c*x)^2+-1//2*im*b*e*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-1//2*b*c*d*x^-1*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^-4*(a+b*arcsin(c*x))*(d+e*x^2), x) == :(-1*e*x^-1*(a+b*arcsin(c*x))+-1//3*d*x^-3*(a+b*arcsin(c*x))+-1//6*b*c*(6*e+d*c^2)*arctanh((1+-1*c^2*x^2)^(1/2))+-1//6*b*c*d*x^-2*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^4*(d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :(1//5*d^2*x^5*(a+b*arcsin(c*x))+1//9*e^2*x^9*(a+b*arcsin(c*x))+-2//945*b*c^-9*(1+-1*c^2*x^2)^3//2*(70*e^2+63*c^4*d^2+135*d*e*c^2)+1//81*b*c^-9*e^2*(1+-1*c^2*x^2)^9//2+1//315*b*c^-9*(1+-1*c^2*x^2)^(1/2)*(35*e^2+63*c^4*d^2+90*d*e*c^2)+1//525*b*c^-9*(1+-1*c^2*x^2)^5//2*(70*e^2+21*c^4*d^2+90*d*e*c^2)+2//7*d*e*x^7*(a+b*arcsin(c*x))+-2//441*b*e*c^-9*(1+-1*c^2*x^2)^7//2*(14*e+9*d*c^2))
@test integrate(x^3*(d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :(1//4*d^2*x^4*(a+b*arcsin(c*x))+1//8*e^2*x^8*(a+b*arcsin(c*x))+-1//3072*b*c^-8*(105*e^2+288*c^4*d^2+320*d*e*c^2)*arcsin(c*x)+1//3*d*e*x^6*(a+b*arcsin(c*x))+1//64*b*c^-1*e^2*x^7*(1+-1*c^2*x^2)^(1/2)+1//3072*b*x*c^-7*(1+-1*c^2*x^2)^(1/2)*(105*e^2+288*c^4*d^2+320*d*e*c^2)+1//4608*b*c^-5*x^3*(1+-1*c^2*x^2)^(1/2)*(105*e^2+288*c^4*d^2+320*d*e*c^2)+1//1152*b*e*c^-3*x^5*(1+-1*c^2*x^2)^(1/2)*(21*e+64*d*c^2))
@test integrate(x^2*(d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :(1//3*d^2*x^3*(a+b*arcsin(c*x))+1//7*e^2*x^7*(a+b*arcsin(c*x))+-1//49*b*c^-7*e^2*(1+-1*c^2*x^2)^7//2+-1//315*b*c^-7*(1+-1*c^2*x^2)^3//2*(45*e^2+35*c^4*d^2+84*d*e*c^2)+1//105*b*c^-7*(1+-1*c^2*x^2)^(1/2)*(15*e^2+35*c^4*d^2+42*d*e*c^2)+2//5*d*e*x^5*(a+b*arcsin(c*x))+1//175*b*e*c^-7*(1+-1*c^2*x^2)^5//2*(15*e+14*d*c^2))
@test integrate(x*(d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :(1//6*e^-1*(d+e*x^2)^3*(a+b*arcsin(c*x))+1//36*b*x*c^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^2+1//288*b*x*c^-5*(1+-1*c^2*x^2)^(1/2)*(15*e^2+44*c^4*d^2+44*d*e*c^2)+-1//96*b*c^-6*e^-1*(e+2*d*c^2)*(5*e^2+8*c^4*d^2+8*d*e*c^2)*arcsin(c*x)+5//144*b*x*c^-3*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)*(e+2*d*c^2))
@test integrate((d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :(x*d^2*(a+b*arcsin(c*x))+1//5*e^2*x^5*(a+b*arcsin(c*x))+1//15*b*c^-5*(1+-1*c^2*x^2)^(1/2)*(3*e^2+15*c^4*d^2+10*d*e*c^2)+1//25*b*c^-5*e^2*(1+-1*c^2*x^2)^5//2+2//3*d*e*x^3*(a+b*arcsin(c*x))+-2//45*b*e*c^-5*(1+-1*c^2*x^2)^3//2*(3*e+5*d*c^2))
@test integrate(x^-1*(d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :(d^2*(a+b*arcsin(c*x))*log(x)+1//4*e^2*x^4*(a+b*arcsin(c*x))+b*d^2*arcsin(c*x)*log(1+-1*exp(2*im*arcsin(c*x)))+d*e*x^2*(a+b*arcsin(c*x))+-1*b*d^2*arcsin(c*x)*log(x)+-3//32*b*c^-4*e^2*arcsin(c*x)+-1//2*im*b*d^2*arcsin(c*x)^2+-1//2*im*b*d^2*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-1//2*b*d*e*c^-2*arcsin(c*x)+1//16*b*c^-1*e^2*x^3*(1+-1*c^2*x^2)^(1/2)+3//32*b*x*c^-3*e^2*(1+-1*c^2*x^2)^(1/2)+(1/2)*b*d*e*x*c^-1*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^-2*(d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :(-1*d^2*x^-1*(a+b*arcsin(c*x))+1//3*e^2*x^3*(a+b*arcsin(c*x))+-1*b*c*d^2*arctanh((1+-1*c^2*x^2)^(1/2))+2*d*e*x*(a+b*arcsin(c*x))+-1//9*b*c^-3*e^2*(1+-1*c^2*x^2)^3//2+1//3*b*e*c^-3*(1+-1*c^2*x^2)^(1/2)*(e+6*d*c^2))
@test integrate(x^-3*(d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :((1/2)*e^2*x^2*(a+b*arcsin(c*x))+-1//2*d^2*x^-2*(a+b*arcsin(c*x))+2*d*e*(a+b*arcsin(c*x))*log(x)+-1//4*b*c^-2*e^2*arcsin(c*x)+-1*im*b*d*e*arcsin(c*x)^2+-1*im*b*d*e*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-2*b*d*e*arcsin(c*x)*log(x)+2*b*d*e*arcsin(c*x)*log(1+-1*exp(2*im*arcsin(c*x)))+-1//2*b*c*d^2*x^-1*(1+-1*c^2*x^2)^(1/2)+1//4*b*x*c^-1*e^2*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^-4*(d+e*x^2)^2*(a+b*arcsin(c*x)), x) == :(x*e^2*(a+b*arcsin(c*x))+-1//3*d^2*x^-3*(a+b*arcsin(c*x))+b*c^-1*e^2*(1+-1*c^2*x^2)^(1/2)+-2*d*e*x^-1*(a+b*arcsin(c*x))+-1//6*b*c*d*(12*e+d*c^2)*arctanh((1+-1*c^2*x^2)^(1/2))+-1//6*b*c*d^2*x^-2*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^4*(d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(1//5*d^3*x^5*(a+b*arcsin(c*x))+1//11*e^3*x^11*(a+b*arcsin(c*x))+-1//121*b*c^-11*e^3*(1+-1*c^2*x^2)^11//2+-1//3465*b*c^-11*(1+-1*c^2*x^2)^3//2*(525*e^3+462*c^6*d^3+1485*e*c^4*d^2+1540*d*c^2*e^2)+1//3*d*e^2*x^9*(a+b*arcsin(c*x))+1//1155*b*c^-11*(1+-1*c^2*x^2)^(1/2)*(105*e^3+231*c^6*d^3+385*d*c^2*e^2+495*e*c^4*d^2)+1//1925*b*c^-11*(1+-1*c^2*x^2)^5//2*(350*e^3+77*c^6*d^3+495*e*c^4*d^2+770*d*c^2*e^2)+3//7*e*d^2*x^7*(a+b*arcsin(c*x))+-1//1617*b*e*c^-11*(1+-1*c^2*x^2)^7//2*(210*e^2+99*c^4*d^2+308*d*e*c^2)+1//297*b*c^-11*e^2*(1+-1*c^2*x^2)^9//2*(15*e+11*d*c^2))
@test integrate(x^3*(d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(1//10*e^-2*(d+e*x^2)^5*(a+b*arcsin(c*x))+-1//8*d*e^-2*(d+e*x^2)^4*(a+b*arcsin(c*x))+1//5120*b*c^-10*e^-2*(-126*e^5+128*c^10*d^5+-800*c^4*d^2*e^3+-525*d*c^2*e^4+-480*c^6*d^3*e^2)*arcsin(c*x)+-1//76800*b*x*c^-9*e^-1*(1+-1*c^2*x^2)^(1/2)*(-1890*e^4+1232*c^8*d^4+-7758*c^4*d^2*e^2+-6615*d*c^2*e^3+-2536*e*c^6*d^3)+1//100*b*x*c^-1*e^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^4+-1//38400*b*x*c^-7*e^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)*(-630*e^3+136*c^6*d^3+-1617*d*c^2*e^2+-1096*e*c^4*d^2)+1//1600*b*x*c^-3*e^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3*(18*e+11*d*c^2)+1//9600*b*x*c^-5*e^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^2*(126*e^2+26*c^4*d^2+201*d*e*c^2))
@test integrate(x^2*(d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(1//3*d^3*x^3*(a+b*arcsin(c*x))+1//9*e^3*x^9*(a+b*arcsin(c*x))+-1//945*b*c^-9*(1+-1*c^2*x^2)^3//2*(140*e^3+105*c^6*d^3+378*e*c^4*d^2+405*d*c^2*e^2)+1//81*b*c^-9*e^3*(1+-1*c^2*x^2)^9//2+1//315*b*c^-9*(1+-1*c^2*x^2)^(1/2)*(35*e^3+105*c^6*d^3+135*d*c^2*e^2+189*e*c^4*d^2)+3//5*e*d^2*x^5*(a+b*arcsin(c*x))+3//7*d*e^2*x^7*(a+b*arcsin(c*x))+-1//441*b*c^-9*e^2*(1+-1*c^2*x^2)^7//2*(28*e+27*d*c^2)+1//525*b*e*c^-9*(1+-1*c^2*x^2)^5//2*(70*e^2+63*c^4*d^2+135*d*e*c^2))
@test integrate(x*(d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(1//8*e^-1*(d+e*x^2)^4*(a+b*arcsin(c*x))+-1//1024*b*c^-8*e^-1*(35*e^4+128*c^8*d^4+160*d*c^2*e^3+256*e*c^6*d^3+288*c^4*d^2*e^2)*arcsin(c*x)+1//64*b*x*c^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3+1//1536*b*x*c^-5*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)*(35*e^2+104*c^4*d^2+104*d*e*c^2)+5//3072*b*x*c^-7*(1+-1*c^2*x^2)^(1/2)*(e+2*d*c^2)*(21*e^2+40*c^4*d^2+40*d*e*c^2)+7//384*b*x*c^-3*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^2*(e+2*d*c^2))
@test integrate((d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(x*d^3*(a+b*arcsin(c*x))+1//7*e^3*x^7*(a+b*arcsin(c*x))+e*d^2*x^3*(a+b*arcsin(c*x))+-1//49*b*c^-7*e^3*(1+-1*c^2*x^2)^7//2+1//35*b*c^-7*(1+-1*c^2*x^2)^(1/2)*(5*e^3+35*c^6*d^3+21*d*c^2*e^2+35*e*c^4*d^2)+3//5*d*e^2*x^5*(a+b*arcsin(c*x))+-1//105*b*e*c^-7*(1+-1*c^2*x^2)^3//2*(15*e^2+35*c^4*d^2+42*d*e*c^2)+3//175*b*c^-7*e^2*(1+-1*c^2*x^2)^5//2*(5*e+7*d*c^2))
@test integrate(x^-1*(d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(d^3*(a+b*arcsin(c*x))*log(x)+1//6*e^3*x^6*(a+b*arcsin(c*x))+b*d^3*arcsin(c*x)*log(1+-1*exp(2*im*arcsin(c*x)))+-1*b*d^3*arcsin(c*x)*log(x)+-5//96*b*c^-6*e^3*arcsin(c*x)+-1//2*im*b*d^3*arcsin(c*x)^2+-1//2*im*b*d^3*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+3//2*e*d^2*x^2*(a+b*arcsin(c*x))+3//4*d*e^2*x^4*(a+b*arcsin(c*x))+-9//32*b*d*c^-4*e^2*arcsin(c*x)+-3//4*b*e*c^-2*d^2*arcsin(c*x)+1//36*b*c^-1*e^3*x^5*(1+-1*c^2*x^2)^(1/2)+5//96*b*x*c^-5*e^3*(1+-1*c^2*x^2)^(1/2)+5//144*b*c^-3*e^3*x^3*(1+-1*c^2*x^2)^(1/2)+3//4*b*e*x*c^-1*d^2*(1+-1*c^2*x^2)^(1/2)+3//16*b*d*c^-1*e^2*x^3*(1+-1*c^2*x^2)^(1/2)+9//32*b*d*x*c^-3*e^2*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^-2*(d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(-1*d^3*x^-1*(a+b*arcsin(c*x))+1//5*e^3*x^5*(a+b*arcsin(c*x))+d*e^2*x^3*(a+b*arcsin(c*x))+-1*b*c*d^3*arctanh((1+-1*c^2*x^2)^(1/2))+3*e*x*d^2*(a+b*arcsin(c*x))+1//25*b*c^-5*e^3*(1+-1*c^2*x^2)^5//2+-1//15*b*c^-5*e^2*(1+-1*c^2*x^2)^3//2*(2*e+5*d*c^2)+1//5*b*e*c^-5*(1+-1*c^2*x^2)^(1/2)*(e^2+15*c^4*d^2+5*d*e*c^2))
@test integrate(x^-3*(d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(-1//2*d^3*x^-2*(a+b*arcsin(c*x))+1//4*e^3*x^4*(a+b*arcsin(c*x))+3*e*d^2*(a+b*arcsin(c*x))*log(x)+3//2*d*e^2*x^2*(a+b*arcsin(c*x))+-3*b*e*d^2*arcsin(c*x)*log(x)+3*b*e*d^2*arcsin(c*x)*log(1+-1*exp(2*im*arcsin(c*x)))+-3//2*im*b*e*d^2*arcsin(c*x)^2+-3//2*im*b*e*d^2*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-3//32*b*c^-4*e^2*(e+8*d*c^2)*arcsin(c*x)+-1//2*b*c*d^3*x^-1*(1+-1*c^2*x^2)^(1/2)+1//16*b*c^-1*e^3*x^3*(1+-1*c^2*x^2)^(1/2)+3//32*b*x*c^-3*e^2*(1+-1*c^2*x^2)^(1/2)*(e+8*d*c^2))
@test integrate(x^-4*(d+e*x^2)^3*(a+b*arcsin(c*x)), x) == :(-1//3*d^3*x^-3*(a+b*arcsin(c*x))+1//3*e^3*x^3*(a+b*arcsin(c*x))+-3*e*d^2*x^-1*(a+b*arcsin(c*x))+3*d*x*e^2*(a+b*arcsin(c*x))+-1//9*b*c^-3*e^3*(1+-1*c^2*x^2)^3//2+-1//6*b*c*d^2*(18*e+d*c^2)*arctanh((1+-1*c^2*x^2)^(1/2))+-1//6*b*c*d^3*x^-2*(1+-1*c^2*x^2)^(1/2)+1//3*b*c^-3*e^2*(1+-1*c^2*x^2)^(1/2)*(e+9*d*c^2))
@test integrate((d+e*x^2)^4*(a+b*arcsin(c*x)), x) == :(x*d^4*(a+b*arcsin(c*x))+1//9*e^4*x^9*(a+b*arcsin(c*x))+1//81*b*c^-9*e^4*(1+-1*c^2*x^2)^9//2+1//315*b*c^-9*(1+-1*c^2*x^2)^(1/2)*(35*e^4+315*c^8*d^4+180*d*c^2*e^3+378*c^4*d^2*e^2+420*e*c^6*d^3)+4//3*e*d^3*x^3*(a+b*arcsin(c*x))+4//7*d*e^3*x^7*(a+b*arcsin(c*x))+6//5*d^2*e^2*x^5*(a+b*arcsin(c*x))+-4//441*b*c^-9*e^3*(1+-1*c^2*x^2)^7//2*(7*e+9*d*c^2)+-4//945*b*e*c^-9*(1+-1*c^2*x^2)^3//2*(35*e^3+105*c^6*d^3+135*d*c^2*e^2+189*e*c^4*d^2)+2//525*b*c^-9*e^2*(1+-1*c^2*x^2)^5//2*(35*e^2+63*c^4*d^2+90*d*e*c^2))
@test integrate(x^4*(d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :(1//3*e^-1*x^3*(a+b*arcsin(c*x))+(1/2)*e^-5//2*(-1d)^3//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-5//2*(-1d)^3//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*a*d*x*e^-2+-1//2*e^-5//2*(-1d)^3//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^-5//2*(-1d)^3//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//9*b*c^-3*e^-1*(1+-1*c^2*x^2)^3//2+1//3*b*c^-3*e^-1*(1+-1*c^2*x^2)^(1/2)+(1/2)*im*b*e^-5//2*(-1d)^3//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*e^-5//2*(-1d)^3//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*b*d*x*e^-2*arcsin(c*x)+-1*b*d*c^-1*e^-2*(1+-1*c^2*x^2)^(1/2)+-1//2*im*b*e^-5//2*(-1d)^3//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-5//2*(-1d)^3//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x))))
@test integrate(x^3*(d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :((1/2)*e^-1*x^2*(a+b*arcsin(c*x))+-1//2*d*e^-2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d*e^-2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d*e^-2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d*e^-2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*b*c^-2*e^-1*arcsin(c*x)+(1/2)*im*b*d*e^-2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d*e^-2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d*e^-2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d*e^-2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*d*b^-1*e^-2*(a+b*arcsin(c*x))^2+1//4*b*x*c^-1*e^-1*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^2*(d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :(a*x*e^-1+b*x*e^-1*arcsin(c*x)+b*c^-1*e^-1*(1+-1*c^2*x^2)^(1/2)+(1/2)*e^-3//2*(-1d)^(1/2)*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-3//2*(-1d)^(1/2)*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^-3//2*(-1d)^(1/2)*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^-3//2*(-1d)^(1/2)*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*e^-3//2*(-1d)^(1/2)*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*e^-3//2*(-1d)^(1/2)*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-3//2*(-1d)^(1/2)*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-3//2*(-1d)^(1/2)*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x))))
@test integrate(x*(d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :((1/2)*e^-1*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-1*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-1*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-1*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-1*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-1*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-1*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-1*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b^-1*e^-1*(a+b*arcsin(c*x))^2)
@test integrate((d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :((1/2)*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x))))
@test integrate(x^-1*(d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :(d^-1*(a+b*arcsin(c*x))*log(1+-1*exp(2*im*arcsin(c*x)))+-1//2*d^-1*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-1*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-1*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-1*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-1*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-1*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-1*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-1*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*d^-1*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x))))
@test integrate(x^-2*(d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :(-1*d^-1*x^-1*(a+b*arcsin(c*x))+(1/2)*e^(1/2)*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^(1/2)*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*b*c*d^-1*arctanh((1+-1*c^2*x^2)^(1/2))+-1//2*e^(1/2)*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^(1/2)*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*e^(1/2)*(-1d)^-3//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*e^(1/2)*(-1d)^-3//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^(1/2)*(-1d)^-3//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^(1/2)*(-1d)^-3//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x))))
@test integrate(x^-3*(d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :(-1//2*d^-1*x^-2*(a+b*arcsin(c*x))+(1/2)*e*d^-2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e*d^-2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e*d^-2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e*d^-2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*e*d^-2*(a+b*arcsin(c*x))*log(1+-1*exp(2*im*arcsin(c*x)))+(1/2)*im*b*e*d^-2*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-1//2*im*b*e*d^-2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e*d^-2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e*d^-2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e*d^-2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*b*c*d^-1*x^-1*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^-4*(d+e*x^2)^-1*(a+b*arcsin(c*x)), x) == :(-1//3*d^-1*x^-3*(a+b*arcsin(c*x))+e*d^-2*x^-1*(a+b*arcsin(c*x))+(1/2)*e^3//2*(-1d)^-5//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^3//2*(-1d)^-5//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^3//2*(-1d)^-5//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^3//2*(-1d)^-5//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//6*b*c^3*d^-1*arctanh((1+-1*c^2*x^2)^(1/2))+b*c*e*d^-2*arctanh((1+-1*c^2*x^2)^(1/2))+(1/2)*im*b*e^3//2*(-1d)^-5//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*e^3//2*(-1d)^-5//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^3//2*(-1d)^-5//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^3//2*(-1d)^-5//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//6*b*c*d^-1*x^-2*(1+-1*c^2*x^2)^(1/2))
@test integrate(x^3*(d+e*x^2)^-2*(a+b*arcsin(c*x)), x) == :((1/2)*e^-2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*d*e^-2*(d+e*x^2)^-1*(a+b*arcsin(c*x))+-1//2*im*b*e^-2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b^-1*e^-2*(a+b*arcsin(c*x))^2+-1//2*b*c*d^(1/2)*e^-2*(e+d*c^2)^-1//2*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2)))
@test integrate(x*(d+e*x^2)^-2*(a+b*arcsin(c*x)), x) == :((1/2)*e^-1*(d+e*x^2)^-1*(-1a+-1*b*arcsin(c*x))+(1/2)*b*c*d^-1//2*e^-1*(e+d*c^2)^-1//2*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2)))
@test integrate(x^-1*(d+e*x^2)^-2*(a+b*arcsin(c*x)), x) == :(d^-2*(a+b*arcsin(c*x))*log(1+-1*exp(2*im*arcsin(c*x)))+(1/2)*d^-1*(d+e*x^2)^-1*(a+b*arcsin(c*x))+-1//2*d^-2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*d^-2*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-1//2*b*c*d^-3//2*(e+d*c^2)^-1//2*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2)))
@test integrate(x^-3*(d+e*x^2)^-2*(a+b*arcsin(c*x)), x) == :(-1//2*d^-2*x^-2*(a+b*arcsin(c*x))+e*d^-3*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+e*d^-3*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+e*d^-3*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+e*d^-3*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-2*e*d^-3*(a+b*arcsin(c*x))*log(1+-1*exp(2*im*arcsin(c*x)))+-1//2*e*d^-2*(d+e*x^2)^-1*(a+b*arcsin(c*x))+im*b*e*d^-3*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-1*im*b*e*d^-3*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*im*b*e*d^-3*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*im*b*e*d^-3*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*im*b*e*d^-3*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*b*c*d^-2*x^-1*(1+-1*c^2*x^2)^(1/2)+(1/2)*b*c*e*d^-5//2*(e+d*c^2)^-1//2*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2)))
@test integrate(x^4*(d+e*x^2)^-2*(a+b*arcsin(c*x)), x) == :(a*x*e^-2+b*x*e^-2*arcsin(c*x)+b*c^-1*e^-2*(1+-1*c^2*x^2)^(1/2)+-3//4*e^-5//2*(-1d)^(1/2)*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//4*e^-5//2*(-1d)^(1/2)*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*d*e^-5//2*((-1d)^(1/2)+-1*x*e^(1/2))^-1*(a+b*arcsin(c*x))+1//4*d*e^-5//2*((-1d)^(1/2)+x*e^(1/2))^-1*(a+b*arcsin(c*x))+3//4*e^-5//2*(-1d)^(1/2)*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//4*e^-5//2*(-1d)^(1/2)*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//4*im*b*e^-5//2*(-1d)^(1/2)*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//4*im*b*e^-5//2*(-1d)^(1/2)*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//4*im*b*e^-5//2*(-1d)^(1/2)*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//4*im*b*e^-5//2*(-1d)^(1/2)*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*b*c*d*e^-5//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+1//4*b*c*d*e^-5//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2))))
@test integrate(x^2*(d+e*x^2)^-2*(a+b*arcsin(c*x)), x) == :(-1//4*e^-3//2*((-1d)^(1/2)+x*e^(1/2))^-1*(a+b*arcsin(c*x))+1//4*e^-3//2*((-1d)^(1/2)+-1*x*e^(1/2))^-1*(a+b*arcsin(c*x))+-1//4*e^-3//2*(-1d)^-1//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*e^-3//2*(-1d)^-1//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*e^-3//2*(-1d)^-1//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*e^-3//2*(-1d)^-1//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*im*b*e^-3//2*(-1d)^-1//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*im*b*e^-3//2*(-1d)^-1//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*b*c*e^-3//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+-1//4*b*c*e^-3//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2)))+1//4*im*b*e^-3//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*im*b*e^-3//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x))))
@test integrate((d+e*x^2)^-2*(a+b*arcsin(c*x)), x) == :(-1//4*d^-1*e^-1//2*((-1d)^(1/2)+-1*x*e^(1/2))^-1*(a+b*arcsin(c*x))+-1//4*e^-1//2*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*e^-1//2*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*d^-1*e^-1//2*((-1d)^(1/2)+x*e^(1/2))^-1*(a+b*arcsin(c*x))+1//4*e^-1//2*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*e^-1//2*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*im*b*e^-1//2*(-1d)^-3//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*im*b*e^-1//2*(-1d)^-3//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*im*b*e^-1//2*(-1d)^-3//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*im*b*e^-1//2*(-1d)^-3//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*b*c*d^-1*e^-1//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+1//4*b*c*d^-1*e^-1//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2))))
@test integrate(x^-2*(d+e*x^2)^-2*(a+b*arcsin(c*x)), x) == :(-1*d^-2*x^-1*(a+b*arcsin(c*x))+-1*b*c*d^-2*arctanh((1+-1*c^2*x^2)^(1/2))+-3//4*e^(1/2)*(-1d)^-5//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//4*e^(1/2)*(-1d)^-5//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*d^-2*e^(1/2)*((-1d)^(1/2)+x*e^(1/2))^-1*(a+b*arcsin(c*x))+1//4*d^-2*e^(1/2)*((-1d)^(1/2)+-1*x*e^(1/2))^-1*(a+b*arcsin(c*x))+3//4*e^(1/2)*(-1d)^-5//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//4*e^(1/2)*(-1d)^-5//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//4*im*b*e^(1/2)*(-1d)^-5//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//4*im*b*e^(1/2)*(-1d)^-5//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//4*im*b*e^(1/2)*(-1d)^-5//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//4*im*b*e^(1/2)*(-1d)^-5//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//4*b*c*d^-2*e^(1/2)*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+-1//4*b*c*d^-2*e^(1/2)*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2))))
@test integrate(x^5*(d+e*x^2)^-3*(a+b*arcsin(c*x)), x) == :((1/2)*e^-3*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-3*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-3*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-3*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+d*e^-3*(d+e*x^2)^-1*(a+b*arcsin(c*x))+-1//2*im*b*e^-3*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-3*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-3*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*e^-3*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b^-1*e^-3*(a+b*arcsin(c*x))^2+-1//4*d^2*e^-3*(d+e*x^2)^-2*(a+b*arcsin(c*x))+-1*b*c*d^(1/2)*e^-3*(e+d*c^2)^-1//2*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2))+1//8*b*c*d^(1/2)*e^-3*(e+d*c^2)^-3//2*(e+2*d*c^2)*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2))+1//8*b*c*d*x*e^-2*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1*(e+d*c^2)^-1)
@test integrate(x^3*(d+e*x^2)^-3*(a+b*arcsin(c*x)), x) == :(-1//4*b*d^-1*e^-2*arcsin(c*x)+1//4*d^-1*x^4*(d+e*x^2)^-2*(a+b*arcsin(c*x))+-1//8*b*c*x*e^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1*(e+d*c^2)^-1+1//8*b*c*d^-1//2*e^-2*(e+d*c^2)^-3//2*(3*e+2*d*c^2)*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2)))
@test integrate(x*(d+e*x^2)^-3*(a+b*arcsin(c*x)), x) == :(-1//4*e^-1*(d+e*x^2)^-2*(a+b*arcsin(c*x))+1//8*b*c*x*d^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1*(e+d*c^2)^-1+1//8*b*c*d^-3//2*e^-1*(e+d*c^2)^-3//2*(e+2*d*c^2)*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2)))
@test integrate(x^-1*(d+e*x^2)^-3*(a+b*arcsin(c*x)), x) == :(d^-3*(a+b*arcsin(c*x))*log(1+-1*exp(2*im*arcsin(c*x)))+(1/2)*d^-2*(d+e*x^2)^-1*(a+b*arcsin(c*x))+-1//2*d^-3*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-3*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-3*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*d^-3*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//4*d^-1*(d+e*x^2)^-2*(a+b*arcsin(c*x))+(1/2)*im*b*d^-3*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-3*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-3*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*im*b*d^-3*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*im*b*d^-3*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+-1//2*b*c*d^-5//2*(e+d*c^2)^-1//2*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2))+-1//8*b*c*d^-5//2*(e+d*c^2)^-3//2*(e+2*d*c^2)*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2))+-1//8*b*c*e*x*d^-2*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1*(e+d*c^2)^-1)
@test integrate(x^-3*(d+e*x^2)^-3*(a+b*arcsin(c*x)), x) == :(-1//2*d^-3*x^-2*(a+b*arcsin(c*x))+-1*e*d^-3*(d+e*x^2)^-1*(a+b*arcsin(c*x))+-3*e*d^-4*(a+b*arcsin(c*x))*log(1+-1*exp(2*im*arcsin(c*x)))+-1//4*e*d^-2*(d+e*x^2)^-2*(a+b*arcsin(c*x))+3//2*e*d^-4*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//2*e*d^-4*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//2*e*d^-4*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//2*e*d^-4*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//2*im*b*e*d^-4*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//2*im*b*e*d^-4*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//2*im*b*e*d^-4*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//2*im*b*e*d^-4*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*b*c*d^-3*x^-1*(1+-1*c^2*x^2)^(1/2)+3//2*im*b*e*d^-4*Polylogarithms.polylog(2,exp(2*im*arcsin(c*x)))+b*c*e*d^-7//2*(e+d*c^2)^-1//2*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2))+1//8*b*c*e*d^-7//2*(e+d*c^2)^-3//2*(e+2*d*c^2)*arctan(x*d^-1//2*(1+-1*c^2*x^2)^-1//2*(e+d*c^2)^(1/2))+1//8*b*c*x*d^-3*e^2*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1*(e+d*c^2)^-1)
@test integrate(x^4*(d+e*x^2)^-3*(a+b*arcsin(c*x)), x) == :(-1//16*e^-5//2*((-1d)^(1/2)+x*e^(1/2))^-1*(5a+5*b*arcsin(c*x))+1//16*e^-5//2*((-1d)^(1/2)+-1*x*e^(1/2))^-1*(5a+5*b*arcsin(c*x))+-1//16*e^-5//2*(-1d)^(1/2)*((-1d)^(1/2)+-1*x*e^(1/2))^-2*(a+b*arcsin(c*x))+-1//16*e^-5//2*(-1d)^-1//2*(3a+3*b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//16*e^-5//2*(-1d)^-1//2*(3a+3*b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*e^-5//2*(-1d)^(1/2)*((-1d)^(1/2)+x*e^(1/2))^-2*(a+b*arcsin(c*x))+1//16*e^-5//2*(-1d)^-1//2*(3a+3*b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*e^-5//2*(-1d)^-1//2*(3a+3*b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-5//16*b*c*e^-5//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+-5//16*b*c*e^-5//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2)))+-3//16*im*b*e^-5//2*(-1d)^-1//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//16*im*b*e^-5//2*(-1d)^-1//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//16*im*b*e^-5//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//16*im*b*e^-5//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*b*d*c^3*e^-5//2*(e+d*c^2)^-3//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+1//16*b*d*c^3*e^-5//2*(e+d*c^2)^-3//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2)))+1//16*b*c*e^-2*(-1d)^(1/2)*(1+-1*c^2*x^2)^(1/2)*(e+d*c^2)^-1*((-1d)^(1/2)+x*e^(1/2))^-1+1//16*b*c*e^-2*(-1d)^(1/2)*(1+-1*c^2*x^2)^(1/2)*(e+d*c^2)^-1*((-1d)^(1/2)+-1*x*e^(1/2))^-1)
@test integrate(x^2*(d+e*x^2)^-3*(a+b*arcsin(c*x)), x) == :(-1//16*d^-1*e^-3//2*((-1d)^(1/2)+-1*x*e^(1/2))^-1*(a+b*arcsin(c*x))+-1//16*e^-3//2*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//16*e^-3//2*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//16*e^-3//2*(-1d)^-1//2*((-1d)^(1/2)+-1*x*e^(1/2))^-2*(a+b*arcsin(c*x))+1//16*d^-1*e^-3//2*((-1d)^(1/2)+x*e^(1/2))^-1*(a+b*arcsin(c*x))+1//16*e^-3//2*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*e^-3//2*(-1d)^-3//2*(a+b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*e^-3//2*(-1d)^-1//2*((-1d)^(1/2)+x*e^(1/2))^-2*(a+b*arcsin(c*x))+-1//16*im*b*e^-3//2*(-1d)^-3//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//16*im*b*e^-3//2*(-1d)^-3//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//16*b*c^3*e^-3//2*(e+d*c^2)^-3//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+-1//16*b*c^3*e^-3//2*(e+d*c^2)^-3//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2)))+1//16*im*b*e^-3//2*(-1d)^-3//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*im*b*e^-3//2*(-1d)^-3//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*b*c*d^-1*e^-3//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+1//16*b*c*d^-1*e^-3//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2)))+1//16*b*c*e^-1*(-1d)^-1//2*(1+-1*c^2*x^2)^(1/2)*(e+d*c^2)^-1*((-1d)^(1/2)+x*e^(1/2))^-1+1//16*b*c*e^-1*(-1d)^-1//2*(1+-1*c^2*x^2)^(1/2)*(e+d*c^2)^-1*((-1d)^(1/2)+-1*x*e^(1/2))^-1)
@test integrate((d+e*x^2)^-3*(a+b*arcsin(c*x)), x) == :(-1//16*d^-2*e^-1//2*((-1d)^(1/2)+-1*x*e^(1/2))^-1*(3a+3*b*arcsin(c*x))+-1//16*e^-1//2*(-1d)^-5//2*(3a+3*b*arcsin(c*x))*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//16*e^-1//2*(-1d)^-5//2*(3a+3*b*arcsin(c*x))*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//16*e^-1//2*(-1d)^-3//2*((-1d)^(1/2)+-1*x*e^(1/2))^-2*(a+b*arcsin(c*x))+1//16*d^-2*e^-1//2*((-1d)^(1/2)+x*e^(1/2))^-1*(3a+3*b*arcsin(c*x))+1//16*e^-1//2*(-1d)^-5//2*(3a+3*b*arcsin(c*x))*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*e^-1//2*(-1d)^-5//2*(3a+3*b*arcsin(c*x))*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*e^-1//2*(-1d)^-3//2*((-1d)^(1/2)+x*e^(1/2))^-2*(a+b*arcsin(c*x))+-3//16*im*b*e^-1//2*(-1d)^-5//2*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-3//16*im*b*e^-1//2*(-1d)^-5//2*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//16*im*b*e^-1//2*(-1d)^-5//2*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+3//16*im*b*e^-1//2*(-1d)^-5//2*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+1//16*b*c*(-1d)^-3//2*(1+-1*c^2*x^2)^(1/2)*(e+d*c^2)^-1*((-1d)^(1/2)+x*e^(1/2))^-1+1//16*b*c*(-1d)^-3//2*(1+-1*c^2*x^2)^(1/2)*(e+d*c^2)^-1*((-1d)^(1/2)+-1*x*e^(1/2))^-1+1//16*b*c^3*d^-1*e^-1//2*(e+d*c^2)^-3//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+1//16*b*c^3*d^-1*e^-1//2*(e+d*c^2)^-3//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2)))+3//16*b*c*d^-2*e^-1//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+x*c^2*(-1d)^(1/2)))+3//16*b*c*d^-2*e^-1//2*(e+d*c^2)^-1//2*arctanh((1+-1*c^2*x^2)^-1//2*(e+d*c^2)^-1//2*(e^(1/2)+-1*x*c^2*(-1d)^(1/2))))
@test integrate((d+e*x^2)^-3//2*(a+b*arcsin(c*x)), x) == :(b*d^-1*e^-1//2*arctan(c^-1*e^(1/2)*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+x*d^-1*(d+e*x^2)^-1//2*(a+b*arcsin(c*x)))
@test integrate((d+e*x^2)^-5//2*(a+b*arcsin(c*x)), x) == :(1//3*x*d^-1*(d+e*x^2)^-3//2*(a+b*arcsin(c*x))+2//3*b*d^-2*e^-1//2*arctan(c^-1*e^(1/2)*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+2//3*x*d^-2*(d+e*x^2)^-1//2*(a+b*arcsin(c*x))+1//3*b*c*d^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2*(e+d*c^2)^-1)
@test integrate((d+e*x^2)^-7//2*(a+b*arcsin(c*x)), x) == :(1//5*x*d^-1*(d+e*x^2)^-5//2*(a+b*arcsin(c*x))+4//15*x*d^-2*(d+e*x^2)^-3//2*(a+b*arcsin(c*x))+8//15*b*d^-3*e^-1//2*arctan(c^-1*e^(1/2)*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+8//15*x*d^-3*(d+e*x^2)^-1//2*(a+b*arcsin(c*x))+1//15*b*c*d^-1*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-3//2*(e+d*c^2)^-1+2//15*b*c*d^-2*(1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2*(e+d*c^2)^-2*(2*e+3*d*c^2))
@test integrate((a+b*arcsin(c*x))^2*(d+e*x^2)^3, x) == :(x*d^3*(a+b*arcsin(c*x))^2+-2*x*b^2*d^3+-2//343*b^2*e^3*x^7+1//7*e^3*x^7*(a+b*arcsin(c*x))^2+e*d^2*x^3*(a+b*arcsin(c*x))^2+-32//245*x*b^2*c^-6*e^3+-16//735*b^2*c^-4*e^3*x^3+-12//1225*b^2*c^-2*e^3*x^5+-6//125*d*b^2*e^2*x^5+-2//9*e*b^2*d^2*x^3+3//5*d*e^2*x^5*(a+b*arcsin(c*x))^2+2*b*c^-1*d^3*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+-16//25*d*x*b^2*c^-4*e^2+-8//75*d*b^2*c^-2*e^2*x^3+-4//3*e*x*b^2*c^-2*d^2+32//245*b*c^-7*e^3*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+2//49*b*c^-1*e^3*x^6*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+4//3*b*e*c^-3*d^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+12//245*b*c^-3*e^3*x^4*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+16//25*b*d*c^-5*e^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+16//245*b*c^-5*e^3*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+2//3*b*e*c^-1*d^2*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+6//25*b*d*c^-1*e^2*x^4*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+8//25*b*d*c^-3*e^2*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x)))
@test integrate((a+b*arcsin(c*x))^2*(d+e*x^2)^2, x) == :(x*d^2*(a+b*arcsin(c*x))^2+-2*x*b^2*d^2+-2//125*b^2*e^2*x^5+1//5*e^2*x^5*(a+b*arcsin(c*x))^2+-16//75*x*b^2*c^-4*e^2+-8//225*b^2*c^-2*e^2*x^3+-4//27*d*e*b^2*x^3+2//3*d*e*x^3*(a+b*arcsin(c*x))^2+2*b*c^-1*d^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+-8//9*d*e*x*b^2*c^-2+16//75*b*c^-5*e^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+2//25*b*c^-1*e^2*x^4*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+8//9*b*d*e*c^-3*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+8//75*b*c^-3*e^2*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+4//9*b*d*e*c^-1*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x)))
@test integrate((a+b*arcsin(c*x))^2*(d+e*x^2), x) == :(d*x*(a+b*arcsin(c*x))^2+-2*d*x*b^2+-2//27*e*b^2*x^3+1//3*e*x^3*(a+b*arcsin(c*x))^2+-4//9*e*x*b^2*c^-2+2*b*d*c^-1*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+4//9*b*e*c^-3*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))+2//9*b*e*c^-1*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x)))
@test integrate((a+b*arcsin(c*x))^2, x) == :(x*(a+b*arcsin(c*x))^2+-2*x*b^2+2*b*c^-1*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x)))
@test integrate((a+b*arcsin(c*x))^2*(d+e*x^2)^-1, x) == :(b^2*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(3,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+b^2*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(3,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))^2*log(1+-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+(1/2)*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))^2*log(1+-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*b^2*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(3,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*b^2*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(3,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))^2*log(1+e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1//2*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))^2*log(1+e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+im*b*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))*Polylogarithms.polylog(2,-1*e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+im*b*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))*Polylogarithms.polylog(2,-1*e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*im*b*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))*Polylogarithms.polylog(2,e^(1/2)*((e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x)))+-1*im*b*e^-1//2*(-1d)^-1//2*(a+b*arcsin(c*x))*Polylogarithms.polylog(2,e^(1/2)*(-1*(e+d*c^2)^(1/2)+im*c*(-1d)^(1/2))^-1*exp(im*arcsin(c*x))))
@test integrate((a+b*arcsin(c*x))^-1*(d+e*x^2)^2, x) == :(b^-1*c^-1*d^2*cos(a*b^-1)*cosintegral(b^-1*(a+b*arcsin(c*x)))+b^-1*c^-1*d^2*sin(a*b^-1)*sinintegral(b^-1*(a+b*arcsin(c*x)))+-3//16*b^-1*c^-5*e^2*cos(3*a*b^-1)*cosintegral(3*arcsin(c*x)+3*a*b^-1)+-3//16*b^-1*c^-5*e^2*sin(3*a*b^-1)*sinintegral(3*arcsin(c*x)+3*a*b^-1)+1//8*b^-1*c^-5*e^2*cos(a*b^-1)*cosintegral(a*b^-1+arcsin(c*x))+1//8*b^-1*c^-5*e^2*sin(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x))+1//16*b^-1*c^-5*e^2*cos(5*a*b^-1)*cosintegral(5*arcsin(c*x)+5*a*b^-1)+1//16*b^-1*c^-5*e^2*sin(5*a*b^-1)*sinintegral(5*arcsin(c*x)+5*a*b^-1)+(1/2)*d*e*b^-1*c^-3*cos(a*b^-1)*cosintegral(a*b^-1+arcsin(c*x))+(1/2)*d*e*b^-1*c^-3*sin(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x))+-1//2*d*e*b^-1*c^-3*cos(3*a*b^-1)*cosintegral(3*arcsin(c*x)+3*a*b^-1)+-1//2*d*e*b^-1*c^-3*sin(3*a*b^-1)*sinintegral(3*arcsin(c*x)+3*a*b^-1))
@test integrate((a+b*arcsin(c*x))^-1*(d+e*x^2), x) == :(d*b^-1*c^-1*cos(a*b^-1)*cosintegral(b^-1*(a+b*arcsin(c*x)))+d*b^-1*c^-1*sin(a*b^-1)*sinintegral(b^-1*(a+b*arcsin(c*x)))+-1//4*e*b^-1*c^-3*cos(3*a*b^-1)*cosintegral(3*arcsin(c*x)+3*a*b^-1)+-1//4*e*b^-1*c^-3*sin(3*a*b^-1)*sinintegral(3*arcsin(c*x)+3*a*b^-1)+1//4*e*b^-1*c^-3*cos(a*b^-1)*cosintegral(a*b^-1+arcsin(c*x))+1//4*e*b^-1*c^-3*sin(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x)))
@test integrate((a+b*arcsin(c*x))^-1, x) == :(b^-1*c^-1*cos(a*b^-1)*cosintegral(b^-1*(a+b*arcsin(c*x)))+b^-1*c^-1*sin(a*b^-1)*sinintegral(b^-1*(a+b*arcsin(c*x))))
@test integrate((a+b*arcsin(c*x))^-2*(d+e*x^2)^2, x) == :(b^-2*c^-1*d^2*cosintegral(a*b^-1+arcsin(c*x))*sin(a*b^-1)+-1*b^-1*c^-1*d^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1+-1*b^-2*c^-1*d^2*cos(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x))+-9//16*b^-2*c^-5*e^2*cosintegral(3*arcsin(c*x)+3*a*b^-1)*sin(3*a*b^-1)+-5//16*b^-2*c^-5*e^2*cos(5*a*b^-1)*sinintegral(5*arcsin(c*x)+5*a*b^-1)+-1//8*b^-2*c^-5*e^2*cos(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x))+1//8*b^-2*c^-5*e^2*cosintegral(a*b^-1+arcsin(c*x))*sin(a*b^-1)+5//16*b^-2*c^-5*e^2*cosintegral(5*arcsin(c*x)+5*a*b^-1)*sin(5*a*b^-1)+9//16*b^-2*c^-5*e^2*cos(3*a*b^-1)*sinintegral(3*arcsin(c*x)+3*a*b^-1)+(1/2)*d*e*b^-2*c^-3*cosintegral(a*b^-1+arcsin(c*x))*sin(a*b^-1)+-1*b^-1*c^-1*e^2*x^4*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1+-3//2*d*e*b^-2*c^-3*cosintegral(3*arcsin(c*x)+3*a*b^-1)*sin(3*a*b^-1)+-1//2*d*e*b^-2*c^-3*cos(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x))+3//2*d*e*b^-2*c^-3*cos(3*a*b^-1)*sinintegral(3*arcsin(c*x)+3*a*b^-1)+-2*d*e*b^-1*c^-1*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1)
@test integrate((a+b*arcsin(c*x))^-2*(d+e*x^2), x) == :(d*b^-2*c^-1*cosintegral(a*b^-1+arcsin(c*x))*sin(a*b^-1)+-1*d*b^-1*c^-1*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1+-1*d*b^-2*c^-1*cos(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x))+-3//4*e*b^-2*c^-3*cosintegral(3*arcsin(c*x)+3*a*b^-1)*sin(3*a*b^-1)+-1//4*e*b^-2*c^-3*cos(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x))+1//4*e*b^-2*c^-3*cosintegral(a*b^-1+arcsin(c*x))*sin(a*b^-1)+3//4*e*b^-2*c^-3*cos(3*a*b^-1)*sinintegral(3*arcsin(c*x)+3*a*b^-1)+-1*e*b^-1*c^-1*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1)
@test integrate((a+b*arcsin(c*x))^-2, x) == :(b^-2*c^-1*cosintegral(a*b^-1+arcsin(c*x))*sin(a*b^-1)+-1*b^-1*c^-1*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1+-1*b^-2*c^-1*cos(a*b^-1)*sinintegral(a*b^-1+arcsin(c*x)))
@test integrate((a+b*arcsin(c*x))^(1/2)*(d+e*x^2)^2, x) == :(x*d^2*(a+b*arcsin(c*x))^(1/2)+1//5*e^2*x^5*(a+b*arcsin(c*x))^(1/2)+2//3*d*e*x^3*(a+b*arcsin(c*x))^(1/2)+(1/2)*2^(1/2)*pi^(1/2)*b^(1/2)*c^-1*d^2*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+-1//2*2^(1/2)*pi^(1/2)*b^(1/2)*c^-1*d^2*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//16*2^(1/2)*pi^(1/2)*b^(1/2)*c^-5*e^2*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//96*6^(1/2)*pi^(1/2)*b^(1/2)*c^-5*e^2*fresnelc(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(3*a*b^-1)+-1//800*10^(1/2)*pi^(1/2)*b^(1/2)*c^-5*e^2*cos(5*a*b^-1)*fresnels(10^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+1//16*2^(1/2)*pi^(1/2)*b^(1/2)*c^-5*e^2*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+1//96*6^(1/2)*pi^(1/2)*b^(1/2)*c^-5*e^2*cos(3*a*b^-1)*fresnels(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+1//800*10^(1/2)*pi^(1/2)*b^(1/2)*c^-5*e^2*fresnelc(10^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(5*a*b^-1)+-1//4*d*e*2^(1/2)*pi^(1/2)*b^(1/2)*c^-3*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//36*d*e*6^(1/2)*pi^(1/2)*b^(1/2)*c^-3*fresnelc(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(3*a*b^-1)+1//4*d*e*2^(1/2)*pi^(1/2)*b^(1/2)*c^-3*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+1//36*d*e*6^(1/2)*pi^(1/2)*b^(1/2)*c^-3*cos(3*a*b^-1)*fresnels(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2)))
@test integrate((a+b*arcsin(c*x))^(1/2)*(d+e*x^2), x) == :(d*x*(a+b*arcsin(c*x))^(1/2)+1//3*e*x^3*(a+b*arcsin(c*x))^(1/2)+(1/2)*d*2^(1/2)*pi^(1/2)*b^(1/2)*c^-1*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+-1//2*d*2^(1/2)*pi^(1/2)*b^(1/2)*c^-1*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//8*e*2^(1/2)*pi^(1/2)*b^(1/2)*c^-3*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//72*e*6^(1/2)*pi^(1/2)*b^(1/2)*c^-3*fresnelc(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(3*a*b^-1)+1//8*e*2^(1/2)*pi^(1/2)*b^(1/2)*c^-3*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+1//72*e*6^(1/2)*pi^(1/2)*b^(1/2)*c^-3*cos(3*a*b^-1)*fresnels(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2)))
@test integrate((a+b*arcsin(c*x))^(1/2), x) == :(x*(a+b*arcsin(c*x))^(1/2)+(1/2)*2^(1/2)*pi^(1/2)*b^(1/2)*c^-1*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+-1//2*2^(1/2)*pi^(1/2)*b^(1/2)*c^-1*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2)))
@test integrate((a+b*arcsin(c*x))^3//2*(d+e*x^2), x) == :(d*x*(a+b*arcsin(c*x))^3//2+1//3*e*x^3*(a+b*arcsin(c*x))^3//2+1//3*b*e*c^-3*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^(1/2)+3//2*b*d*c^-1*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^(1/2)+1//6*b*e*c^-1*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^(1/2)+-3//4*d*2^(1/2)*pi^(1/2)*b^3//2*c^-1*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-3//4*d*2^(1/2)*pi^(1/2)*b^3//2*c^-1*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+-3//16*e*2^(1/2)*pi^(1/2)*b^3//2*c^-3*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-3//16*e*2^(1/2)*pi^(1/2)*b^3//2*c^-3*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+1//144*e*6^(1/2)*pi^(1/2)*b^3//2*c^-3*cos(3*a*b^-1)*fresnelc(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+1//144*e*6^(1/2)*pi^(1/2)*b^3//2*c^-3*fresnels(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(3*a*b^-1))
@test integrate((a+b*arcsin(c*x))^3//2, x) == :(x*(a+b*arcsin(c*x))^3//2+3//2*b*c^-1*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^(1/2)+-3//4*2^(1/2)*pi^(1/2)*b^3//2*c^-1*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-3//4*2^(1/2)*pi^(1/2)*b^3//2*c^-1*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1))
@test integrate((a+b*arcsin(c*x))^-1//2*(d+e*x^2)^2, x) == :(2^(1/2)*pi^(1/2)*b^-1//2*c^-1*d^2*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+2^(1/2)*pi^(1/2)*b^-1//2*c^-1*d^2*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+-1//16*6^(1/2)*pi^(1/2)*b^-1//2*c^-5*e^2*cos(3*a*b^-1)*fresnelc(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//16*6^(1/2)*pi^(1/2)*b^-1//2*c^-5*e^2*fresnels(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(3*a*b^-1)+1//8*2^(1/2)*pi^(1/2)*b^-1//2*c^-5*e^2*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+1//8*2^(1/2)*pi^(1/2)*b^-1//2*c^-5*e^2*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+1//80*10^(1/2)*pi^(1/2)*b^-1//2*c^-5*e^2*cos(5*a*b^-1)*fresnelc(10^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+1//80*10^(1/2)*pi^(1/2)*b^-1//2*c^-5*e^2*fresnels(10^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(5*a*b^-1)+(1/2)*d*e*2^(1/2)*pi^(1/2)*b^-1//2*c^-3*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+(1/2)*d*e*2^(1/2)*pi^(1/2)*b^-1//2*c^-3*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+-1//6*d*e*6^(1/2)*pi^(1/2)*b^-1//2*c^-3*cos(3*a*b^-1)*fresnelc(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//6*d*e*6^(1/2)*pi^(1/2)*b^-1//2*c^-3*fresnels(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(3*a*b^-1))
@test integrate((a+b*arcsin(c*x))^-1//2*(d+e*x^2), x) == :(d*2^(1/2)*pi^(1/2)*b^-1//2*c^-1*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+d*2^(1/2)*pi^(1/2)*b^-1//2*c^-1*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+-1//12*e*6^(1/2)*pi^(1/2)*b^-1//2*c^-3*cos(3*a*b^-1)*fresnelc(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//12*e*6^(1/2)*pi^(1/2)*b^-1//2*c^-3*fresnels(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(3*a*b^-1)+1//4*e*2^(1/2)*pi^(1/2)*b^-1//2*c^-3*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+1//4*e*2^(1/2)*pi^(1/2)*b^-1//2*c^-3*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1))
@test integrate((a+b*arcsin(c*x))^-1//2, x) == :(2^(1/2)*pi^(1/2)*b^-1//2*c^-1*cos(a*b^-1)*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+2^(1/2)*pi^(1/2)*b^-1//2*c^-1*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1))
@test integrate((a+b*arcsin(c*x))^-3//2*(d+e*x^2), x) == :(-2*d*b^-1*c^-1*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1//2+-2*e*b^-1*c^-1*x^2*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1//2+(1/2)*e*2^(1/2)*pi^(1/2)*b^-3//2*c^-3*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+(1/2)*e*6^(1/2)*pi^(1/2)*b^-3//2*c^-3*cos(3*a*b^-1)*fresnels(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-2*d*2^(1/2)*pi^(1/2)*b^-3//2*c^-1*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+2*d*2^(1/2)*pi^(1/2)*b^-3//2*c^-1*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1)+-1//2*e*2^(1/2)*pi^(1/2)*b^-3//2*c^-3*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+-1//2*e*6^(1/2)*pi^(1/2)*b^-3//2*c^-3*fresnelc(6^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(3*a*b^-1))
@test integrate((a+b*arcsin(c*x))^-3//2, x) == :(-2*b^-1*c^-1*(1+-1*c^2*x^2)^(1/2)*(a+b*arcsin(c*x))^-1//2+-2*2^(1/2)*pi^(1/2)*b^-3//2*c^-1*cos(a*b^-1)*fresnels(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))+2*2^(1/2)*pi^(1/2)*b^-3//2*c^-1*fresnelc(2^(1/2)*pi^-1//2*b^-1//2*(a+b*arcsin(c*x))^(1/2))*sin(a*b^-1))

max_stars_repo_path: test/5 Inverse trig functions/5.1 Inverse sine/5.1.4b (f x)^m (d+e x^2)^p (a+b arcsin(c x))^n.jl


text:
# ---
# title: 496. Next Greater Element I
# id: problem496
# author: Tian Jun
# date: 2020-10-31
# difficulty: Easy
# categories: Stack
# link: <https://leetcode.com/problems/next-greater-element-i/description/>
# hidden: true
# ---
#
# You are given two arrays **(without duplicates)** `nums1` and `nums2` where
# `nums1`’s elements are subset of `nums2`. Find all the next greater numbers
# for `nums1`'s elements in the corresponding places of `nums2`.
#
# The Next Greater Number of a number **x** in `nums1` is the first greater
# number to its right in `nums2`. If it does not exist, output -1 for this
# number.
#
# **Example 1:**
#
#
#
#     Input: **nums1** = [4,1,2], **nums2** = [1,3,4,2].
#     Output: [-1,3,-1]
#     Explanation:
#         For number 4 in the first array, you cannot find the next greater number for it in the second array, so output -1.
#         For number 1 in the first array, the next greater number for it in the second array is 3.
#         For number 2 in the first array, there is no next greater number for it in the second array, so output -1.
#
#
# **Example 2:**
#
#
#
#     Input: **nums1** = [2,4], **nums2** = [1,2,3,4].
#     Output: [3,-1]
#     Explanation:
#         For number 2 in the first array, the next greater number for it in the second array is 3.
#         For number 4 in the first array, there is no next greater number for it in the second array, so output -1.
#
#
# **Note:**
#
#   1. All elements in `nums1` and `nums2` are unique.
#   2. The length of both `nums1` and `nums2` would not exceed 1000.
#
#
## @lc code=start
using LeetCode

## add your code here:
## @lc code=end