text:
"""
compile_julia_fwsim( net::Network , target_semus::Vector{SpeciesEMU} )
  returns FWSim_Julia

creates the Julia_FWSim object for a specific network and a set of species emus that should be simulated
"""
function compile_julia_fwsim( net::Network , target_semus::Vector{SpeciesEMU} )

    emudecomp_1 = MetabolicFluxAnalysis.compute_emu_decomp( net , target_semus )
    emu_graph_1 = MetabolicFluxAnalysis.create_emu_graph(emudecomp_1)

    fluxi_ast_1 = MetabolicFluxAnalysis.create_ast_from_emu_graph( emu_graph_1 )

    # get the target semus from the fluxi measurements..
    target_smrs = MetabolicFluxAnalysis.construct_all_mass_ratios_for_measurement( target_semus )
    #julia_fw_sim_1 = MetabolicFluxAnalysis.ast_to_juliacode_01(fluxi1,fluxi_ast_1,target_smrs)
    julia_fw_sim_1 = MetabolicFluxAnalysis.ast_to_juliacode_01(net,fluxi_ast_1,target_smrs)

    return julia_fw_sim_1
end

"""
compile_julia_fwsim( net::Network , data::Vector{MassDistributionMeasurement} )
  returns FWSim_Julia

creates the Julia_FWSim object for a specific network and a set of measurements
"""
function compile_julia_fwsim( net::Network , data::Vector{MassDistributionMeasurement}  )
    target_semus = map( d -> d.sass , data)
    julia_fw_sim =  compile_julia_fwsim( net , target_semus )
end

"""
struct ILE_Evaluator

contains all the information to evaluate flux distributions with respect to
a given ILE

Functions to use with:
  eval_flux2mds( ilee::ILE_Evaluator , x::Array{Float64,2} )
  eval_flux2sse( ilee , x::Array{Float64,2} )
"""
struct ILE_Evaluator
    substrate_mds::Array{Float64,1}
    mdata::Array{Float64,2}
    mdata2fw::Vector{Int64} # f_fwsim(x)[i]  corresponds to mdata[i,:]
    f_fwsim::Any           # function (substr_mds::Array{Float64,1},fluxes::Array{Float64,2}) -> mds::Array{Float64,2}
    f_fwsim_armed::Any
    fwsim::FWSim
end

"""
eval_flux2mds( ilee::ILE_Evaluator , x::Array{Float64,2} )
  returns Array{Float64,2}

computes mds for given ILE_Evaluator and fluxes
"""
function eval_flux2mds( ilee::ILE_Evaluator , x::Array{Float64,2} )
    mds::Array{Float64,2} = NaN * ones(size(ilee.mdata,1),size(x,2))
    mds                   = ilee.f_fwsim(ilee.substrate_mds,x)
    #for zi=1:size(x,2)
    #    mds[:,zi] = ilee.f_fwsim(ilee.substrate_mds,x[:,zi])
    #end
    return mds
end

"""
eval_flux2mds( ilee::ILE_Evaluator , x::Array{Float64,2} )
  returns Array{Float64,2}

computes sses for given ILE_Evaluator and fluxes
"""
function eval_flux2sse( ilee , x::Array{Float64,2} )
    mds = eval_flux2mds( ilee , x)
    res::Array{Float64,2} = broadcast( / , broadcast( - , mds[ilee.mdata2fw,:] , ilee.mdata[:,1] ) , ilee.mdata[:,2] )
    sse::Array{Float64,2} = sum( res.^2 , 1 )
    return sse
end

function eval_flux2sse( ilee , x::Array{Float64,1} )
    mds = eval_flux2mds( ilee , x[:,:])
    res::Array{Float64,2} = broadcast( / , broadcast( - , mds[ilee.mdata2fw,:] , ilee.mdata[:,1] ) , ilee.mdata[:,2] )
    sse::Array{Float64,2} = sum( res.^2 , 1 )[1]
    return sse
end

"""
create_julia_ile_evaluator( net::Network , substr_config::Vector{Dict{MetabolicFluxAnalysis.ConfiguredSEMU,Float64}} , data::Vector{MassDistributionMeasurement} )
  returns ILE_Evaluator

creates the ILE_Evaluator object which can be used to run the FW-Sim and perform
the fitting of fluxes against md data.
"""
function create_julia_ile_evaluator( net::Network , substr_config::Vector{Dict{MetabolicFluxAnalysis.ConfiguredSEMU,Float64}} , data::Vector{MassDistributionMeasurement} )
    julia_fw_sim = compile_julia_fwsim( net::Network , data::Vector{MassDistributionMeasurement}  )

    mr_positions::Dict{ASTEMUMassRatio,Int64} = Dict{ASTEMUMassRatio,Int64}()
    for zi in 1:length(julia_fw_sim.target_mass_ratios)
        mr_positions[julia_fw_sim.target_mass_ratios[zi]] = zi
    end

    mdata     = Array{Float64,2}(0,3)
    fw2mdata  = Vector{Int64}()

    for mdm in data
        semu = mdm.sass
        for zi=0:length(semu)
            mrd = ASTEMUMassRatio(semu,zi)
            if(!haskey(mr_positions,mrd))
                print("\n!! Something went wrong, no target semu for  measurement $(mrd)\n")
            else
                mdata    = [ mdata     ; mdm.data[zi][1:3]' ]
                fw2mdata = [ fw2mdata  ; mr_positions[mrd]  ]
            end
        end
    end

     # and collect data for semus:
     mds_a =  MetabolicFluxAnalysis.construct_mds( substr_config , julia_fw_sim.semu_mass_ratios )

    f_fwsim_single = eval(  parse( julia_fw_sim.code ) )
    f_fwsim_batch  = (xsubstr_mds::Array{Float64,1},xfluxes::Array{Float64,2}) -> eval_over_columns( (x_::Array{Float64,1}) -> f_fwsim_single(xsubstr_mds,x_) , size(mdata,1) , xfluxes )
    f_fwsim_batch_armed  = (xfluxes::Array{Float64,2}) -> eval_over_columns( (x_::Array{Float64,1}) -> f_fwsim_single(mds_a,x_) , size(mdata,1) , xfluxes )
    return ILE_Evaluator(mds_a,mdata,fw2mdata,f_fwsim_batch, f_fwsim_batch_armed, julia_fw_sim)
end

function eval_over_columns( f::Any , rows_result::Int , x::Array{Float64,2} )
    x_out::Array{Float64,2} = NaN * ones(rows_result,size(x,2))
    for zi=1:size(x,2)
        x_out[:,zi] = f(x[:,zi]) #ilee.f_fwsim(ilee.substrate_mds,x[:,zi])
    end
    return x_out
end

function fva(net::Network,lc::Vector{LinConstr})
    return fva(net::Network,lc::Vector{LinConstr},collect(1:length(net.fluxes)))
end

function fva(net::Network,lc::Vector{LinConstr},idx::Vector{Int64})
    print_output = length(idx)>10
    if(print_output); print("fva: "); end
    d  = length(net.fluxes)
    fp = get_flux_polyhedron(net,lc)
    lb = NaN * ones(length(idx))
    ub = NaN * ones(length(idx))
    for zi=1:length(idx)
        fba_result = solve_lp_minmax(fp, (1.0*( (1:d).== idx[zi] ) ) )
        lb[zi] = fba_result[1]
        ub[zi] = fba_result[2]
        if(print_output); if(mod(zi,ceil(length(idx)/40.))==0) print("."); end; end
    end
    if(print_output); print(" ..done!\n") end
    return (lb,ub)
end

"""
compile_opencl_fwsim( net::Network , target_semus::Vector{SpeciesEMU} )
  returns FWSim_OpenCL

creates the OpenCL_FWSim object for a specific network and a set of species emus that should be simulated
"""
function compile_opencl_fwsim( net::Network , target_semus::Vector{SpeciesEMU} )

    emudecomp_1 = MetabolicFluxAnalysis.compute_emu_decomp( net , target_semus )
    emu_graph_1 = MetabolicFluxAnalysis.create_emu_graph(emudecomp_1)

    fluxi_ast_1 = MetabolicFluxAnalysis.create_ast_from_emu_graph( emu_graph_1 )

    # get the target semus from the fluxi measurements..
    target_smrs     = MetabolicFluxAnalysis.construct_all_mass_ratios_for_measurement( target_semus )
    #julia_fw_sim_1 = MetabolicFluxAnalysis.ast_to_juliacode_01(fluxi1,fluxi_ast_1,target_smrs)
    opencl_fw_sim_1 = MetabolicFluxAnalysis.ast_to_opencl_01(net,fluxi_ast_1,target_smrs)

    return opencl_fw_sim_1
end

"""
compile_opencl_fwsim( net::Network , data::Vector{MassDistributionMeasurement} )
  returns FWSim_OpenCL

creates the OpenCL FWSim object for a specific network and a set of measurements
"""
function compile_opencl_fwsim( net::Network , data::Vector{MassDistributionMeasurement}  )
    target_semus = map( d -> d.sass , data)
    ocl_fw_sim =  compile_opencl_fwsim( net , target_semus )
end

function build_opencl_fwsim!( ocl_fwsim::MetabolicFluxAnalysis.FWSim_OpenCL , ocl_context::OCLContext)

    ocl_fwsim.ocl_context = ocl_context
    #p_ocl = cl.Program(ocl_context.ocl_ctx, source= ocl_fwsim.code ) |> OpenCL.cl.build!
    print("Create cl.Program\n")
    p_ocl = cl.Program(ocl_context.ocl_ctx, source= ocl_fwsim.code )
    print("Build! cl.Program\n")
    OpenCL.cl.build!(p_ocl)

    k_ocl = cl.Kernel(p_ocl, "fwsim")

    ocl_fwsim.p = p_ocl
    ocl_fwsim.k = k_ocl
end

function run_ocl_fluxes( ocl_fwsim::FWSim_OpenCL , semu_data_x::Array{Float64,1} , flux_data_x::Array{Float64,2} )
    n_fluxes = size(flux_data_x,2)
    data_out  = Array{Float32}( length(ocl_fwsim.target_mass_ratios) * n_fluxes )

    #semu_data = convert( Array{Float32,1} ,[0.00 ; 1.00; 1.00; 0.00; 0.00; 1.0 ;0.0;0.0;1.0;0.0;0.0;0;0;0;0;0] )
    #flux_data = convert( Array{Float32,1} ,[100.; 110 ; 50 ; 20 ; 20 ; 80 ; 0;0;0;0;0;0;0;0;0;0] )
    semu_data = convert( Array{Float32,1} , semu_data_x[:] )
    flux_data = convert( Array{Float32,1} , flux_data_x[:] )

    #device, ctx, queue = OpenCL.cl.create_compute_context()
    ocl_context = ocl_fwsim.ocl_context.value
    ctx         = ocl_context.ocl_ctx
    queue       = ocl_context.ocl_queue

    semu_buff = cl.Buffer(Float32, ctx, (:r, :copy), hostbuf=semu_data)
    flux_buff = cl.Buffer(Float32, ctx, (:r, :copy), hostbuf=flux_data)
    out_buff  = cl.Buffer(Float32, ctx, :w, length(data_out))
    k = ocl_fwsim.k.value #cl.Kernel(p, "fwsim")

    req_sx = ocl_fwsim.required_matrix_size_x
    req_sy = ocl_fwsim.required_matrix_size_y

    println("length data_out = $(length(data_out))")
    println("nfluxes = $(size(flux_data_x,2))")
    println("run config: $(req_sx),$(req_sy*size(flux_data,2)) ; $(req_sx),$(req_sy)")

    #queue(k, [ size(flux_data,2) * req_sx ; req_sy ], [req_sx;req_sy], semu_buff, flux_buff, out_buff)
    #queue(k, [ req_sx ; n_fluxes * req_sx ], [req_sx;req_sx], semu_buff, flux_buff, c_buff)
    queue(k, [ n_fluxes * req_sx ], [req_sx], semu_buff, flux_buff, out_buff)

    #cl.api.clGetKernelWorkGroupInfo(cl.CL_KERNEL_WORK_GROUP_SIZE)
    r = cl.read(ocl_context.ocl_queue, out_buff)
end

"""

"""
function run_ocl_fluxes( ocl_fwsim::FWSim_OpenCL , semu_buff::cl.Buffer , flux_data_x::Array{Float64,2} )
    n_fluxes = size(flux_data_x,2)
    data_out  = Array{Float32}( length(ocl_fwsim.target_mass_ratios) * n_fluxes )

    #semu_data = convert( Array{Float32,1} , semu_data[:] )
    flux_data = convert( Array{Float32,1} , flux_data_x[:] )

    ocl_context = ocl_fwsim.ocl_context.value

    #semu_buff = cl.Buffer(Float32, ocl_context.ctx, (:r, :copy), hostbuf=semu_data)
    flux_buff = cl.Buffer(Float32, ocl_context.ocl_ctx, (:r, :copy), hostbuf=flux_data)
    c_buff = cl.Buffer(Float32, ocl_context.ocl_ctx, :w, length(data_out))
    k = ocl_fwsim.k.value #cl.Kernel(p, "fwsim")

    req_sx = ocl_fwsim.required_matrix_size_x
    req_sy = ocl_fwsim.required_matrix_size_y
    #queue(k, [ req_sx ; n_fluxes * req_sx ], [req_sx;req_sx], semu_buff, flux_buff, c_buff)
    queue(k, [ n_fluxes * req_sx ], [req_sx], semu_buff, flux_buff, c_buff)
    r = cl.read(ocl_context.ocl_queue, c_buff)
end

"""
create_opencl_ile_evaluator( net::Network , substr_config::Vector{Dict{MetabolicFluxAnalysis.ConfiguredSEMU,Float64}} , data::Vector{MassDistributionMeasurement} )
  returns ILE_Evaluator

creates the ILE_Evaluator object which can be used to run the FW-Sim and perform
the fitting of fluxes against md data.
"""
function create_opencl_ile_evaluator( net::Network , substr_config::Vector{Dict{MetabolicFluxAnalysis.ConfiguredSEMU,Float64}} , data::Vector{MassDistributionMeasurement} , ocl_context::OCLContext  )
    ocl_fw_sim = compile_opencl_fwsim( net::Network , data::Vector{MassDistributionMeasurement}  )

    if(false)
        print("\nOCL KERNEL:\n")
        print(ocl_fw_sim.code)
        print("\n")
        return ocl_fw_sim
    end

    mr_positions::Dict{ASTEMUMassRatio,Int64} = Dict{ASTEMUMassRatio,Int64}()
    for zi in 1:length(ocl_fw_sim.target_mass_ratios)
        mr_positions[ocl_fw_sim.target_mass_ratios[zi]] = zi
    end

    mdata     = Array{Float64,2}(0,3)
    fw2mdata  = Vector{Int64}()

    for mdm in data
        semu = mdm.sass
        for zi=0:length(semu)
            mrd = ASTEMUMassRatio(semu,zi)
            if(!haskey(mr_positions,mrd))
                print("\n!! Something went wrong, no target semu for  measurement $(mrd)\n")
            else
                mdata    = [ mdata     ; mdm.data[zi][1:3]' ]
                fw2mdata = [ fw2mdata  ; mr_positions[mrd]  ]
            end
        end
    end

     # and collect data for semus:
     mds_a =  MetabolicFluxAnalysis.construct_mds( substr_config , ocl_fw_sim.semu_mass_ratios )

    #f_fwsim = eval(  parse( opencl_fw_sim.code ) )
    #p_ocl = cl.Program(ctx, source= opencl_fw_sim.code ) |> cl.build!
    #k_ocl = cl.Kernel(p, "fwsim")
    build_opencl_fwsim!( ocl_fw_sim::MetabolicFluxAnalysis.FWSim_OpenCL , ocl_context::OCLContext)

    # create the semu data buffer:
    semu_data = convert( Array{Float32,1} , mds_a[:] )
    semu_buff = cl.Buffer(Float32, ocl_context.ocl_ctx, (:r, :copy), hostbuf=semu_data)

    f_fwsim       = (xsubstr_mds::Array{Float64,1},xfluxes::Array{Float64,2}) -> run_ocl_fluxes(ocl_fw_sim,xsubstr_mds,xfluxes)
    f_fwsim_armed = (xfluxes::Array{Float64,2}) -> run_ocl_fluxes(ocl_fw_sim,semu_buff,xfluxes)
    #f_fwsim_batch  = (xsubstr_mds::Array{Float64,1},xfluxes::Array{Float64,2}) -> eval_over_columns( (x_::Array{Float64,1}) -> f_fwsim_single(xsubstr_mds,x_) , size(mdata,1) , xfluxes )

    return ILE_Evaluator(mds_a,mdata,fw2mdata,f_fwsim,f_fwsim_armed , ocl_fw_sim)
end


text:
"""
    struct WeightingPotential{T, N, S, AT} <: AbstractArray{T, N}

Weighting potential for a given [`Contact`](@ref) which is a unitless potential.

## Parametric types
* `T`: Element type of `data`.
* `N`: Dimension of the `grid` and `data` array.
* `S`: Coordinate system (`Cartesian` or `Cylindrical`).
* `AT`: Axes type.

## Fields
* `data::Array{T, N}`: Array containing the values of the weighting potential at the discrete points of the `grid`.
* `grid::Grid{T, N, S, AT}`: [`Grid`](@ref) defining the discrete points for which the weighting potential is determined.
"""
struct WeightingPotential{T, N, S <: AbstractCoordinateSystem, AT} <: AbstractArray{T, N}
    data::Array{T, N}
    grid::Grid{T, N, S, AT}
end

@inline size(wpot::WeightingPotential{T, N, S}) where {T, N, S} = size(wpot.data)
@inline length(wpot::WeightingPotential{T, N, S}) where {T, N, S} = length(wpot.data)
@inline getindex(wpot::WeightingPotential{T, N, S}, I::Vararg{Int, N}) where {T, N, S} = getindex(wpot.data, I...)
@inline getindex(wpot::WeightingPotential{T, N, S}, i::Int) where {T, N, S} = getindex(wpot.data, i)
@inline getindex(wpot::WeightingPotential{T, N, S}, s::Symbol) where {T, N, S} = getindex(wpot.grid, s)

function WeightingPotential(nt::NamedTuple)
    grid = Grid(nt.grid)
    T = typeof(ustrip(nt.values[1]))
    S = get_coordinate_system(grid)
    N = get_number_of_dimensions(grid)
    WeightingPotential{T, N, S, typeof(grid.axes)}( nt.values, grid)
end
Base.convert(T::Type{WeightingPotential}, x::NamedTuple) = T(x)

function NamedTuple(wpot::WeightingPotential{T, 3}) where {T}
    return (
        grid = NamedTuple(wpot.grid),
        values = wpot.data,
    )
end
Base.convert(T::Type{NamedTuple}, x::WeightingPotential) = T(x)

ext: jl


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

mutable struct ProtocolsEnum <: SwaggerModel

    function ProtocolsEnum(;)
        o = new()
        o
    end
end # type ProtocolsEnum

const _property_map_ProtocolsEnum = Dict{Symbol,Symbol}()
const _property_types_ProtocolsEnum = Dict{Symbol,String}()
Base.propertynames(::Type{ ProtocolsEnum }) = collect(keys(_property_map_ProtocolsEnum))
Swagger.property_type(::Type{ ProtocolsEnum }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_ProtocolsEnum[name]))}
Swagger.field_name(::Type{ ProtocolsEnum }, property_name::Symbol) =  _property_map_ProtocolsEnum[property_name]

function check_required(o::ProtocolsEnum)
    true
end

function validate_property(::Type{ ProtocolsEnum }, name::Symbol, val)
end


text:
include("pf_SQMC.jl")
include("plotsAndTests.jl")
include("sobol.jl")

const Δt = 0.02
#The size of the random acceleration
const σa = 10.0 #m/s^2
#The size of the random change in ϕ
const σϕ = 0.5
#The size of the random change in β
const σβ = 0.05
#The size of the noise on acceleration measurements
const σam = .1
const σym = .1
#Wavelength in meters
const λ = 0.13

# State x = [pₓ, vₓ , ϕ₁, ϕ₂, β₁, β₂, r₁, r₂, a]
# Noise u = [a, ϕ₁, ϕ₂, β₁, β₂, ny1, ny2, na]
# Out   y₁ = ∑rₖe^(iβₖ)e^(i2π<pₖ,u(ϕₖ)>)+ny
#       y₂ = a + na

#OBS LET NOISE BE NORMAL
@inbounds function signalUpdate!(x, t, n, xt, i)
  a = n[1]
  py = 0
  u(v) = [-sin(v) cos(v)]'
  xt[1] = x[1] + Δt*x[2] + Δt^2/2*a     #p⁺ = p + Δt*v + Δt²/2*a
  xt[2] = x[2] + Δt*a                   #v⁺ = v + Δt*a
  #xt[3] = x[3] + Δt*n[2]                  #ϕ₁⁺= ϕ₁ + Δt*nϕ₁
  #xt[4] = x[4] + Δt*n[3]                  #ϕ₂⁺= ϕ₂ + Δt*nϕ₂
  xt[3:4] = x[3:4] + Δt*σϕ*n[2:3]
  #xt[5] = x[5] - (u(xt[3])-u(x[3]))*[x[1]; py] #β₁⁺= β₁ - <p,u(ϕ₁⁺)-u(ϕ₁)> + nβ₁
  #xt[6] = x[6] - (u(xt[4])-u(x[4]))*[x[1]; py] #β₂⁺= β₂ - <p,u(ϕ₂⁺)-u(ϕ₂)> + nβ₂
  #xt[5:6] = x[5:6] - (u(xt[3:4])-u(x[3:4]))*[x[1]; py] + Δt*σβ*n[4:5]
  xt[5:6] = x[5:6] - (-sin(xt[3:4])+sin(x[3:4]))*x[1] + Δt*σβ*n[4:5]
  xt[7:8] = x[7:8]
  xt[9] = a
  return
end

@inbounds function signalUpdateOld!(x, t, n, xt, i)
  a = n[1]
  py = 0
  xt[1] = x[1] + Δt*x[2] + Δt^2/2*a
  xt[2] = x[2] + Δt*n[1]
  xt[3:4] = x[3:4] + Δt*σϕ*n[2:3]
  xt[5:6] = x[5:6] + Δt*σβ*n[4:5]
  xt[7:8] = x[7:8]
  xt[9] = a
  return
end

@inbounds function signalOut(x, t, n, y)
  signalOutNoNoise(x, t, y)
  y[1] += σym*n[6]
  y[2] += σym*n[7]
  y[3] += σam*n[8]
  return
end

function signalOutNoNoise(x, t, y)
  ϕi, βi, ri, ai = 3:4, 5:6, 7:8, 9
  u(v) = [-sin(v) cos(v)]'
  p = [x[1]; 0]
  complexy = sum(x[ri].*exp(2π/λ*im*x[βi]).*exp(2π/λ*im*(p'*u(x[ϕi]))'))
  y[:] = [real(complexy);
  imag(complexy);
  x[ai]]
  return
end

@inbounds function signalOutNoNoiseFast(x, t, y)
  realExp = x[5:6] - sin(x[3:4])*x[1]
  realExp *= 2π/λ
  y[1] = x[7]*cos(realExp[1])+x[8]*cos(realExp[2])
  y[2] = x[7]*sin(realExp[1])+x[8]*sin(realExp[2])
  y[3] = x[9]
  return
end

function signalpxy(yhat,y,t)
  #w = 1/sqrt(2π)*e^(-(yhat[1]-y[1])^2/2)
  #Without Aux
  #w = -(norm([yhat[1];yhat[2]]-[y[1];y[2]]))^2/(2*(σym)^2)-norm(yhat[3]-y[3])^2/(2*(σam)^2)
  #With Aux
  w = -(norm([yhat[1],yhat[2]]-[y[1],y[2]]))^2/(2*(σym)^2)#-norm(yhat[3]-y[3])^2/(2*(σam)^2)
end

function sinGen!(u, t)
  randn!(slice(u,2:size(u,1),:))
  A = 10/π
  w = 2π/10
  u[1] = -A*w^2*cos(w*Δt*t)
  return
end

#Generation of noise for particles given accelerator measurement
function randGen!(u, y, t)
  randn!(u)
  #Method 1
  #u[1,:] *= σam
  #u[1,:] += y[t]
  #Change weights too here

  #Method 2
  u[:,1] *= σam*σa/sqrt(σam^2+σa^2)
  u[:,1] += y[3,t]*σa^2/(σam^2+σa^2)
  return
end

function twoBeamsOnLineSettings(improvement = true, sinus = true)
  x0 = [0., 0, .2, .7, 0., 0. , .8, 1.2, 0]
  Ny, NuGen, NuSim = 3, 8, 5
  generator = sinus ? sinGen! : ((u,t) -> rands!(u))
  #est = (x,w,t) -> x[:,findmax(w)[2]]
  est = (x,w,t) -> sum(x.*exp(w'),2)
  f = improvement ? signalUpdate! : signalUpdateOld!
  FilterSettings(f, signalOutNoNoiseFast, signalOut,
    signalpxy, Ny, generator, (randGen!, :aux), x0, NuGen, NuSim, est)
end


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

mutable struct AdditionalUnattendContent <: SwaggerModel
    passName::Any # spec type: Union{ Nothing, String } # spec name: passName
    componentName::Any # spec type: Union{ Nothing, String } # spec name: componentName
    settingName::Any # spec type: Union{ Nothing, String } # spec name: settingName
    content::Any # spec type: Union{ Nothing, String } # spec name: content

    function AdditionalUnattendContent(;passName=nothing, componentName=nothing, settingName=nothing, content=nothing)
        o = new()
        validate_property(AdditionalUnattendContent, Symbol("passName"), passName)
        setfield!(o, Symbol("passName"), passName)
        validate_property(AdditionalUnattendContent, Symbol("componentName"), componentName)
        setfield!(o, Symbol("componentName"), componentName)
        validate_property(AdditionalUnattendContent, Symbol("settingName"), settingName)
        setfield!(o, Symbol("settingName"), settingName)
        validate_property(AdditionalUnattendContent, Symbol("content"), content)
        setfield!(o, Symbol("content"), content)
        o
    end
end # type AdditionalUnattendContent

const _property_map_AdditionalUnattendContent = Dict{Symbol,Symbol}(Symbol("passName")=>Symbol("passName"), Symbol("componentName")=>Symbol("componentName"), Symbol("settingName")=>Symbol("settingName"), Symbol("content")=>Symbol("content"))
const _property_types_AdditionalUnattendContent = Dict{Symbol,String}(Symbol("passName")=>"String", Symbol("componentName")=>"String", Symbol("settingName")=>"String", Symbol("content")=>"String")
Base.propertynames(::Type{ AdditionalUnattendContent }) = collect(keys(_property_map_AdditionalUnattendContent))
Swagger.property_type(::Type{ AdditionalUnattendContent }, name::Symbol) = Union{Nothing,eval(Meta.parse(_property_types_AdditionalUnattendContent[name]))}
Swagger.field_name(::Type{ AdditionalUnattendContent }, property_name::Symbol) =  _property_map_AdditionalUnattendContent[property_name]

const _allowed_AdditionalUnattendContent_passName = ["OobeSystem"]

const _allowed_AdditionalUnattendContent_componentName = ["Microsoft-Windows-Shell-Setup"]

const _allowed_AdditionalUnattendContent_settingName = ["AutoLogon", "FirstLogonCommands"]

function check_required(o::AdditionalUnattendContent)
    true
end

function validate_property(::Type{ AdditionalUnattendContent }, name::Symbol, val)
    if name === Symbol("passName")
        Swagger.validate_param(name, "AdditionalUnattendContent", :enum, val, _allowed_AdditionalUnattendContent_passName)
    end
    if name === Symbol("componentName")
        Swagger.validate_param(name, "AdditionalUnattendContent", :enum, val, _allowed_AdditionalUnattendContent_componentName)
    end
    if name === Symbol("settingName")
        Swagger.validate_param(name, "AdditionalUnattendContent", :enum, val, _allowed_AdditionalUnattendContent_settingName)
    end
end


text:
@testset "4.1.11 (e x)^m (a+b x^n)^p sin" begin
    (a, b, c, d, x, ) = @variables a b c d x

    #= ::Package:: =#

    #= ::Title:: =#
    #=Integrands*of*the*form*(e*x)^m*(a+b*x^n)^p*sin(c+d*x)=#

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(e*x)^m*(a+b*x^1)^p*sin(c+d*x)=#

    #= ::Subsubsection::Closed:: =#
    #=p>0=#

    @test_int [x^3*(a + b*x)*sin(c + d*x), x, 11, (-24*b*cos(c + d*x))/d^5 + (6*a*x*cos(c + d*x))/d^3 + (12*b*x^2*cos(c + d*x))/d^3 - (a*x^3*cos(c + d*x))/d - (b*x^4*cos(c + d*x))/d - (6*a*sin(c + d*x))/d^4 - (24*b*x*sin(c + d*x))/d^4 + (3*a*x^2*sin(c + d*x))/d^2 + (4*b*x^3*sin(c + d*x))/d^2]
    @test_int [x^2*(a + b*x)*sin(c + d*x), x, 9, (2*a*cos(c + d*x))/d^3 + (6*b*x*cos(c + d*x))/d^3 - (a*x^2*cos(c + d*x))/d - (b*x^3*cos(c + d*x))/d - (6*b*sin(c + d*x))/d^4 + (2*a*x*sin(c + d*x))/d^2 + (3*b*x^2*sin(c + d*x))/d^2]
    @test_int [x*(a + b*x)*sin(c + d*x), x, 7, (2*b*cos(c + d*x))/d^3 - (a*x*cos(c + d*x))/d - (b*x^2*cos(c + d*x))/d + (a*sin(c + d*x))/d^2 + (2*b*x*sin(c + d*x))/d^2]
    @test_int [(a + b*x)*sin(c + d*x), x, 2, -(((a + b*x)*cos(c + d*x))/d) + (b*sin(c + d*x))/d^2]
    @test_int [((a + b*x)*sin(c + d*x))/x, x, 6, -((b*cos(c + d*x))/d) + a*CosIntegral(d*x)*sin(c) + a*cos(c)*SinIntegral(d*x)]
    @test_int [((a + b*x)*sin(c + d*x))/x^2, x, 9, a*d*cos(c)*CosIntegral(d*x) + b*CosIntegral(d*x)*sin(c) - (a*sin(c + d*x))/x + b*cos(c)*SinIntegral(d*x) - a*d*sin(c)*SinIntegral(d*x)]
    @test_int [((a + b*x)*sin(c + d*x))/x^3, x, 11, -(a*d*cos(c + d*x))/(2*x) + b*d*cos(c)*CosIntegral(d*x) - (a*d^2*CosIntegral(d*x)*sin(c))/2 - (a*sin(c + d*x))/(2*x^2) - (b*sin(c + d*x))/x - (a*d^2*cos(c)*SinIntegral(d*x))/2 - b*d*sin(c)*SinIntegral(d*x)]
    @test_int [((a + b*x)*sin(c + d*x))/x^4, x, 13, -(a*d*cos(c + d*x))/(6*x^2) - (b*d*cos(c + d*x))/(2*x) - (a*d^3*cos(c)*CosIntegral(d*x))/6 - (b*d^2*CosIntegral(d*x)*sin(c))/2 - (a*sin(c + d*x))/(3*x^3) - (b*sin(c + d*x))/(2*x^2) + (a*d^2*sin(c + d*x))/(6*x) - (b*d^2*cos(c)*SinIntegral(d*x))/2 + (a*d^3*sin(c)*SinIntegral(d*x))/6]
    @test_int [((a + b*x)*sin(c + d*x))/x^5, x, 15, -(a*d*cos(c + d*x))/(12*x^3) - (b*d*cos(c + d*x))/(6*x^2) + (a*d^3*cos(c + d*x))/(24*x) - (b*d^3*cos(c)*CosIntegral(d*x))/6 + (a*d^4*CosIntegral(d*x)*sin(c))/24 - (a*sin(c + d*x))/(4*x^4) - (b*sin(c + d*x))/(3*x^3) + (a*d^2*sin(c + d*x))/(24*x^2) + (b*d^2*sin(c + d*x))/(6*x) + (a*d^4*cos(c)*SinIntegral(d*x))/24 + (b*d^3*sin(c)*SinIntegral(d*x))/6]

    @test_int [x^2*(a + b*x)^2*sin(c + d*x), x, 14, (-24*b^2*cos(c + d*x))/d^5 + (2*a^2*cos(c + d*x))/d^3 + (12*a*b*x*cos(c + d*x))/d^3 + (12*b^2*x^2*cos(c + d*x))/d^3 - (a^2*x^2*cos(c + d*x))/d - (2*a*b*x^3*cos(c + d*x))/d - (b^2*x^4*cos(c + d*x))/d - (12*a*b*sin(c + d*x))/d^4 - (24*b^2*x*sin(c + d*x))/d^4 + (2*a^2*x*sin(c + d*x))/d^2 + (6*a*b*x^2*sin(c + d*x))/d^2 + (4*b^2*x^3*sin(c + d*x))/d^2]
    @test_int [x*(a + b*x)^2*sin(c + d*x), x, 11, (4*a*b*cos(c + d*x))/d^3 + (6*b^2*x*cos(c + d*x))/d^3 - (a^2*x*cos(c + d*x))/d - (2*a*b*x^2*cos(c + d*x))/d - (b^2*x^3*cos(c + d*x))/d - (6*b^2*sin(c + d*x))/d^4 + (a^2*sin(c + d*x))/d^2 + (4*a*b*x*sin(c + d*x))/d^2 + (3*b^2*x^2*sin(c + d*x))/d^2]
    @test_int [(a + b*x)^2*sin(c + d*x), x, 3, (2*b^2*cos(c + d*x))/d^3 - ((a + b*x)^2*cos(c + d*x))/d + (2*b*(a + b*x)*sin(c + d*x))/d^2]
    @test_int [((a + b*x)^2*sin(c + d*x))/x, x, 8, (-2*a*b*cos(c + d*x))/d - (b^2*x*cos(c + d*x))/d + a^2*CosIntegral(d*x)*sin(c) + (b^2*sin(c + d*x))/d^2 + a^2*cos(c)*SinIntegral(d*x)]
    @test_int [((a + b*x)^2*sin(c + d*x))/x^2, x, 10, -((b^2*cos(c + d*x))/d) + a^2*d*cos(c)*CosIntegral(d*x) + 2*a*b*CosIntegral(d*x)*sin(c) - (a^2*sin(c + d*x))/x + 2*a*b*cos(c)*SinIntegral(d*x) - a^2*d*sin(c)*SinIntegral(d*x)]
    @test_int [((a + b*x)^2*sin(c + d*x))/x^3, x, 14, -(a^2*d*cos(c + d*x))/(2*x) + 2*a*b*d*cos(c)*CosIntegral(d*x) + b^2*CosIntegral(d*x)*sin(c) - (a^2*d^2*CosIntegral(d*x)*sin(c))/2 - (a^2*sin(c + d*x))/(2*x^2) - (2*a*b*sin(c + d*x))/x + b^2*cos(c)*SinIntegral(d*x) - (a^2*d^2*cos(c)*SinIntegral(d*x))/2 - 2*a*b*d*sin(c)*SinIntegral(d*x)]
    @test_int [((a + b*x)^2*sin(c + d*x))/x^4, x, 17, -(a^2*d*cos(c + d*x))/(6*x^2) - (a*b*d*cos(c + d*x))/x + b^2*d*cos(c)*CosIntegral(d*x) - (a^2*d^3*cos(c)*CosIntegral(d*x))/6 - a*b*d^2*CosIntegral(d*x)*sin(c) - (a^2*sin(c + d*x))/(3*x^3) - (a*b*sin(c + d*x))/x^2 - (b^2*sin(c + d*x))/x + (a^2*d^2*sin(c + d*x))/(6*x) - a*b*d^2*cos(c)*SinIntegral(d*x) - b^2*d*sin(c)*SinIntegral(d*x) + (a^2*d^3*sin(c)*SinIntegral(d*x))/6]
    @test_int [((a + b*x)^2*sin(c + d*x))/x^5, x, 20, -(a^2*d*cos(c + d*x))/(12*x^3) - (a*b*d*cos(c + d*x))/(3*x^2) - (b^2*d*cos(c + d*x))/(2*x) + (a^2*d^3*cos(c + d*x))/(24*x) - (a*b*d^3*cos(c)*CosIntegral(d*x))/3 - (b^2*d^2*CosIntegral(d*x)*sin(c))/2 + (a^2*d^4*CosIntegral(d*x)*sin(c))/24 - (a^2*sin(c + d*x))/(4*x^4) - (2*a*b*sin(c + d*x))/(3*x^3) - (b^2*sin(c + d*x))/(2*x^2) + (a^2*d^2*sin(c + d*x))/(24*x^2) + (a*b*d^2*sin(c + d*x))/(3*x) - (b^2*d^2*cos(c)*SinIntegral(d*x))/2 + (a^2*d^4*cos(c)*SinIntegral(d*x))/24 + (a*b*d^3*sin(c)*SinIntegral(d*x))/3]

    #= ::Subsubsection::Closed:: =#
    #=p<0=#

    @test_int [(x^4*sin(c + d*x))/(a + b*x), x, 15, (-2*a*cos(c + d*x))/(b^2*d^3) + (a^3*cos(c + d*x))/(b^4*d) + (6*x*cos(c + d*x))/(b*d^3) - (a^2*x*cos(c + d*x))/(b^3*d) + (a*x^2*cos(c + d*x))/(b^2*d) - (x^3*cos(c + d*x))/(b*d) + (a^4*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^5 - (6*sin(c + d*x))/(b*d^4) + (a^2*sin(c + d*x))/(b^3*d^2) - (2*a*x*sin(c + d*x))/(b^2*d^2) + (3*x^2*sin(c + d*x))/(b*d^2) + (a^4*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^5]
    @test_int [(x^3*sin(c + d*x))/(a + b*x), x, 11, (2*cos(c + d*x))/(b*d^3) - (a^2*cos(c + d*x))/(b^3*d) + (a*x*cos(c + d*x))/(b^2*d) - (x^2*cos(c + d*x))/(b*d) - (a^3*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^4 - (a*sin(c + d*x))/(b^2*d^2) + (2*x*sin(c + d*x))/(b*d^2) - (a^3*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^4]
    @test_int [(x^2*sin(c + d*x))/(a + b*x), x, 8, (a*cos(c + d*x))/(b^2*d) - (x*cos(c + d*x))/(b*d) + (a^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^3 + sin(c + d*x)/(b*d^2) + (a^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^3]
    @test_int [(x*sin(c + d*x))/(a + b*x), x, 6, -(cos(c + d*x)/(b*d)) - (a*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^2 - (a*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^2]
    @test_int [sin(c + d*x)/(a + b*x), x, 3, (CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b + (cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b]
    @test_int [sin(c + d*x)/(x*(a + b*x)), x, 8, (CosIntegral(d*x)*sin(c))/a - (CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/a + (cos(c)*SinIntegral(d*x))/a - (cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a]
    @test_int [sin(c + d*x)/(x^2*(a + b*x)), x, 12, (d*cos(c)*CosIntegral(d*x))/a - (b*CosIntegral(d*x)*sin(c))/a^2 + (b*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/a^2 - sin(c + d*x)/(a*x) - (b*cos(c)*SinIntegral(d*x))/a^2 - (d*sin(c)*SinIntegral(d*x))/a + (b*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^2]
    @test_int [sin(c + d*x)/(x^3*(a + b*x)), x, 17, -(d*cos(c + d*x))/(2*a*x) - (b*d*cos(c)*CosIntegral(d*x))/a^2 + (b^2*CosIntegral(d*x)*sin(c))/a^3 - (d^2*CosIntegral(d*x)*sin(c))/(2*a) - (b^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/a^3 - sin(c + d*x)/(2*a*x^2) + (b*sin(c + d*x))/(a^2*x) + (b^2*cos(c)*SinIntegral(d*x))/a^3 - (d^2*cos(c)*SinIntegral(d*x))/(2*a) + (b*d*sin(c)*SinIntegral(d*x))/a^2 - (b^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^3]

    @test_int [(x^4*sin(c + d*x))/(a + b*x)^2, x, 15, (2*cos(c + d*x))/(b^2*d^3) - (3*a^2*cos(c + d*x))/(b^4*d) + (2*a*x*cos(c + d*x))/(b^3*d) - (x^2*cos(c + d*x))/(b^2*d) + (a^4*d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/b^6 - (4*a^3*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^5 - (2*a*sin(c + d*x))/(b^3*d^2) + (2*x*sin(c + d*x))/(b^2*d^2) - (a^4*sin(c + d*x))/(b^5*(a + b*x)) - (4*a^3*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^5 - (a^4*d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^6]
    @test_int [(x^3*sin(c + d*x))/(a + b*x)^2, x, 12, (2*a*cos(c + d*x))/(b^3*d) - (x*cos(c + d*x))/(b^2*d) - (a^3*d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/b^5 + (3*a^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^4 + sin(c + d*x)/(b^2*d^2) + (a^3*sin(c + d*x))/(b^4*(a + b*x)) + (3*a^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^4 + (a^3*d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^5]
    @test_int [(x^2*sin(c + d*x))/(a + b*x)^2, x, 10, -(cos(c + d*x)/(b^2*d)) + (a^2*d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/b^4 - (2*a*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^3 - (a^2*sin(c + d*x))/(b^3*(a + b*x)) - (2*a*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^3 - (a^2*d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^4]
    @test_int [(x*sin(c + d*x))/(a + b*x)^2, x, 9, -((a*d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/b^3) + (CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^2 + (a*sin(c + d*x))/(b^2*(a + b*x)) + (cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^2 + (a*d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^3]
    @test_int [sin(c + d*x)/(a + b*x)^2, x, 4, (d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/b^2 - sin(c + d*x)/(b*(a + b*x)) - (d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^2]
    @test_int [sin(c + d*x)/(x*(a + b*x)^2), x, 12, -((d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/(a*b)) + (CosIntegral(d*x)*sin(c))/a^2 - (CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/a^2 + sin(c + d*x)/(a*(a + b*x)) + (cos(c)*SinIntegral(d*x))/a^2 - (cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^2 + (d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(a*b)]
    @test_int [sin(c + d*x)/(x^2*(a + b*x)^2), x, 16, (d*cos(c)*CosIntegral(d*x))/a^2 + (d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/a^2 - (2*b*CosIntegral(d*x)*sin(c))/a^3 + (2*b*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/a^3 - sin(c + d*x)/(a^2*x) - (b*sin(c + d*x))/(a^2*(a + b*x)) - (2*b*cos(c)*SinIntegral(d*x))/a^3 - (d*sin(c)*SinIntegral(d*x))/a^2 + (2*b*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^3 - (d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^2]

    @test_int [(x^3*sin(c + d*x))/(a + b*x)^3, x, 15, -(cos(c + d*x)/(b^3*d)) + (a^3*d*cos(c + d*x))/(2*b^5*(a + b*x)) + (3*a^2*d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/b^5 - (3*a*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^4 + (a^3*d^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/(2*b^6) + (a^3*sin(c + d*x))/(2*b^4*(a + b*x)^2) - (3*a^2*sin(c + d*x))/(b^4*(a + b*x)) - (3*a*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^4 + (a^3*d^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(2*b^6) - (3*a^2*d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^5]
    @test_int [(x^2*sin(c + d*x))/(a + b*x)^3, x, 14, -(a^2*d*cos(c + d*x))/(2*b^4*(a + b*x)) - (2*a*d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/b^4 + (CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/b^3 - (a^2*d^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/(2*b^5) - (a^2*sin(c + d*x))/(2*b^3*(a + b*x)^2) + (2*a*sin(c + d*x))/(b^3*(a + b*x)) + (cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^3 - (a^2*d^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(2*b^5) + (2*a*d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^4]
    @test_int [(x*sin(c + d*x))/(a + b*x)^3, x, 11, (a*d*cos(c + d*x))/(2*b^3*(a + b*x)) + (d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/b^3 + (a*d^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/(2*b^4) + (a*sin(c + d*x))/(2*b^2*(a + b*x)^2) - sin(c + d*x)/(b^2*(a + b*x)) + (a*d^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(2*b^4) - (d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/b^3]
    @test_int [sin(c + d*x)/(a + b*x)^3, x, 5, -(d*cos(c + d*x))/(2*b^2*(a + b*x)) - (d^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/(2*b^3) - sin(c + d*x)/(2*b*(a + b*x)^2) - (d^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(2*b^3)]
    @test_int [sin(c + d*x)/(x*(a + b*x)^3), x, 17, (d*cos(c + d*x))/(2*a*b*(a + b*x)) - (d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/(a^2*b) + (CosIntegral(d*x)*sin(c))/a^3 - (CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/a^3 + (d^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/(2*a*b^2) + sin(c + d*x)/(2*a*(a + b*x)^2) + sin(c + d*x)/(a^2*(a + b*x)) + (cos(c)*SinIntegral(d*x))/a^3 - (cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^3 + (d^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(2*a*b^2) + (d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(a^2*b)]
    @test_int [sin(c + d*x)/(x^2*(a + b*x)^3), x, 21, -(d*cos(c + d*x))/(2*a^2*(a + b*x)) + (d*cos(c)*CosIntegral(d*x))/a^3 + (2*d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/a^3 - (3*b*CosIntegral(d*x)*sin(c))/a^4 + (3*b*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/a^4 - (d^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/(2*a^2*b) - sin(c + d*x)/(a^3*x) - (b*sin(c + d*x))/(2*a^2*(a + b*x)^2) - (2*b*sin(c + d*x))/(a^3*(a + b*x)) - (3*b*cos(c)*SinIntegral(d*x))/a^4 - (d*sin(c)*SinIntegral(d*x))/a^3 + (3*b*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^4 - (d^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(2*a^2*b) - (2*d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^3]
    @test_int [sin(c + d*x)/(x^3*(a + b*x)^3), x, 26, -(d*cos(c + d*x))/(2*a^3*x) + (b*d*cos(c + d*x))/(2*a^3*(a + b*x)) - (3*b*d*cos(c)*CosIntegral(d*x))/a^4 - (3*b*d*cos(c - (a*d)/b)*CosIntegral((a*d)/b + d*x))/a^4 + (6*b^2*CosIntegral(d*x)*sin(c))/a^5 - (d^2*CosIntegral(d*x)*sin(c))/(2*a^3) - (6*b^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/a^5 + (d^2*CosIntegral((a*d)/b + d*x)*sin(c - (a*d)/b))/(2*a^3) - sin(c + d*x)/(2*a^3*x^2) + (3*b*sin(c + d*x))/(a^4*x) + (b^2*sin(c + d*x))/(2*a^3*(a + b*x)^2) + (3*b^2*sin(c + d*x))/(a^4*(a + b*x)) + (6*b^2*cos(c)*SinIntegral(d*x))/a^5 - (d^2*cos(c)*SinIntegral(d*x))/(2*a^3) + (3*b*d*sin(c)*SinIntegral(d*x))/a^4 - (6*b^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^5 + (d^2*cos(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/(2*a^3) + (3*b*d*sin(c - (a*d)/b)*SinIntegral((a*d)/b + d*x))/a^4]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(e*x)^m*(a+b*x^2)^p*sin(c+d*x)=#

    #= ::Subsubsection::Closed:: =#
    #=p>0=#

    @test_int [x^3*(a + b*x^2)*sin(c + d*x), x, 12, (-120*b*x*cos(c + d*x))/d^5 + (6*a*x*cos(c + d*x))/d^3 + (20*b*x^3*cos(c + d*x))/d^3 - (a*x^3*cos(c + d*x))/d - (b*x^5*cos(c + d*x))/d + (120*b*sin(c + d*x))/d^6 - (6*a*sin(c + d*x))/d^4 - (60*b*x^2*sin(c + d*x))/d^4 + (3*a*x^2*sin(c + d*x))/d^2 + (5*b*x^4*sin(c + d*x))/d^2]
    @test_int [x^2*(a + b*x^2)*sin(c + d*x), x, 10, (-24*b*cos(c + d*x))/d^5 + (2*a*cos(c + d*x))/d^3 + (12*b*x^2*cos(c + d*x))/d^3 - (a*x^2*cos(c + d*x))/d - (b*x^4*cos(c + d*x))/d - (24*b*x*sin(c + d*x))/d^4 + (2*a*x*sin(c + d*x))/d^2 + (4*b*x^3*sin(c + d*x))/d^2]
    @test_int [x*(a + b*x^2)*sin(c + d*x), x, 8, (6*b*x*cos(c + d*x))/d^3 - (a*x*cos(c + d*x))/d - (b*x^3*cos(c + d*x))/d - (6*b*sin(c + d*x))/d^4 + (a*sin(c + d*x))/d^2 + (3*b*x^2*sin(c + d*x))/d^2]
    @test_int [(a + b*x^2)*sin(c + d*x), x, 6, (2*b*cos(c + d*x))/d^3 - (a*cos(c + d*x))/d - (b*x^2*cos(c + d*x))/d + (2*b*x*sin(c + d*x))/d^2]
    @test_int [((a + b*x^2)*sin(c + d*x))/x, x, 7, -((b*x*cos(c + d*x))/d) + a*CosIntegral(d*x)*sin(c) + (b*sin(c + d*x))/d^2 + a*cos(c)*SinIntegral(d*x)]
    @test_int [((a + b*x^2)*sin(c + d*x))/x^2, x, 7, -((b*cos(c + d*x))/d) + a*d*cos(c)*CosIntegral(d*x) - (a*sin(c + d*x))/x - a*d*sin(c)*SinIntegral(d*x)]
    @test_int [((a + b*x^2)*sin(c + d*x))/x^3, x, 10, -(a*d*cos(c + d*x))/(2*x) + b*CosIntegral(d*x)*sin(c) - (a*d^2*CosIntegral(d*x)*sin(c))/2 - (a*sin(c + d*x))/(2*x^2) + b*cos(c)*SinIntegral(d*x) - (a*d^2*cos(c)*SinIntegral(d*x))/2]
    @test_int [((a + b*x^2)*sin(c + d*x))/x^4, x, 12, -(a*d*cos(c + d*x))/(6*x^2) + b*d*cos(c)*CosIntegral(d*x) - (a*d^3*cos(c)*CosIntegral(d*x))/6 - (a*sin(c + d*x))/(3*x^3) - (b*sin(c + d*x))/x + (a*d^2*sin(c + d*x))/(6*x) - b*d*sin(c)*SinIntegral(d*x) + (a*d^3*sin(c)*SinIntegral(d*x))/6]
    @test_int [((a + b*x^2)*sin(c + d*x))/x^5, x, 14, -(a*d*cos(c + d*x))/(12*x^3) - (b*d*cos(c + d*x))/(2*x) + (a*d^3*cos(c + d*x))/(24*x) - (b*d^2*CosIntegral(d*x)*sin(c))/2 + (a*d^4*CosIntegral(d*x)*sin(c))/24 - (a*sin(c + d*x))/(4*x^4) - (b*sin(c + d*x))/(2*x^2) + (a*d^2*sin(c + d*x))/(24*x^2) - (b*d^2*cos(c)*SinIntegral(d*x))/2 + (a*d^4*cos(c)*SinIntegral(d*x))/24]

    @test_int [x^2*(a + b*x^2)^2*sin(c + d*x), x, 17, (720*b^2*cos(c + d*x))/d^7 - (48*a*b*cos(c + d*x))/d^5 + (2*a^2*cos(c + d*x))/d^3 - (360*b^2*x^2*cos(c + d*x))/d^5 + (24*a*b*x^2*cos(c + d*x))/d^3 - (a^2*x^2*cos(c + d*x))/d + (30*b^2*x^4*cos(c + d*x))/d^3 - (2*a*b*x^4*cos(c + d*x))/d - (b^2*x^6*cos(c + d*x))/d + (720*b^2*x*sin(c + d*x))/d^6 - (48*a*b*x*sin(c + d*x))/d^4 + (2*a^2*x*sin(c + d*x))/d^2 - (120*b^2*x^3*sin(c + d*x))/d^4 + (8*a*b*x^3*sin(c + d*x))/d^2 + (6*b^2*x^5*sin(c + d*x))/d^2]
    @test_int [x*(a + b*x^2)^2*sin(c + d*x), x, 14, (-120*b^2*x*cos(c + d*x))/d^5 + (12*a*b*x*cos(c + d*x))/d^3 - (a^2*x*cos(c + d*x))/d + (20*b^2*x^3*cos(c + d*x))/d^3 - (2*a*b*x^3*cos(c + d*x))/d - (b^2*x^5*cos(c + d*x))/d + (120*b^2*sin(c + d*x))/d^6 - (12*a*b*sin(c + d*x))/d^4 + (a^2*sin(c + d*x))/d^2 - (60*b^2*x^2*sin(c + d*x))/d^4 + (6*a*b*x^2*sin(c + d*x))/d^2 + (5*b^2*x^4*sin(c + d*x))/d^2]
    @test_int [(a + b*x^2)^2*sin(c + d*x), x, 11, (-24*b^2*cos(c + d*x))/d^5 + (4*a*b*cos(c + d*x))/d^3 - (a^2*cos(c + d*x))/d + (12*b^2*x^2*cos(c + d*x))/d^3 - (2*a*b*x^2*cos(c + d*x))/d - (b^2*x^4*cos(c + d*x))/d - (24*b^2*x*sin(c + d*x))/d^4 + (4*a*b*x*sin(c + d*x))/d^2 + (4*b^2*x^3*sin(c + d*x))/d^2]
    @test_int [((a + b*x^2)^2*sin(c + d*x))/x, x, 11, (6*b^2*x*cos(c + d*x))/d^3 - (2*a*b*x*cos(c + d*x))/d - (b^2*x^3*cos(c + d*x))/d + a^2*CosIntegral(d*x)*sin(c) - (6*b^2*sin(c + d*x))/d^4 + (2*a*b*sin(c + d*x))/d^2 + (3*b^2*x^2*sin(c + d*x))/d^2 + a^2*cos(c)*SinIntegral(d*x)]
    @test_int [((a + b*x^2)^2*sin(c + d*x))/x^2, x, 10, (2*b^2*cos(c + d*x))/d^3 - (2*a*b*cos(c + d*x))/d - (b^2*x^2*cos(c + d*x))/d + a^2*d*cos(c)*CosIntegral(d*x) - (a^2*sin(c + d*x))/x + (2*b^2*x*sin(c + d*x))/d^2 - a^2*d*sin(c)*SinIntegral(d*x)]
    @test_int [((a + b*x^2)^2*sin(c + d*x))/x^3, x, 12, -(a^2*d*cos(c + d*x))/(2*x) - (b^2*x*cos(c + d*x))/d + 2*a*b*CosIntegral(d*x)*sin(c) - (a^2*d^2*CosIntegral(d*x)*sin(c))/2 + (b^2*sin(c + d*x))/d^2 - (a^2*sin(c + d*x))/(2*x^2) + 2*a*b*cos(c)*SinIntegral(d*x) - (a^2*d^2*cos(c)*SinIntegral(d*x))/2]
    @test_int [((a + b*x^2)^2*sin(c + d*x))/x^4, x, 13, -((b^2*cos(c + d*x))/d) - (a^2*d*cos(c + d*x))/(6*x^2) + 2*a*b*d*cos(c)*CosIntegral(d*x) - (a^2*d^3*cos(c)*CosIntegral(d*x))/6 - (a^2*sin(c + d*x))/(3*x^3) - (2*a*b*sin(c + d*x))/x + (a^2*d^2*sin(c + d*x))/(6*x) - 2*a*b*d*sin(c)*SinIntegral(d*x) + (a^2*d^3*sin(c)*SinIntegral(d*x))/6]
    @test_int [((a + b*x^2)^2*sin(c + d*x))/x^5, x, 17, -(a^2*d*cos(c + d*x))/(12*x^3) - (a*b*d*cos(c + d*x))/x + (a^2*d^3*cos(c + d*x))/(24*x) + b^2*CosIntegral(d*x)*sin(c) - a*b*d^2*CosIntegral(d*x)*sin(c) + (a^2*d^4*CosIntegral(d*x)*sin(c))/24 - (a^2*sin(c + d*x))/(4*x^4) - (a*b*sin(c + d*x))/x^2 + (a^2*d^2*sin(c + d*x))/(24*x^2) + b^2*cos(c)*SinIntegral(d*x) - a*b*d^2*cos(c)*SinIntegral(d*x) + (a^2*d^4*cos(c)*SinIntegral(d*x))/24]

    #= ::Subsubsection::Closed:: =#
    #=p<0=#

    @test_int [(x^4*sin(c + d*x))/(a + b*x^2), x, 14, (2*cos(c + d*x))/(b*d^3) + (a*cos(c + d*x))/(b^2*d) - (x^2*cos(c + d*x))/(b*d) - ((-a)^(3/2)*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*b^(5/2)) + ((-a)^(3/2)*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*b^(5/2)) + (2*x*sin(c + d*x))/(b*d^2) - ((-a)^(3/2)*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*b^(5/2)) - ((-a)^(3/2)*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*b^(5/2))]
    @test_int [(x^3*sin(c + d*x))/(a + b*x^2), x, 12, -((x*cos(c + d*x))/(b*d)) - (a*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*b^2) - (a*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*b^2) + sin(c + d*x)/(b*d^2) + (a*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*b^2) - (a*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*b^2)]
    @test_int [(x^2*sin(c + d*x))/(a + b*x^2), x, 11, -(cos(c + d*x)/(b*d)) - (sqrt(-a)*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*b^(3/2)) + (sqrt(-a)*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*b^(3/2)) - (sqrt(-a)*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*b^(3/2)) - (sqrt(-a)*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*b^(3/2))]
    @test_int [(x*sin(c + d*x))/(a + b*x^2), x, 8, (CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*b) + (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*b) - (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*b) + (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*b)]
    @test_int [sin(c + d*x)/(a + b*x^2), x, 8, -(CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*sqrt(-a)*sqrt(b)) + (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*sqrt(-a)*sqrt(b)) - (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*sqrt(-a)*sqrt(b)) - (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*sqrt(-a)*sqrt(b))]
    @test_int [sin(c + d*x)/(x*(a + b*x^2)), x, 13, (CosIntegral(d*x)*sin(c))/a - (CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*a) - (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*a) + (cos(c)*SinIntegral(d*x))/a + (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*a) - (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*a)]
    @test_int [sin(c + d*x)/(x^2*(a + b*x^2)), x, 14, (d*cos(c)*CosIntegral(d*x))/a - (sqrt(b)*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*(-a)^(3/2)) + (sqrt(b)*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*(-a)^(3/2)) - sin(c + d*x)/(a*x) - (d*sin(c)*SinIntegral(d*x))/a - (sqrt(b)*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*(-a)^(3/2)) - (sqrt(b)*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*(-a)^(3/2))]
    @test_int [sin(c + d*x)/(x^3*(a + b*x^2)), x, 18, -(d*cos(c + d*x))/(2*a*x) - (b*CosIntegral(d*x)*sin(c))/a^2 - (d^2*CosIntegral(d*x)*sin(c))/(2*a) + (b*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*a^2) + (b*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*a^2) - sin(c + d*x)/(2*a*x^2) - (b*cos(c)*SinIntegral(d*x))/a^2 - (d^2*cos(c)*SinIntegral(d*x))/(2*a) - (b*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*a^2) + (b*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*a^2)]

    @test_int [(x^4*sin(c + d*x))/(a + b*x^2)^2, x, 24, -(cos(c + d*x)/(b^2*d)) - (a*d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*b^3) - (a*d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*b^3) - (3*sqrt(-a)*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(4*b^(5/2)) + (3*sqrt(-a)*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(4*b^(5/2)) + (x*sin(c + d*x))/(2*b^2) - (x^3*sin(c + d*x))/(2*b*(a + b*x^2)) - (3*sqrt(-a)*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*b^(5/2)) - (a*d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*b^3) - (3*sqrt(-a)*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*b^(5/2)) + (a*d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*b^3)]
    @test_int [(x^3*sin(c + d*x))/(a + b*x^2)^2, x, 20, (sqrt(-a)*d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*b^(5/2)) - (sqrt(-a)*d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*b^(5/2)) + (CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*b^2) + (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*b^2) + sin(c + d*x)/(2*b^2) - (x^2*sin(c + d*x))/(2*b*(a + b*x^2)) - (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*b^2) + (sqrt(-a)*d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*b^(5/2)) + (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*b^2) + (sqrt(-a)*d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*b^(5/2))]
    @test_int [(x^2*sin(c + d*x))/(a + b*x^2)^2, x, 17, (d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*b^2) + (d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*b^2) - (CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(4*sqrt(-a)*b^(3/2)) + (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(4*sqrt(-a)*b^(3/2)) - (x*sin(c + d*x))/(2*b*(a + b*x^2)) - (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*sqrt(-a)*b^(3/2)) + (d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*b^2) - (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*sqrt(-a)*b^(3/2)) - (d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*b^2)]
    @test_int [(x*sin(c + d*x))/(a + b*x^2)^2, x, 9, (d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*sqrt(-a)*b^(3/2)) - (d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*sqrt(-a)*b^(3/2)) - sin(c + d*x)/(2*b*(a + b*x^2)) + (d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*sqrt(-a)*b^(3/2)) + (d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*sqrt(-a)*b^(3/2))]
    @test_int [sin(c + d*x)/(a + b*x^2)^2, x, 18, -(d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*a*b) - (d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*a*b) + (CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(4*(-a)^(3/2)*sqrt(b)) - (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(4*(-a)^(3/2)*sqrt(b)) - sin(c + d*x)/(4*a*sqrt(b)*(sqrt(-a) - sqrt(b)*x)) + sin(c + d*x)/(4*a*sqrt(b)*(sqrt(-a) + sqrt(b)*x)) + (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*(-a)^(3/2)*sqrt(b)) - (d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*a*b) + (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*(-a)^(3/2)*sqrt(b)) + (d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*a*b)]
    @test_int [sin(c + d*x)/(x*(a + b*x^2)^2), x, 22, (d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*(-a)^(3/2)*sqrt(b)) - (d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*(-a)^(3/2)*sqrt(b)) + (CosIntegral(d*x)*sin(c))/a^2 - (CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*a^2) - (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*a^2) + sin(c + d*x)/(2*a*(a + b*x^2)) + (cos(c)*SinIntegral(d*x))/a^2 + (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*a^2) + (d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*(-a)^(3/2)*sqrt(b)) - (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*a^2) + (d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*(-a)^(3/2)*sqrt(b))]
    @test_int [sin(c + d*x)/(x^2*(a + b*x^2)^2), x, 32, (d*cos(c)*CosIntegral(d*x))/a^2 + (d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*a^2) + (d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*a^2) + (3*sqrt(b)*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(4*(-a)^(5/2)) - (3*sqrt(b)*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(4*(-a)^(5/2)) - sin(c + d*x)/(a^2*x) + (sqrt(b)*sin(c + d*x))/(4*a^2*(sqrt(-a) - sqrt(b)*x)) - (sqrt(b)*sin(c + d*x))/(4*a^2*(sqrt(-a) + sqrt(b)*x)) - (d*sin(c)*SinIntegral(d*x))/a^2 + (3*sqrt(b)*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*(-a)^(5/2)) + (d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(4*a^2) + (3*sqrt(b)*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*(-a)^(5/2)) - (d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(4*a^2)]

    @test_int [(x^3*sin(c + d*x))/(a + b*x^2)^3, x, 27, -(d*x*cos(c + d*x))/(8*b^2*(a + b*x^2)) + (3*d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*sqrt(-a)*b^(5/2)) - (3*d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*sqrt(-a)*b^(5/2)) - (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*b^3) - (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*b^3) - (x^2*sin(c + d*x))/(4*b*(a + b*x^2)^2) - sin(c + d*x)/(4*b^2*(a + b*x^2)) + (d^2*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*b^3) + (3*d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*sqrt(-a)*b^(5/2)) - (d^2*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*b^3) + (3*d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*sqrt(-a)*b^(5/2))]
    @test_int [(x^2*sin(c + d*x))/(a + b*x^2)^3, x, 28, -(d*cos(c + d*x))/(8*b^2*(a + b*x^2)) - (d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a*b^2) - (d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a*b^2) + (CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(3/2)*b^(3/2)) + (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*sqrt(-a)*b^(5/2)) - (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(3/2)*b^(3/2)) - (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*sqrt(-a)*b^(5/2)) - sin(c + d*x)/(16*a*b^(3/2)*(sqrt(-a) - sqrt(b)*x)) + sin(c + d*x)/(16*a*b^(3/2)*(sqrt(-a) + sqrt(b)*x)) - (x*sin(c + d*x))/(4*b*(a + b*x^2)^2) + (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(3/2)*b^(3/2)) + (d^2*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*sqrt(-a)*b^(5/2)) - (d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a*b^2) + (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(3/2)*b^(3/2)) + (d^2*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*sqrt(-a)*b^(5/2)) + (d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a*b^2)]
    @test_int [(x*sin(c + d*x))/(a + b*x^2)^3, x, 19, -(d*cos(c + d*x))/(16*a*b^(3/2)*(sqrt(-a) - sqrt(b)*x)) + (d*cos(c + d*x))/(16*a*b^(3/2)*(sqrt(-a) + sqrt(b)*x)) - (d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(3/2)*b^(3/2)) + (d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(3/2)*b^(3/2)) + (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*a*b^2) + (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*a*b^2) - sin(c + d*x)/(4*b*(a + b*x^2)^2) - (d^2*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a*b^2) - (d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(3/2)*b^(3/2)) + (d^2*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a*b^2) - (d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(3/2)*b^(3/2))]
    @test_int [sin(c + d*x)/(a + b*x^2)^3, x, 28, (d*cos(c + d*x))/(16*(-a)^(3/2)*b*(sqrt(-a) - sqrt(b)*x)) + (d*cos(c + d*x))/(16*(-a)^(3/2)*b*(sqrt(-a) + sqrt(b)*x)) - (3*d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a^2*b) - (3*d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a^2*b) - (3*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(5/2)*sqrt(b)) + (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(3/2)*b^(3/2)) + (3*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(5/2)*sqrt(b)) - (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(3/2)*b^(3/2)) - sin(c + d*x)/(16*(-a)^(3/2)*sqrt(b)*(sqrt(-a) - sqrt(b)*x)^2) - (3*sin(c + d*x))/(16*a^2*sqrt(b)*(sqrt(-a) - sqrt(b)*x)) + sin(c + d*x)/(16*(-a)^(3/2)*sqrt(b)*(sqrt(-a) + sqrt(b)*x)^2) + (3*sin(c + d*x))/(16*a^2*sqrt(b)*(sqrt(-a) + sqrt(b)*x)) - (3*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(5/2)*sqrt(b)) + (d^2*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(3/2)*b^(3/2)) - (3*d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a^2*b) - (3*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(5/2)*sqrt(b)) + (d^2*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(3/2)*b^(3/2)) + (3*d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a^2*b)]
    @test_int [sin(c + d*x)/(x*(a + b*x^2)^3), x, 41, (d*cos(c + d*x))/(16*a^2*sqrt(b)*(sqrt(-a) - sqrt(b)*x)) - (d*cos(c + d*x))/(16*a^2*sqrt(b)*(sqrt(-a) + sqrt(b)*x)) - (5*d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(5/2)*sqrt(b)) + (5*d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(5/2)*sqrt(b)) + (CosIntegral(d*x)*sin(c))/a^3 - (CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*a^3) - (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*a^2*b) - (CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*a^3) - (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*a^2*b) + sin(c + d*x)/(4*a*(a + b*x^2)^2) + sin(c + d*x)/(2*a^2*(a + b*x^2)) + (cos(c)*SinIntegral(d*x))/a^3 + (cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*a^3) + (d^2*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a^2*b) - (5*d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(5/2)*sqrt(b)) - (cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*a^3) - (d^2*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a^2*b) - (5*d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(5/2)*sqrt(b))]
    @test_int [sin(c + d*x)/(x^2*(a + b*x^2)^3), x, 60, (d*cos(c + d*x))/(16*(-a)^(5/2)*(sqrt(-a) - sqrt(b)*x)) + (d*cos(c + d*x))/(16*(-a)^(5/2)*(sqrt(-a) + sqrt(b)*x)) + (d*cos(c)*CosIntegral(d*x))/a^3 + (7*d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a^3) + (7*d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a^3) - (15*sqrt(b)*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(7/2)) + (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(5/2)*sqrt(b)) + (15*sqrt(b)*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(7/2)) - (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*(-a)^(5/2)*sqrt(b)) - sin(c + d*x)/(a^3*x) - (sqrt(b)*sin(c + d*x))/(16*(-a)^(5/2)*(sqrt(-a) - sqrt(b)*x)^2) + (7*sqrt(b)*sin(c + d*x))/(16*a^3*(sqrt(-a) - sqrt(b)*x)) + (sqrt(b)*sin(c + d*x))/(16*(-a)^(5/2)*(sqrt(-a) + sqrt(b)*x)^2) - (7*sqrt(b)*sin(c + d*x))/(16*a^3*(sqrt(-a) + sqrt(b)*x)) - (d*sin(c)*SinIntegral(d*x))/a^3 - (15*sqrt(b)*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(7/2)) + (d^2*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(5/2)*sqrt(b)) + (7*d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a^3) - (15*sqrt(b)*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(7/2)) + (d^2*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(5/2)*sqrt(b)) - (7*d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a^3)]
    @test_int [sin(c + d*x)/(x^3*(a + b*x^2)^3), x, 46, -(d*cos(c + d*x))/(2*a^3*x) - (sqrt(b)*d*cos(c + d*x))/(16*a^3*(sqrt(-a) - sqrt(b)*x)) + (sqrt(b)*d*cos(c + d*x))/(16*a^3*(sqrt(-a) + sqrt(b)*x)) - (9*sqrt(b)*d*cos(c + (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(7/2)) + (9*sqrt(b)*d*cos(c - (sqrt(-a)*d)/sqrt(b))*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(7/2)) - (3*b*CosIntegral(d*x)*sin(c))/a^4 - (d^2*CosIntegral(d*x)*sin(c))/(2*a^3) + (3*b*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(2*a^4) + (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) + d*x)*sin(c - (sqrt(-a)*d)/sqrt(b)))/(16*a^3) + (3*b*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(2*a^4) + (d^2*CosIntegral((sqrt(-a)*d)/sqrt(b) - d*x)*sin(c + (sqrt(-a)*d)/sqrt(b)))/(16*a^3) - sin(c + d*x)/(2*a^3*x^2) - (b*sin(c + d*x))/(4*a^2*(a + b*x^2)^2) - (b*sin(c + d*x))/(a^3*(a + b*x^2)) - (3*b*cos(c)*SinIntegral(d*x))/a^4 - (d^2*cos(c)*SinIntegral(d*x))/(2*a^3) - (3*b*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(2*a^4) - (d^2*cos(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*a^3) - (9*sqrt(b)*d*sin(c + (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) - d*x))/(16*(-a)^(7/2)) + (3*b*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(2*a^4) + (d^2*cos(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*a^3) - (9*sqrt(b)*d*sin(c - (sqrt(-a)*d)/sqrt(b))*SinIntegral((sqrt(-a)*d)/sqrt(b) + d*x))/(16*(-a)^(7/2))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(e*x)^m*(a+b*x^3)^p*sin(c+d*x)=#

    #= ::Subsubsection::Closed:: =#
    #=p>0=#

    @test_int [x^3*(a + b*x^3)*sin(c + d*x), x, 13, (720*b*cos(c + d*x))/d^7 + (6*a*x*cos(c + d*x))/d^3 - (360*b*x^2*cos(c + d*x))/d^5 - (a*x^3*cos(c + d*x))/d + (30*b*x^4*cos(c + d*x))/d^3 - (b*x^6*cos(c + d*x))/d - (6*a*sin(c + d*x))/d^4 + (720*b*x*sin(c + d*x))/d^6 + (3*a*x^2*sin(c + d*x))/d^2 - (120*b*x^3*sin(c + d*x))/d^4 + (6*b*x^5*sin(c + d*x))/d^2]
    @test_int [x^2*(a + b*x^3)*sin(c + d*x), x, 11, (2*a*cos(c + d*x))/d^3 - (120*b*x*cos(c + d*x))/d^5 - (a*x^2*cos(c + d*x))/d + (20*b*x^3*cos(c + d*x))/d^3 - (b*x^5*cos(c + d*x))/d + (120*b*sin(c + d*x))/d^6 + (2*a*x*sin(c + d*x))/d^2 - (60*b*x^2*sin(c + d*x))/d^4 + (5*b*x^4*sin(c + d*x))/d^2]
    @test_int [x*(a + b*x^3)*sin(c + d*x), x, 9, (-24*b*cos(c + d*x))/d^5 - (a*x*cos(c + d*x))/d + (12*b*x^2*cos(c + d*x))/d^3 - (b*x^4*cos(c + d*x))/d + (a*sin(c + d*x))/d^2 - (24*b*x*sin(c + d*x))/d^4 + (4*b*x^3*sin(c + d*x))/d^2]
    @test_int [(a + b*x^3)*sin(c + d*x), x, 7, -((a*cos(c + d*x))/d) + (6*b*x*cos(c + d*x))/d^3 - (b*x^3*cos(c + d*x))/d - (6*b*sin(c + d*x))/d^4 + (3*b*x^2*sin(c + d*x))/d^2]
    @test_int [((a + b*x^3)*sin(c + d*x))/x, x, 8, (2*b*cos(c + d*x))/d^3 - (b*x^2*cos(c + d*x))/d + a*CosIntegral(d*x)*sin(c) + (2*b*x*sin(c + d*x))/d^2 + a*cos(c)*SinIntegral(d*x)]
    @test_int [((a + b*x^3)*sin(c + d*x))/x^2, x, 8, -((b*x*cos(c + d*x))/d) + a*d*cos(c)*CosIntegral(d*x) + (b*sin(c + d*x))/d^2 - (a*sin(c + d*x))/x - a*d*sin(c)*SinIntegral(d*x)]
    @test_int [((a + b*x^3)*sin(c + d*x))/x^3, x, 8, -((b*cos(c + d*x))/d) - (a*d*cos(c + d*x))/(2*x) - (a*d^2*CosIntegral(d*x)*sin(c))/2 - (a*sin(c + d*x))/(2*x^2) - (a*d^2*cos(c)*SinIntegral(d*x))/2]
    @test_int [((a + b*x^3)*sin(c + d*x))/x^4, x, 11, -(a*d*cos(c + d*x))/(6*x^2) - (a*d^3*cos(c)*CosIntegral(d*x))/6 + b*CosIntegral(d*x)*sin(c) - (a*sin(c + d*x))/(3*x^3) + (a*d^2*sin(c + d*x))/(6*x) + b*cos(c)*SinIntegral(d*x) + (a*d^3*sin(c)*SinIntegral(d*x))/6]

    @test_int [x*(a + b*x^3)^2*sin(c + d*x), x, 17, (-48*a*b*cos(c + d*x))/d^5 + (5040*b^2*x*cos(c + d*x))/d^7 - (a^2*x*cos(c + d*x))/d + (24*a*b*x^2*cos(c + d*x))/d^3 - (840*b^2*x^3*cos(c + d*x))/d^5 - (2*a*b*x^4*cos(c + d*x))/d + (42*b^2*x^5*cos(c + d*x))/d^3 - (b^2*x^7*cos(c + d*x))/d - (5040*b^2*sin(c + d*x))/d^8 + (a^2*sin(c + d*x))/d^2 - (48*a*b*x*sin(c + d*x))/d^4 + (2520*b^2*x^2*sin(c + d*x))/d^6 + (8*a*b*x^3*sin(c + d*x))/d^2 - (210*b^2*x^4*sin(c + d*x))/d^4 + (7*b^2*x^6*sin(c + d*x))/d^2]
    @test_int [(a + b*x^3)^2*sin(c + d*x), x, 14, (720*b^2*cos(c + d*x))/d^7 - (a^2*cos(c + d*x))/d + (12*a*b*x*cos(c + d*x))/d^3 - (360*b^2*x^2*cos(c + d*x))/d^5 - (2*a*b*x^3*cos(c + d*x))/d + (30*b^2*x^4*cos(c + d*x))/d^3 - (b^2*x^6*cos(c + d*x))/d - (12*a*b*sin(c + d*x))/d^4 + (720*b^2*x*sin(c + d*x))/d^6 + (6*a*b*x^2*sin(c + d*x))/d^2 - (120*b^2*x^3*sin(c + d*x))/d^4 + (6*b^2*x^5*sin(c + d*x))/d^2]
    @test_int [((a + b*x^3)^2*sin(c + d*x))/x, x, 14, (4*a*b*cos(c + d*x))/d^3 - (120*b^2*x*cos(c + d*x))/d^5 - (2*a*b*x^2*cos(c + d*x))/d + (20*b^2*x^3*cos(c + d*x))/d^3 - (b^2*x^5*cos(c + d*x))/d + a^2*CosIntegral(d*x)*sin(c) + (120*b^2*sin(c + d*x))/d^6 + (4*a*b*x*sin(c + d*x))/d^2 - (60*b^2*x^2*sin(c + d*x))/d^4 + (5*b^2*x^4*sin(c + d*x))/d^2 + a^2*cos(c)*SinIntegral(d*x)]
    @test_int [((a + b*x^3)^2*sin(c + d*x))/x^2, x, 13, (-24*b^2*cos(c + d*x))/d^5 - (2*a*b*x*cos(c + d*x))/d + (12*b^2*x^2*cos(c + d*x))/d^3 - (b^2*x^4*cos(c + d*x))/d + a^2*d*cos(c)*CosIntegral(d*x) + (2*a*b*sin(c + d*x))/d^2 - (a^2*sin(c + d*x))/x - (24*b^2*x*sin(c + d*x))/d^4 + (4*b^2*x^3*sin(c + d*x))/d^2 - a^2*d*sin(c)*SinIntegral(d*x)]
    @test_int [((a + b*x^3)^2*sin(c + d*x))/x^3, x, 12, (-2*a*b*cos(c + d*x))/d - (a^2*d*cos(c + d*x))/(2*x) + (6*b^2*x*cos(c + d*x))/d^3 - (b^2*x^3*cos(c + d*x))/d - (a^2*d^2*CosIntegral(d*x)*sin(c))/2 - (6*b^2*sin(c + d*x))/d^4 - (a^2*sin(c + d*x))/(2*x^2) + (3*b^2*x^2*sin(c + d*x))/d^2 - (a^2*d^2*cos(c)*SinIntegral(d*x))/2]
    @test_int [((a + b*x^3)^2*sin(c + d*x))/x^4, x, 14, (2*b^2*cos(c + d*x))/d^3 - (a^2*d*cos(c + d*x))/(6*x^2) - (b^2*x^2*cos(c + d*x))/d - (a^2*d^3*cos(c)*CosIntegral(d*x))/6 + 2*a*b*CosIntegral(d*x)*sin(c) - (a^2*sin(c + d*x))/(3*x^3) + (a^2*d^2*sin(c + d*x))/(6*x) + (2*b^2*x*sin(c + d*x))/d^2 + 2*a*b*cos(c)*SinIntegral(d*x) + (a^2*d^3*sin(c)*SinIntegral(d*x))/6]
    @test_int [((a + b*x^3)^2*sin(c + d*x))/x^5, x, 15, -(a^2*d*cos(c + d*x))/(12*x^3) + (a^2*d^3*cos(c + d*x))/(24*x) - (b^2*x*cos(c + d*x))/d + 2*a*b*d*cos(c)*CosIntegral(d*x) + (a^2*d^4*CosIntegral(d*x)*sin(c))/24 + (b^2*sin(c + d*x))/d^2 - (a^2*sin(c + d*x))/(4*x^4) + (a^2*d^2*sin(c + d*x))/(24*x^2) - (2*a*b*sin(c + d*x))/x + (a^2*d^4*cos(c)*SinIntegral(d*x))/24 - 2*a*b*d*sin(c)*SinIntegral(d*x)]

    #= ::Subsubsection::Closed:: =#
    #=p<0=#

    @test_int [(x^4*sin(c + d*x))/(a + b*x^3), x, 15, -((x*cos(c + d*x))/(b*d)) + (a^(2/3)*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*b^(5/3)) + ((-1)^(2/3)*a^(2/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*b^(5/3)) - ((-1)^(1/3)*a^(2/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*b^(5/3)) + sin(c + d*x)/(b*d^2) - ((-1)^(2/3)*a^(2/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*b^(5/3)) + (a^(2/3)*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*b^(5/3)) - ((-1)^(1/3)*a^(2/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*b^(5/3))]
    @test_int [(x^3*sin(c + d*x))/(a + b*x^3), x, 14, -(cos(c + d*x)/(b*d)) - (a^(1/3)*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*b^(4/3)) + ((-1)^(1/3)*a^(1/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*b^(4/3)) - ((-1)^(2/3)*a^(1/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*b^(4/3)) - ((-1)^(1/3)*a^(1/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*b^(4/3)) - (a^(1/3)*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*b^(4/3)) - ((-1)^(2/3)*a^(1/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*b^(4/3))]
    @test_int [(x^2*sin(c + d*x))/(a + b*x^3), x, 11, (CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*b) + (CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*b) + (CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*b) - (cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*b) + (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*b) + (cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*b)]
    @test_int [(x*sin(c + d*x))/(a + b*x^3), x, 11, -((CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*a^(1/3)*b^(2/3))) - ((-1)^(2/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*a^(1/3)*b^(2/3)) + ((-1)^(1/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*a^(1/3)*b^(2/3)) + ((-1)^(2/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*a^(1/3)*b^(2/3)) - (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*a^(1/3)*b^(2/3)) + ((-1)^(1/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*a^(1/3)*b^(2/3))]
    @test_int [sin(c + d*x)/(a + b*x^3), x, 11, (CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*a^(2/3)*b^(1/3)) - ((-1)^(1/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*a^(2/3)*b^(1/3)) + ((-1)^(2/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*a^(2/3)*b^(1/3)) + ((-1)^(1/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*a^(2/3)*b^(1/3)) + (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*a^(2/3)*b^(1/3)) + ((-1)^(2/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*a^(2/3)*b^(1/3))]
    @test_int [sin(c + d*x)/(x*(a + b*x^3)), x, 16, (CosIntegral(d*x)*sin(c))/a - (CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*a) - (CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*a) - (CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*a) + (cos(c)*SinIntegral(d*x))/a + (cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*a) - (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*a) - (cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*a)]
    @test_int [sin(c + d*x)/(x^2*(a + b*x^3)), x, 17, (d*cos(c)*CosIntegral(d*x))/a + (b^(1/3)*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*a^(4/3)) + ((-1)^(2/3)*b^(1/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*a^(4/3)) - ((-1)^(1/3)*b^(1/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*a^(4/3)) - sin(c + d*x)/(a*x) - (d*sin(c)*SinIntegral(d*x))/a - ((-1)^(2/3)*b^(1/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*a^(4/3)) + (b^(1/3)*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*a^(4/3)) - ((-1)^(1/3)*b^(1/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*a^(4/3))]
    @test_int [sin(c + d*x)/(x^3*(a + b*x^3)), x, 18, -((d*cos(c + d*x))/(2*a*x)) - (d^2*CosIntegral(d*x)*sin(c))/(2*a) - (b^(2/3)*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*a^(5/3)) + ((-1)^(1/3)*b^(2/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*a^(5/3)) - ((-1)^(2/3)*b^(2/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*a^(5/3)) - sin(c + d*x)/(2*a*x^2) - (d^2*cos(c)*SinIntegral(d*x))/(2*a) - ((-1)^(1/3)*b^(2/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*a^(5/3)) - (b^(2/3)*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*a^(5/3)) - ((-1)^(2/3)*b^(2/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*a^(5/3))]

    @test_int [(x^3*sin(c + d*x))/(a + b*x^3)^2, x, 23, -(((-1)^(2/3)*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(1/3)*b^(5/3))) - (d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(1/3)*b^(5/3)) + ((-1)^(1/3)*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(1/3)*b^(5/3)) + (CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(9*a^(2/3)*b^(4/3)) - ((-1)^(1/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(2/3)*b^(4/3)) + ((-1)^(2/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(2/3)*b^(4/3)) - (x*sin(c + d*x))/(3*b*(a + b*x^3)) + ((-1)^(1/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(2/3)*b^(4/3)) - ((-1)^(2/3)*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(1/3)*b^(5/3)) + (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(2/3)*b^(4/3)) + (d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(1/3)*b^(5/3)) + ((-1)^(2/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(2/3)*b^(4/3)) - ((-1)^(1/3)*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(1/3)*b^(5/3))]
    @test_int [(x^2*sin(c + d*x))/(a + b*x^3)^2, x, 12, -(((-1)^(1/3)*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(2/3)*b^(4/3))) + (d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(2/3)*b^(4/3)) + ((-1)^(2/3)*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(2/3)*b^(4/3)) - sin(c + d*x)/(3*b*(a + b*x^3)) - ((-1)^(1/3)*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(2/3)*b^(4/3)) - (d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(2/3)*b^(4/3)) - ((-1)^(2/3)*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(2/3)*b^(4/3))]
    @test_int [(x*sin(c + d*x))/(a + b*x^3)^2, x, 34, -((d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a*b)) - (d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a*b) - (d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a*b) - (CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(9*a^(4/3)*b^(2/3)) - ((-1)^(2/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(4/3)*b^(2/3)) + ((-1)^(1/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(4/3)*b^(2/3)) + sin(c + d*x)/(3*a*b*x) - sin(c + d*x)/(3*b*x*(a + b*x^3)) + ((-1)^(2/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(4/3)*b^(2/3)) - (d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a*b) - (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(4/3)*b^(2/3)) + (d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a*b) + ((-1)^(1/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(4/3)*b^(2/3)) + (d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a*b)]
    @test_int [sin(c + d*x)/(a + b*x^3)^2, x, 36, ((-1)^(2/3)*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(4/3)*b^(2/3)) + (d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(4/3)*b^(2/3)) - ((-1)^(1/3)*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(4/3)*b^(2/3)) + (2*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(9*a^(5/3)*b^(1/3)) - (2*(-1)^(1/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(5/3)*b^(1/3)) + (2*(-1)^(2/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(5/3)*b^(1/3)) + sin(c + d*x)/(3*a*b*x^2) - sin(c + d*x)/(3*b*x^2*(a + b*x^3)) + (2*(-1)^(1/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(5/3)*b^(1/3)) + ((-1)^(2/3)*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(4/3)*b^(2/3)) + (2*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(5/3)*b^(1/3)) - (d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(4/3)*b^(2/3)) + (2*(-1)^(2/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(5/3)*b^(1/3)) + ((-1)^(1/3)*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(4/3)*b^(2/3))]
    @test_int [sin(c + d*x)/(x*(a + b*x^3)^2), x, 41, ((-1)^(1/3)*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(5/3)*b^(1/3)) - (d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(5/3)*b^(1/3)) - ((-1)^(2/3)*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(5/3)*b^(1/3)) + (CosIntegral(d*x)*sin(c))/a^2 - (CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*a^2) - (CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*a^2) - (CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*a^2) + sin(c + d*x)/(3*a*b*x^3) - sin(c + d*x)/(3*b*x^3*(a + b*x^3)) + (cos(c)*SinIntegral(d*x))/a^2 + (cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*a^2) + ((-1)^(1/3)*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(5/3)*b^(1/3)) - (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*a^2) + (d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(5/3)*b^(1/3)) - (cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*a^2) + ((-1)^(2/3)*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(5/3)*b^(1/3))]
    @test_int [sin(c + d*x)/(x^2*(a + b*x^3)^2), x, 47, (d*cos(c)*CosIntegral(d*x))/a^2 + (d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^2) + (d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^2) + (d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^2) + (4*b^(1/3)*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(9*a^(7/3)) + (4*(-1)^(2/3)*b^(1/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(7/3)) - (4*(-1)^(1/3)*b^(1/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(7/3)) + sin(c + d*x)/(3*a*b*x^4) - (4*sin(c + d*x))/(3*a^2*x) - sin(c + d*x)/(3*b*x^4*(a + b*x^3)) - (d*sin(c)*SinIntegral(d*x))/a^2 - (4*(-1)^(2/3)*b^(1/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(7/3)) + (d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^2) + (4*b^(1/3)*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)) - (d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^2) - (4*(-1)^(1/3)*b^(1/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)) - (d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^2)]
    @test_int [sin(c + d*x)/(x^3*(a + b*x^3)^2), x, 51, -((d*cos(c + d*x))/(2*a^2*x)) - ((-1)^(2/3)*b^(1/3)*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(7/3)) - (b^(1/3)*d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)) + ((-1)^(1/3)*b^(1/3)*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)) - (d^2*CosIntegral(d*x)*sin(c))/(2*a^2) - (5*b^(2/3)*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(9*a^(8/3)) + (5*(-1)^(1/3)*b^(2/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(8/3)) - (5*(-1)^(2/3)*b^(2/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(9*a^(8/3)) + sin(c + d*x)/(3*a*b*x^5) - (5*sin(c + d*x))/(6*a^2*x^2) - sin(c + d*x)/(3*b*x^5*(a + b*x^3)) - (d^2*cos(c)*SinIntegral(d*x))/(2*a^2) - (5*(-1)^(1/3)*b^(2/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(8/3)) - ((-1)^(2/3)*b^(1/3)*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(7/3)) - (5*b^(2/3)*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(8/3)) + (b^(1/3)*d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)) - (5*(-1)^(2/3)*b^(2/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(8/3)) - ((-1)^(1/3)*b^(1/3)*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3))]

    @test_int [(x^3*sin(c + d*x))/(a + b*x^3)^3, x, 71, (d*cos(c + d*x))/(18*a*b^2*x) - (d*cos(c + d*x))/(18*b^2*x*(a + b*x^3)) + (CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(27*a^(5/3)*b^(4/3)) + (d^2*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(54*a*b^2) - ((-1)^(1/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(27*a^(5/3)*b^(4/3)) + (d^2*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(54*a*b^2) + ((-1)^(2/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(27*a^(5/3)*b^(4/3)) + (d^2*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(54*a*b^2) + sin(c + d*x)/(18*a*b^2*x^2) - (x*sin(c + d*x))/(6*b*(a + b*x^3)^2) - sin(c + d*x)/(18*b^2*x^2*(a + b*x^3)) + ((-1)^(1/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^(5/3)*b^(4/3)) - (d^2*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(54*a*b^2) + (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(5/3)*b^(4/3)) + (d^2*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(54*a*b^2) + ((-1)^(2/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(5/3)*b^(4/3)) + (d^2*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(54*a*b^2)]
    @test_int [(x^2*sin(c + d*x))/(a + b*x^3)^3, x, 37, (d*cos(c + d*x))/(18*a*b^2*x^2) - (d*cos(c + d*x))/(18*b^2*x^2*(a + b*x^3)) - ((-1)^(1/3)*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^(5/3)*b^(4/3)) + (d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(5/3)*b^(4/3)) + ((-1)^(2/3)*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(5/3)*b^(4/3)) - (d^2*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(54*a^(4/3)*b^(5/3)) - ((-1)^(2/3)*d^2*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(54*a^(4/3)*b^(5/3)) + ((-1)^(1/3)*d^2*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(54*a^(4/3)*b^(5/3)) - sin(c + d*x)/(6*b*(a + b*x^3)^2) + ((-1)^(2/3)*d^2*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(54*a^(4/3)*b^(5/3)) - ((-1)^(1/3)*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^(5/3)*b^(4/3)) - (d^2*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(54*a^(4/3)*b^(5/3)) - (d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(5/3)*b^(4/3)) + ((-1)^(1/3)*d^2*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(54*a^(4/3)*b^(5/3)) - ((-1)^(2/3)*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(5/3)*b^(4/3))]
    @test_int [(x*sin(c + d*x))/(a + b*x^3)^3, x, 89, (d*cos(c + d*x))/(18*a*b^2*x^3) - (d*cos(c + d*x))/(18*b^2*x^3*(a + b*x^3)) - (2*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^2*b) - (2*d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^2*b) - (2*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^2*b) - (2*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(27*a^(7/3)*b^(2/3)) + (d^2*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(54*a^(5/3)*b^(4/3)) - (2*(-1)^(2/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(27*a^(7/3)*b^(2/3)) - ((-1)^(1/3)*d^2*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(54*a^(5/3)*b^(4/3)) + (2*(-1)^(1/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(27*a^(7/3)*b^(2/3)) + ((-1)^(2/3)*d^2*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(54*a^(5/3)*b^(4/3)) - sin(c + d*x)/(18*a*b^2*x^4) + (2*sin(c + d*x))/(9*a^2*b*x) - sin(c + d*x)/(6*b*x*(a + b*x^3)^2) + sin(c + d*x)/(18*b^2*x^4*(a + b*x^3)) + (2*(-1)^(2/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^(7/3)*b^(2/3)) + ((-1)^(1/3)*d^2*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(54*a^(5/3)*b^(4/3)) - (2*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^2*b) - (2*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(7/3)*b^(2/3)) + (d^2*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(54*a^(5/3)*b^(4/3)) + (2*d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^2*b) + (2*(-1)^(1/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(7/3)*b^(2/3)) + ((-1)^(2/3)*d^2*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(54*a^(5/3)*b^(4/3)) + (2*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^2*b)]
    @test_int [sin(c + d*x)/(a + b*x^3)^3, x, 99, (d*cos(c + d*x))/(18*a*b^2*x^4) - (d*cos(c + d*x))/(18*a^2*b*x) - (d*cos(c + d*x))/(18*b^2*x^4*(a + b*x^3)) + ((-1)^(2/3)*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(7/3)*b^(2/3)) + (d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)*b^(2/3)) - ((-1)^(1/3)*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)*b^(2/3)) + (5*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(27*a^(8/3)*b^(1/3)) - (d^2*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(54*a^2*b) - (5*(-1)^(1/3)*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(27*a^(8/3)*b^(1/3)) - (d^2*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(54*a^2*b) + (5*(-1)^(2/3)*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(27*a^(8/3)*b^(1/3)) - (d^2*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(54*a^2*b) - sin(c + d*x)/(9*a*b^2*x^5) + (5*sin(c + d*x))/(18*a^2*b*x^2) - sin(c + d*x)/(6*b*x^2*(a + b*x^3)^2) + sin(c + d*x)/(9*b^2*x^5*(a + b*x^3)) + (5*(-1)^(1/3)*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^(8/3)*b^(1/3)) + (d^2*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(54*a^2*b) + ((-1)^(2/3)*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(9*a^(7/3)*b^(2/3)) + (5*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(8/3)*b^(1/3)) - (d^2*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(54*a^2*b) - (d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)*b^(2/3)) + (5*(-1)^(2/3)*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(8/3)*b^(1/3)) - (d^2*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(54*a^2*b) + ((-1)^(1/3)*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(9*a^(7/3)*b^(2/3))]
    @test_int [sin(c + d*x)/(x*(a + b*x^3)^3), x, 110, (d*cos(c + d*x))/(18*a*b^2*x^5) - (d*cos(c + d*x))/(18*a^2*b*x^2) - (d*cos(c + d*x))/(18*b^2*x^5*(a + b*x^3)) + (4*(-1)^(1/3)*d*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^(8/3)*b^(1/3)) - (4*d*cos(c - (a^(1/3)*d)/b^(1/3))*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(8/3)*b^(1/3)) - (4*(-1)^(2/3)*d*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(8/3)*b^(1/3)) + (CosIntegral(d*x)*sin(c))/a^3 - (CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(3*a^3) + (d^2*CosIntegral((a^(1/3)*d)/b^(1/3) + d*x)*sin(c - (a^(1/3)*d)/b^(1/3)))/(54*a^(7/3)*b^(2/3)) - (CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(3*a^3) + ((-1)^(2/3)*d^2*CosIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x)*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3)))/(54*a^(7/3)*b^(2/3)) - (CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(3*a^3) - ((-1)^(1/3)*d^2*CosIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x)*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3)))/(54*a^(7/3)*b^(2/3)) - sin(c + d*x)/(6*a*b^2*x^6) + sin(c + d*x)/(3*a^2*b*x^3) - sin(c + d*x)/(6*b*x^3*(a + b*x^3)^2) + sin(c + d*x)/(6*b^2*x^6*(a + b*x^3)) + (cos(c)*SinIntegral(d*x))/a^3 + (cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(3*a^3) - ((-1)^(2/3)*d^2*cos(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(54*a^(7/3)*b^(2/3)) + (4*(-1)^(1/3)*d*sin(c + ((-1)^(1/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(1/3)*a^(1/3)*d)/b^(1/3) - d*x))/(27*a^(8/3)*b^(1/3)) - (cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(3*a^3) + (d^2*cos(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(54*a^(7/3)*b^(2/3)) + (4*d*sin(c - (a^(1/3)*d)/b^(1/3))*SinIntegral((a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(8/3)*b^(1/3)) - (cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(3*a^3) - ((-1)^(1/3)*d^2*cos(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(54*a^(7/3)*b^(2/3)) + (4*(-1)^(2/3)*d*sin(c - ((-1)^(2/3)*a^(1/3)*d)/b^(1/3))*SinIntegral(((-1)^(2/3)*a^(1/3)*d)/b^(1/3) + d*x))/(27*a^(8/3)*b^(1/3))]
    end

max_stars_repo_path: test/4 Trig functions/4.1 Sine/4.1.11 (e x)^m (a+b x^n)^p sin.jl


text: include("simplematrixsos.jl")


text:
## fem.jl ##

function GaussianRandomField(mean::Vector{<:Real}, cov::CovarianceFunction{d}, method::GaussianRandomFieldGenerator, p::Matrix{<:Real}, t::Matrix{<:Integer}; mode="nodes", kwargs...) where d
    size(p,2) == d || throw(DimensionMismatch("second dimension of points must be equal to $(d)"))
    size(t,2) == d+1 || throw(DimensionMismatch("second dimension of nodes must be equal to $(d+1)"))
	method isa CirculantEmbedding && throw(ArgumentError("cannot use circulant embedding with a finite element mesh"))

    if mode == "center"
        length(mean) == size(t,1) || throw(DimensionMismatch("size of the mean does not correspond to the dimension of the points"))
        pts = compute_centers(p,t)'
        tri = Matrix{Int}(undef,0,0)
    elseif mode == "nodes"
        length(mean) == size(p,1) || throw(DimensionMismatch("size of the mean does not correspond to the dimension of the points"))
        pts = p'
        tri = t'
    else
        throw(ArgumentError("unknown mode $(mode)"))
    end
    _GaussianRandomField(mean, cov, method, pts, tri; kwargs...)
end

GaussianRandomField(cov::CovarianceFunction, method::GaussianRandomFieldGenerator,
                    p::Matrix{<:Real}, t::Matrix{<:Integer}; kwargs...) =
                        GaussianRandomField(0, cov, method, p, t; kwargs...)

function GaussianRandomField(mean::Real, cov::CovarianceFunction, method::GaussianRandomFieldGenerator, p::Matrix{<:Real}, t::Matrix{<:Integer}; mode="nodes", kwargs...)
    T = promote_type(typeof(mean), eltype(p))
    if mode == "center"
        M = fill(convert(T, mean), size(t, 1))
    elseif mode == "nodes"
        M = fill(convert(T, mean), size(p, 1))
    else
        throw(ArgumentError("unknown mode $(mode)"))
    end
    GaussianRandomField(M, cov, method, p, t; mode=mode, kwargs...)
end

function compute_centers(p,t)
    d = size(p, 2)
    vec_t = vec(t)
    size_t = size(t)

    pts = Array{Float64}(undef, size(t, 1), d)
    @inbounds for i in 1:d
        x = reshape(p[vec_t, i], size_t)
        mean!(view(pts, :, i), x)
    end
    pts
end

shape(grf::GaussianRandomField{G,C,<:NTuple{2,AbstractMatrix}} where {G,C}) =
    size(grf.pts[1], 2)

showpoints(io::IO, points::NTuple{2,AbstractMatrix}) =
    print(io, "mesh with ", size(points[1], 2), " points and ", size(points[2], 2),
          " elements")


text:
using Dates
using YAML

"""
    import_cff(input) -> Entry
Import a CFF file and convert it to the internal bibliography format.
"""
function import_cff(input)
    # TODO decide how to treat errors
    entry, _ = BibParser.parse_file(input, :CFF)
    return entry
end

const BIB_TO_CFF_TYPES = Dict{String, String}(
    [
        "article"     => "article"
        "book"        => "book"
        "booklet"     => "pamphlet"
        "manual"      => "manual"
        "proceedings" => "proceedings"
        "unpublished" => "unpublished"
    ]
)
"""
    export_cff(e::Entry, destination::String="CITATION.cff", version::String="1.2.0", add_preferred::Bool=true) -> Dict{String, Any}

Export an `Entry` to a CFF file (default is `CITATION.cff`).
"""
function export_cff(e::Entry; destination::String="CITATION.cff", version::String="1.2.0", add_preferred::Bool=true)
    cff = Dict{String, Any}()

    # mandatory fields
    cff["authors"] = map(
        name -> Dict(
            "family-names"  => na_if_empty(name.last),
            "given-names"   => na_if_empty(name.first * name.middle),
            "name-particle" => na_if_empty(name.particle),
            "name-suffix"   => na_if_empty(name.junior)
        ),
        e.authors
    )
    cff["cff-version"] = version
    cff["message"]     = "If you use this software, please cite it using the metadata from this file."
    cff["title"]       = e.title

    cff["doi"]             = na_if_empty(e.access.doi)
    cff["repository-code"] = na_if_empty(e.access.url)
    cff["date-released"]   = "$(cff_parse_date(e.date))"

    if add_preferred
        preferred = deepcopy(cff)
        delete!(preferred, "cff-version")
        delete!(preferred, "message")

        start = split(e.in.pages, "--")
        preferred["start"]     = na_if_empty(start[1])
        preferred["end"]       = na_if_empty(length(start) == 2 ? start[2] : "")
        preferred["journal"]   = na_if_empty(e.in.journal)
        preferred["issue"]     = na_if_empty(e.in.number)
        preferred["volume"]    = na_if_empty(e.in.volume)
        publisher = Dict{String, String}()
        publisher["name"] = na_if_empty(e.in.publisher)
        preferred["publisher"] = publisher
        preferred["type"]      = get(BIB_TO_CFF_TYPES, e.type, "generic")

        cff["preferred-citation"] = preferred
    end

    YAML.write_file(destination, cff)

    return cff
end

function cff_parse_date(date::BibInternal.Date)
    Date(parse(Int, date.year), parse(Int, date.month), parse(Int, date.day))
end

"""
    na_if_empty(str::AbstractString) -> AbstractString

Use placeholder value if string param is empty.
"""
function na_if_empty(str::AbstractString)
    isempty(str) ? "N/A" : str
end


text:
using Test
using LatexLH, StructLH, ModelObjectsLH, ModelParams, CollegeEntry

ce = CollegeEntry;

# Scale in [0, 1] consistent with percentiles
function make_test_endowment_draws(J :: Integer)
    drawM = range(0.0, 1.0, length = J) * range(0.05, 0.95, length = 4)';
    return drawM
end

function CollegeEntry.retrieve_draws(draws :: Matrix{Float64}, eName)
    switches = CollegeEntry.make_test_endowpct_switches(4, true);
    eIdx = findfirst(eName .== endow_names(switches));
    return draws[:, eIdx]
end

CollegeEntry.n_draws(draws :: Matrix{Float64}) = size(draws, 1);

# Input: No of endowments to rank on.
function student_rankings_test(n :: Integer, highDrawsFirst :: Bool)
    @testset "Student rankings $n, $highDrawsFirst" begin
        switches = CollegeEntry.make_test_endowpct_switches(n, highDrawsFirst);
        # println(switches)
        @test StructLH.describe(switches) isa Matrix{String};
        @test validate_ranking_switches(switches)

        if n > 1
            nameV = endow_names(switches);
            wtV = ce.fixed_weights(switches);
            ce.set_bounds!(switches, nameV[2], wtV[2] - 2.0, wtV[2] + 2.0);
            @test validate_ranking_switches(switches);
            @test isapprox(switches.lbV[1], wtV[2] - 2.0)
        end

        st = ce.make_test_symbol_table();
        e = make_student_ranking(ObjectId(:ranking), switches, st);
        # println(e);
        @test validate_ranking(e)

        J = 5;
        draws = make_test_endowment_draws(J);
        rank_jV = rank_students(e, draws);
        @test isa(rank_jV, Vector{<: Integer})
        @test sort(rank_jV) == collect(1 : J)

        scoreV = score_students(e, draws);
        if highDrawsFirst
            @test all(diff(scoreV[rank_jV]) .< 0.0);
        else
            @test all(diff(scoreV[rank_jV]) .> 0.0);
        end

        lb, ub = range_of_scores(e);
        @test all(lb .<= scoreV .<= ub);
        scaledV = scale_scores(e, scoreV);
        @test all(0.0 .<= scaledV .<= 1.0);
	end
end

function construct_ranking_test(n :: Integer, highDrawsFirst :: Bool)
    @testset "Construct rankings $n, $highDrawsFirst" begin
        eNameV = [Symbol("endow$j")  for j = 1 : n];
        st = SymbolTable();
        for eName ∈ eNameV
            add_symbol!(st, SymbolInfo(eName, "$eName", "$eName", "Group"));
        end
        add_symbol!(st, SymbolInfo(:rankWt, "omega", "Ranking weight", "Group"));

        switches = EndowPctRankingSwitches(eNameV; highDrawsFirst = highDrawsFirst);
        @test validate_ranking_switches(switches);
        r = make_student_ranking(ObjectId(:ranking), switches, st);
        @test validate_ranking(r)
	end
end

@testset "Student rankings" begin
    for n = 1 : 3
        for highDrawsFirst ∈ (true, false)
            student_rankings_test(n, highDrawsFirst);
            construct_ranking_test(n, highDrawsFirst);
        end
    end
end

# -------------