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

@test integrate(x^3*(a+b*x)*sin(c+d*x), x) == :(-24*b*d^-5*cos(c+d*x)+-6*a*d^-4*sin(c+d*x)+-1*a*d^-1*x^3*cos(c+d*x)+-1*b*d^-1*x^4*cos(c+d*x)+-24*b*x*d^-4*sin(c+d*x)+3*a*d^-2*x^2*sin(c+d*x)+4*b*d^-2*x^3*sin(c+d*x)+6*a*x*d^-3*cos(c+d*x)+12*b*d^-3*x^2*cos(c+d*x))
@test integrate(x^2*(a+b*x)*sin(c+d*x), x) == :(-6*b*d^-4*sin(c+d*x)+2*a*d^-3*cos(c+d*x)+-1*a*d^-1*x^2*cos(c+d*x)+-1*b*d^-1*x^3*cos(c+d*x)+2*a*x*d^-2*sin(c+d*x)+3*b*d^-2*x^2*sin(c+d*x)+6*b*x*d^-3*cos(c+d*x))
@test integrate(x*(a+b*x)*sin(c+d*x), x) == :(a*d^-2*sin(c+d*x)+2*b*d^-3*cos(c+d*x)+-1*a*x*d^-1*cos(c+d*x)+-1*b*d^-1*x^2*cos(c+d*x)+2*b*x*d^-2*sin(c+d*x))
@test integrate((a+b*x)*sin(c+d*x), x) == :(b*d^-2*sin(c+d*x)+-1*d^-1*(a+b*x)*cos(c+d*x))
@test integrate(x^-1*(a+b*x)*sin(c+d*x), x) == :(a*cos(c)*sinintegral(d*x)+a*cosintegral(d*x)*sin(c)+-1*b*d^-1*cos(c+d*x))
@test integrate(x^-2*(a+b*x)*sin(c+d*x), x) == :(b*cos(c)*sinintegral(d*x)+b*cosintegral(d*x)*sin(c)+-1*a*x^-1*sin(c+d*x)+a*d*cos(c)*cosintegral(d*x)+-1*a*d*sin(c)*sinintegral(d*x))
@test integrate(x^-3*(a+b*x)*sin(c+d*x), x) == :(-1*b*x^-1*sin(c+d*x)+-1//2*a*x^-2*sin(c+d*x)+b*d*cos(c)*cosintegral(d*x)+-1*b*d*sin(c)*sinintegral(d*x)+-1//2*a*d*x^-1*cos(c+d*x)+-1//2*a*d^2*cos(c)*sinintegral(d*x)+-1//2*a*d^2*cosintegral(d*x)*sin(c))
@test integrate(x^-4*(a+b*x)*sin(c+d*x), x) == :(-1//2*b*x^-2*sin(c+d*x)+-1//3*a*x^-3*sin(c+d*x)+-1//2*b*d*x^-1*cos(c+d*x)+-1//2*b*d^2*cos(c)*sinintegral(d*x)+-1//2*b*d^2*cosintegral(d*x)*sin(c)+-1//6*a*d*x^-2*cos(c+d*x)+-1//6*a*d^3*cos(c)*cosintegral(d*x)+1//6*a*d^2*x^-1*sin(c+d*x)+1//6*a*d^3*sin(c)*sinintegral(d*x))
@test integrate(x^-5*(a+b*x)*sin(c+d*x), x) == :(-1//3*b*x^-3*sin(c+d*x)+-1//4*a*x^-4*sin(c+d*x)+-1//6*b*d*x^-2*cos(c+d*x)+-1//6*b*d^3*cos(c)*cosintegral(d*x)+-1//12*a*d*x^-3*cos(c+d*x)+1//6*b*d^2*x^-1*sin(c+d*x)+1//6*b*d^3*sin(c)*sinintegral(d*x)+1//24*a*d^2*x^-2*sin(c+d*x)+1//24*a*d^3*x^-1*cos(c+d*x)+1//24*a*d^4*cos(c)*sinintegral(d*x)+1//24*a*d^4*cosintegral(d*x)*sin(c))
@test integrate(x^2*(a+b*x)^2*sin(c+d*x), x) == :(-24*b^2*d^-5*cos(c+d*x)+2*a^2*d^-3*cos(c+d*x)+-1*a^2*d^-1*x^2*cos(c+d*x)+-1*b^2*d^-1*x^4*cos(c+d*x)+-24*x*b^2*d^-4*sin(c+d*x)+-12*a*b*d^-4*sin(c+d*x)+2*x*a^2*d^-2*sin(c+d*x)+4*b^2*d^-2*x^3*sin(c+d*x)+12*b^2*d^-3*x^2*cos(c+d*x)+-2*a*b*d^-1*x^3*cos(c+d*x)+6*a*b*d^-2*x^2*sin(c+d*x)+12*a*b*x*d^-3*cos(c+d*x))
@test integrate(x*(a+b*x)^2*sin(c+d*x), x) == :(a^2*d^-2*sin(c+d*x)+-6*b^2*d^-4*sin(c+d*x)+-1*x*a^2*d^-1*cos(c+d*x)+-1*b^2*d^-1*x^3*cos(c+d*x)+3*b^2*d^-2*x^2*sin(c+d*x)+4*a*b*d^-3*cos(c+d*x)+6*x*b^2*d^-3*cos(c+d*x)+-2*a*b*d^-1*x^2*cos(c+d*x)+4*a*b*x*d^-2*sin(c+d*x))
@test integrate((a+b*x)^2*sin(c+d*x), x) == :(-1*d^-1*(a+b*x)^2*cos(c+d*x)+2*b^2*d^-3*cos(c+d*x)+2*b*d^-2*(a+b*x)*sin(c+d*x))
@test integrate(x^-1*(a+b*x)^2*sin(c+d*x), x) == :(a^2*cos(c)*sinintegral(d*x)+a^2*cosintegral(d*x)*sin(c)+b^2*d^-2*sin(c+d*x)+-1*x*b^2*d^-1*cos(c+d*x)+-2*a*b*d^-1*cos(c+d*x))
@test integrate(x^-2*(a+b*x)^2*sin(c+d*x), x) == :(-1*a^2*x^-1*sin(c+d*x)+-1*b^2*d^-1*cos(c+d*x)+d*a^2*cos(c)*cosintegral(d*x)+-1*d*a^2*sin(c)*sinintegral(d*x)+2*a*b*cos(c)*sinintegral(d*x)+2*a*b*cosintegral(d*x)*sin(c))
@test integrate(x^-3*(a+b*x)^2*sin(c+d*x), x) == :(b^2*cos(c)*sinintegral(d*x)+b^2*cosintegral(d*x)*sin(c)+-1//2*a^2*x^-2*sin(c+d*x)+-2*a*b*x^-1*sin(c+d*x)+-1//2*d*a^2*x^-1*cos(c+d*x)+-1//2*a^2*d^2*cos(c)*sinintegral(d*x)+-1//2*a^2*d^2*cosintegral(d*x)*sin(c)+-2*a*b*d*sin(c)*sinintegral(d*x)+2*a*b*d*cos(c)*cosintegral(d*x))
@test integrate(x^-4*(a+b*x)^2*sin(c+d*x), x) == :(-1*b^2*x^-1*sin(c+d*x)+-1//3*a^2*x^-3*sin(c+d*x)+d*b^2*cos(c)*cosintegral(d*x)+-1*a*b*x^-2*sin(c+d*x)+-1*d*b^2*sin(c)*sinintegral(d*x)+-1//6*d*a^2*x^-2*cos(c+d*x)+-1//6*a^2*d^3*cos(c)*cosintegral(d*x)+1//6*a^2*d^2*x^-1*sin(c+d*x)+1//6*a^2*d^3*sin(c)*sinintegral(d*x)+-1*a*b*d*x^-1*cos(c+d*x)+-1*a*b*d^2*cos(c)*sinintegral(d*x)+-1*a*b*d^2*cosintegral(d*x)*sin(c))
@test integrate(x^-5*(a+b*x)^2*sin(c+d*x), x) == :(-1//2*b^2*x^-2*sin(c+d*x)+-1//4*a^2*x^-4*sin(c+d*x)+-2//3*a*b*x^-3*sin(c+d*x)+-1//2*d*b^2*x^-1*cos(c+d*x)+-1//2*b^2*d^2*cos(c)*sinintegral(d*x)+-1//2*b^2*d^2*cosintegral(d*x)*sin(c)+-1//12*d*a^2*x^-3*cos(c+d*x)+1//24*a^2*d^2*x^-2*sin(c+d*x)+1//24*a^2*d^3*x^-1*cos(c+d*x)+1//24*a^2*d^4*cos(c)*sinintegral(d*x)+1//24*a^2*d^4*cosintegral(d*x)*sin(c)+-1//3*a*b*d*x^-2*cos(c+d*x)+-1//3*a*b*d^3*cos(c)*cosintegral(d*x)+1//3*a*b*d^2*x^-1*sin(c+d*x)+1//3*a*b*d^3*sin(c)*sinintegral(d*x))
@test integrate(x^4*(a+b*x)^-1*sin(c+d*x), x) == :(-6*b^-1*d^-4*sin(c+d*x)+a^2*b^-3*d^-2*sin(c+d*x)+a^3*b^-4*d^-1*cos(c+d*x)+a^4*b^-5*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*a^4*b^-5*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1*b^-1*d^-1*x^3*cos(c+d*x)+-2*a*b^-2*d^-3*cos(c+d*x)+3*b^-1*d^-2*x^2*sin(c+d*x)+6*x*b^-1*d^-3*cos(c+d*x)+a*b^-2*d^-1*x^2*cos(c+d*x)+-1*x*a^2*b^-3*d^-1*cos(c+d*x)+-2*a*x*b^-2*d^-2*sin(c+d*x))
@test integrate(x^3*(a+b*x)^-1*sin(c+d*x), x) == :(2*b^-1*d^-3*cos(c+d*x)+a^3*b^-4*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1*a*b^-2*d^-2*sin(c+d*x)+-1*a^2*b^-3*d^-1*cos(c+d*x)+-1*a^3*b^-4*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*b^-1*d^-1*x^2*cos(c+d*x)+2*x*b^-1*d^-2*sin(c+d*x)+a*x*b^-2*d^-1*cos(c+d*x))
@test integrate(x^2*(a+b*x)^-1*sin(c+d*x), x) == :(b^-1*d^-2*sin(c+d*x)+a*b^-2*d^-1*cos(c+d*x)+a^2*b^-3*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*x*b^-1*d^-1*cos(c+d*x)+-1*a^2*b^-3*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1))
@test integrate(x*(a+b*x)^-1*sin(c+d*x), x) == :(-1*b^-1*d^-1*cos(c+d*x)+a*b^-2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1*a*b^-2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate((a+b*x)^-1*sin(c+d*x), x) == :(b^-1*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*b^-1*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1))
@test integrate(x^-1*(a+b*x)^-1*sin(c+d*x), x) == :(a^-1*cos(c)*sinintegral(d*x)+a^-1*cosintegral(d*x)*sin(c)+a^-1*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1*a^-1*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x^-2*(a+b*x)^-1*sin(c+d*x), x) == :(-1*a^-1*x^-1*sin(c+d*x)+b*a^-2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+d*a^-1*cos(c)*cosintegral(d*x)+-1*b*a^-2*cos(c)*sinintegral(d*x)+-1*b*a^-2*cosintegral(d*x)*sin(c)+-1*b*a^-2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1*d*a^-1*sin(c)*sinintegral(d*x))
@test integrate(x^-3*(a+b*x)^-1*sin(c+d*x), x) == :(-1//2*a^-1*x^-2*sin(c+d*x)+b*a^-2*x^-1*sin(c+d*x)+a^-3*b^2*cos(c)*sinintegral(d*x)+a^-3*b^2*cosintegral(d*x)*sin(c)+a^-3*b^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1*a^-3*b^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1//2*d*a^-1*x^-1*cos(c+d*x)+-1//2*a^-1*d^2*cos(c)*sinintegral(d*x)+-1//2*a^-1*d^2*cosintegral(d*x)*sin(c)+b*d*a^-2*sin(c)*sinintegral(d*x)+-1*b*d*a^-2*cos(c)*cosintegral(d*x))
@test integrate(x^4*(a+b*x)^-2*sin(c+d*x), x) == :(2*b^-2*d^-3*cos(c+d*x)+-1*a^4*b^-5*(a+b*x)^-1*sin(c+d*x)+-1*b^-2*d^-1*x^2*cos(c+d*x)+-4*a^3*b^-5*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-3*a^2*b^-4*d^-1*cos(c+d*x)+-2*a*b^-3*d^-2*sin(c+d*x)+2*x*b^-2*d^-2*sin(c+d*x)+4*a^3*b^-5*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+d*a^4*b^-6*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+d*a^4*b^-6*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+2*a*x*b^-3*d^-1*cos(c+d*x))
@test integrate(x^3*(a+b*x)^-2*sin(c+d*x), x) == :(b^-2*d^-2*sin(c+d*x)+a^3*b^-4*(a+b*x)^-1*sin(c+d*x)+-1*x*b^-2*d^-1*cos(c+d*x)+-3*a^2*b^-4*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+2*a*b^-3*d^-1*cos(c+d*x)+3*a^2*b^-4*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*d*a^3*b^-5*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+-1*d*a^3*b^-5*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x^2*(a+b*x)^-2*sin(c+d*x), x) == :(-1*b^-2*d^-1*cos(c+d*x)+-1*a^2*b^-3*(a+b*x)^-1*sin(c+d*x)+-2*a*b^-3*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+2*a*b^-3*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+d*a^2*b^-4*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+d*a^2*b^-4*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x*(a+b*x)^-2*sin(c+d*x), x) == :(b^-2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*b^-2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+a*b^-2*(a+b*x)^-1*sin(c+d*x)+-1*a*d*b^-3*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+-1*a*d*b^-3*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate((a+b*x)^-2*sin(c+d*x), x) == :(-1*b^-1*(a+b*x)^-1*sin(c+d*x)+d*b^-2*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+d*b^-2*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x^-1*(a+b*x)^-2*sin(c+d*x), x) == :(a^-1*(a+b*x)^-1*sin(c+d*x)+a^-2*cos(c)*sinintegral(d*x)+a^-2*cosintegral(d*x)*sin(c)+a^-2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1*a^-2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*d*a^-1*b^-1*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+-1*d*a^-1*b^-1*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x^-2*(a+b*x)^-2*sin(c+d*x), x) == :(-1*a^-2*x^-1*sin(c+d*x)+d*a^-2*cos(c)*cosintegral(d*x)+d*a^-2*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+d*a^-2*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*b*a^-2*(a+b*x)^-1*sin(c+d*x)+-1*d*a^-2*sin(c)*sinintegral(d*x)+-2*b*a^-3*cos(c)*sinintegral(d*x)+-2*b*a^-3*cosintegral(d*x)*sin(c)+-2*b*a^-3*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+2*b*a^-3*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x^3*(a+b*x)^-3*sin(c+d*x), x) == :(-1*b^-3*d^-1*cos(c+d*x)+(1/2)*a^3*b^-4*(a+b*x)^-2*sin(c+d*x)+-3*a*b^-4*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-3*a^2*b^-4*(a+b*x)^-1*sin(c+d*x)+3*a*b^-4*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+(1/2)*d*a^3*b^-5*(a+b*x)^-1*cos(c+d*x)+(1/2)*a^3*b^-6*d^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+3*d*a^2*b^-5*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+3*d*a^2*b^-5*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1//2*a^3*b^-6*d^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1))
@test integrate(x^2*(a+b*x)^-3*sin(c+d*x), x) == :(b^-3*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*b^-3*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+2*a*b^-3*(a+b*x)^-1*sin(c+d*x)+-1//2*a^2*b^-3*(a+b*x)^-2*sin(c+d*x)+(1/2)*a^2*b^-5*d^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-2*a*d*b^-4*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+-2*a*d*b^-4*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1//2*d*a^2*b^-4*(a+b*x)^-1*cos(c+d*x)+-1//2*a^2*b^-5*d^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x*(a+b*x)^-3*sin(c+d*x), x) == :(-1*b^-2*(a+b*x)^-1*sin(c+d*x)+d*b^-3*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+d*b^-3*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+(1/2)*a*b^-2*(a+b*x)^-2*sin(c+d*x)+(1/2)*a*d*b^-3*(a+b*x)^-1*cos(c+d*x)+(1/2)*a*b^-4*d^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1//2*a*b^-4*d^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1))
@test integrate((a+b*x)^-3*sin(c+d*x), x) == :(-1//2*b^-1*(a+b*x)^-2*sin(c+d*x)+(1/2)*b^-3*d^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1//2*d*b^-2*(a+b*x)^-1*cos(c+d*x)+-1//2*b^-3*d^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x^-1*(a+b*x)^-3*sin(c+d*x), x) == :(a^-3*cos(c)*sinintegral(d*x)+a^-3*cosintegral(d*x)*sin(c)+a^-3*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+a^-2*(a+b*x)^-1*sin(c+d*x)+(1/2)*a^-1*(a+b*x)^-2*sin(c+d*x)+-1*a^-3*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+(1/2)*d*a^-1*b^-1*(a+b*x)^-1*cos(c+d*x)+(1/2)*a^-1*b^-2*d^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1*d*a^-2*b^-1*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+-1*d*a^-2*b^-1*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1//2*a^-1*b^-2*d^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1))
@test integrate(x^-2*(a+b*x)^-3*sin(c+d*x), x) == :(-1*a^-3*x^-1*sin(c+d*x)+d*a^-3*cos(c)*cosintegral(d*x)+-1*d*a^-3*sin(c)*sinintegral(d*x)+-3*b*a^-4*cos(c)*sinintegral(d*x)+-3*b*a^-4*cosintegral(d*x)*sin(c)+-3*b*a^-4*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-2*b*a^-3*(a+b*x)^-1*sin(c+d*x)+2*d*a^-3*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+2*d*a^-3*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+3*b*a^-4*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-1//2*b*a^-2*(a+b*x)^-2*sin(c+d*x)+-1//2*d*a^-2*(a+b*x)^-1*cos(c+d*x)+(1/2)*a^-2*b^-1*d^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1//2*a^-2*b^-1*d^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1))
@test integrate(x^-3*(a+b*x)^-3*sin(c+d*x), x) == :(-1//2*a^-3*x^-2*sin(c+d*x)+(1/2)*a^-3*b^2*(a+b*x)^-2*sin(c+d*x)+(1/2)*a^-3*d^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+-6*a^-5*b^2*cos(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+3*b*a^-4*x^-1*sin(c+d*x)+3*a^-4*b^2*(a+b*x)^-1*sin(c+d*x)+6*a^-5*b^2*cos(c)*sinintegral(d*x)+6*a^-5*b^2*cosintegral(d*x)*sin(c)+6*a^-5*b^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+-1//2*d*a^-3*x^-1*cos(c+d*x)+-1//2*a^-3*d^2*cos(c)*sinintegral(d*x)+-1//2*a^-3*d^2*cosintegral(d*x)*sin(c)+-1//2*a^-3*d^2*cosintegral(d*x+a*d*b^-1)*sin(-1c+a*d*b^-1)+(1/2)*b*d*a^-3*(a+b*x)^-1*cos(c+d*x)+-3*b*d*a^-4*cos(c)*cosintegral(d*x)+-3*b*d*a^-4*cos(-1c+a*d*b^-1)*cosintegral(d*x+a*d*b^-1)+-3*b*d*a^-4*sin(-1c+a*d*b^-1)*sinintegral(d*x+a*d*b^-1)+3*b*d*a^-4*sin(c)*sinintegral(d*x))
@test integrate(x^3*(a+b*x^2)*sin(c+d*x), x) == :(-6*a*d^-4*sin(c+d*x)+120*b*d^-6*sin(c+d*x)+-1*a*d^-1*x^3*cos(c+d*x)+-1*b*d^-1*x^5*cos(c+d*x)+-120*b*x*d^-5*cos(c+d*x)+-60*b*d^-4*x^2*sin(c+d*x)+3*a*d^-2*x^2*sin(c+d*x)+5*b*d^-2*x^4*sin(c+d*x)+6*a*x*d^-3*cos(c+d*x)+20*b*d^-3*x^3*cos(c+d*x))
@test integrate(x^2*(a+b*x^2)*sin(c+d*x), x) == :(-24*b*d^-5*cos(c+d*x)+2*a*d^-3*cos(c+d*x)+-1*a*d^-1*x^2*cos(c+d*x)+-1*b*d^-1*x^4*cos(c+d*x)+-24*b*x*d^-4*sin(c+d*x)+2*a*x*d^-2*sin(c+d*x)+4*b*d^-2*x^3*sin(c+d*x)+12*b*d^-3*x^2*cos(c+d*x))
@test integrate(x*(a+b*x^2)*sin(c+d*x), x) == :(a*d^-2*sin(c+d*x)+-6*b*d^-4*sin(c+d*x)+-1*a*x*d^-1*cos(c+d*x)+-1*b*d^-1*x^3*cos(c+d*x)+3*b*d^-2*x^2*sin(c+d*x)+6*b*x*d^-3*cos(c+d*x))
@test integrate((a+b*x^2)*sin(c+d*x), x) == :(-1*a*d^-1*cos(c+d*x)+2*b*d^-3*cos(c+d*x)+-1*b*d^-1*x^2*cos(c+d*x)+2*b*x*d^-2*sin(c+d*x))
@test integrate(x^-1*(a+b*x^2)*sin(c+d*x), x) == :(a*cos(c)*sinintegral(d*x)+a*cosintegral(d*x)*sin(c)+b*d^-2*sin(c+d*x)+-1*b*x*d^-1*cos(c+d*x))
@test integrate(x^-2*(a+b*x^2)*sin(c+d*x), x) == :(-1*a*x^-1*sin(c+d*x)+-1*b*d^-1*cos(c+d*x)+a*d*cos(c)*cosintegral(d*x)+-1*a*d*sin(c)*sinintegral(d*x))
@test integrate(x^-3*(a+b*x^2)*sin(c+d*x), x) == :(b*cos(c)*sinintegral(d*x)+b*cosintegral(d*x)*sin(c)+-1//2*a*x^-2*sin(c+d*x)+-1//2*a*d*x^-1*cos(c+d*x)+-1//2*a*d^2*cos(c)*sinintegral(d*x)+-1//2*a*d^2*cosintegral(d*x)*sin(c))
@test integrate(x^-4*(a+b*x^2)*sin(c+d*x), x) == :(-1*b*x^-1*sin(c+d*x)+-1//3*a*x^-3*sin(c+d*x)+b*d*cos(c)*cosintegral(d*x)+-1*b*d*sin(c)*sinintegral(d*x)+-1//6*a*d*x^-2*cos(c+d*x)+-1//6*a*d^3*cos(c)*cosintegral(d*x)+1//6*a*d^2*x^-1*sin(c+d*x)+1//6*a*d^3*sin(c)*sinintegral(d*x))
@test integrate(x^-5*(a+b*x^2)*sin(c+d*x), x) == :(-1//2*b*x^-2*sin(c+d*x)+-1//4*a*x^-4*sin(c+d*x)+-1//2*b*d*x^-1*cos(c+d*x)+-1//2*b*d^2*cos(c)*sinintegral(d*x)+-1//2*b*d^2*cosintegral(d*x)*sin(c)+-1//12*a*d*x^-3*cos(c+d*x)+1//24*a*d^2*x^-2*sin(c+d*x)+1//24*a*d^3*x^-1*cos(c+d*x)+1//24*a*d^4*cos(c)*sinintegral(d*x)+1//24*a*d^4*cosintegral(d*x)*sin(c))
@test integrate(x^2*(a+b*x^2)^2*sin(c+d*x), x) == :(2*a^2*d^-3*cos(c+d*x)+720*b^2*d^-7*cos(c+d*x)+-1*a^2*d^-1*x^2*cos(c+d*x)+-1*b^2*d^-1*x^6*cos(c+d*x)+-360*b^2*d^-5*x^2*cos(c+d*x)+-120*b^2*d^-4*x^3*sin(c+d*x)+-48*a*b*d^-5*cos(c+d*x)+2*x*a^2*d^-2*sin(c+d*x)+6*b^2*d^-2*x^5*sin(c+d*x)+30*b^2*d^-3*x^4*cos(c+d*x)+720*x*b^2*d^-6*sin(c+d*x)+-48*a*b*x*d^-4*sin(c+d*x)+-2*a*b*d^-1*x^4*cos(c+d*x)+8*a*b*d^-2*x^3*sin(c+d*x)+24*a*b*d^-3*x^2*cos(c+d*x))
@test integrate(x*(a+b*x^2)^2*sin(c+d*x), x) == :(a^2*d^-2*sin(c+d*x)+120*b^2*d^-6*sin(c+d*x)+-1*x*a^2*d^-1*cos(c+d*x)+-1*b^2*d^-1*x^5*cos(c+d*x)+-120*x*b^2*d^-5*cos(c+d*x)+-60*b^2*d^-4*x^2*sin(c+d*x)+-12*a*b*d^-4*sin(c+d*x)+5*b^2*d^-2*x^4*sin(c+d*x)+20*b^2*d^-3*x^3*cos(c+d*x)+-2*a*b*d^-1*x^3*cos(c+d*x)+6*a*b*d^-2*x^2*sin(c+d*x)+12*a*b*x*d^-3*cos(c+d*x))
@test integrate((a+b*x^2)^2*sin(c+d*x), x) == :(-1*a^2*d^-1*cos(c+d*x)+-24*b^2*d^-5*cos(c+d*x)+-1*b^2*d^-1*x^4*cos(c+d*x)+-24*x*b^2*d^-4*sin(c+d*x)+4*a*b*d^-3*cos(c+d*x)+4*b^2*d^-2*x^3*sin(c+d*x)+12*b^2*d^-3*x^2*cos(c+d*x)+-2*a*b*d^-1*x^2*cos(c+d*x)+4*a*b*x*d^-2*sin(c+d*x))
@test integrate(x^-1*(a+b*x^2)^2*sin(c+d*x), x) == :(a^2*cos(c)*sinintegral(d*x)+a^2*cosintegral(d*x)*sin(c)+-6*b^2*d^-4*sin(c+d*x)+-1*b^2*d^-1*x^3*cos(c+d*x)+2*a*b*d^-2*sin(c+d*x)+3*b^2*d^-2*x^2*sin(c+d*x)+6*x*b^2*d^-3*cos(c+d*x)+-2*a*b*x*d^-1*cos(c+d*x))
@test integrate(x^-2*(a+b*x^2)^2*sin(c+d*x), x) == :(-1*a^2*x^-1*sin(c+d*x)+2*b^2*d^-3*cos(c+d*x)+d*a^2*cos(c)*cosintegral(d*x)+-1*d*a^2*sin(c)*sinintegral(d*x)+-1*b^2*d^-1*x^2*cos(c+d*x)+-2*a*b*d^-1*cos(c+d*x)+2*x*b^2*d^-2*sin(c+d*x))
@test integrate(x^-3*(a+b*x^2)^2*sin(c+d*x), x) == :(b^2*d^-2*sin(c+d*x)+-1//2*a^2*x^-2*sin(c+d*x)+-1*x*b^2*d^-1*cos(c+d*x)+2*a*b*cos(c)*sinintegral(d*x)+2*a*b*cosintegral(d*x)*sin(c)+-1//2*d*a^2*x^-1*cos(c+d*x)+-1//2*a^2*d^2*cos(c)*sinintegral(d*x)+-1//2*a^2*d^2*cosintegral(d*x)*sin(c))
@test integrate(x^-4*(a+b*x^2)^2*sin(c+d*x), x) == :(-1*b^2*d^-1*cos(c+d*x)+-1//3*a^2*x^-3*sin(c+d*x)+-2*a*b*x^-1*sin(c+d*x)+-1//6*d*a^2*x^-2*cos(c+d*x)+-1//6*a^2*d^3*cos(c)*cosintegral(d*x)+1//6*a^2*d^2*x^-1*sin(c+d*x)+1//6*a^2*d^3*sin(c)*sinintegral(d*x)+-2*a*b*d*sin(c)*sinintegral(d*x)+2*a*b*d*cos(c)*cosintegral(d*x))
@test integrate(x^-5*(a+b*x^2)^2*sin(c+d*x), x) == :(b^2*cos(c)*sinintegral(d*x)+b^2*cosintegral(d*x)*sin(c)+-1//4*a^2*x^-4*sin(c+d*x)+-1*a*b*x^-2*sin(c+d*x)+-1//12*d*a^2*x^-3*cos(c+d*x)+1//24*a^2*d^2*x^-2*sin(c+d*x)+1//24*a^2*d^3*x^-1*cos(c+d*x)+1//24*a^2*d^4*cos(c)*sinintegral(d*x)+1//24*a^2*d^4*cosintegral(d*x)*sin(c)+-1*a*b*d*x^-1*cos(c+d*x)+-1*a*b*d^2*cos(c)*sinintegral(d*x)+-1*a*b*d^2*cosintegral(d*x)*sin(c))
@test integrate(x^4*(a+b*x^2)^-1*sin(c+d*x), x) == :(2*b^-1*d^-3*cos(c+d*x)+a*b^-2*d^-1*cos(c+d*x)+(1/2)*b^-5//2*(-1a)^3//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1*b^-1*d^-1*x^2*cos(c+d*x)+2*x*b^-1*d^-2*sin(c+d*x)+-1//2*b^-5//2*(-1a)^3//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-5//2*(-1a)^3//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-5//2*(-1a)^3//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^3*(a+b*x^2)^-1*sin(c+d*x), x) == :(b^-1*d^-2*sin(c+d*x)+(1/2)*a*b^-2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1*x*b^-1*d^-1*cos(c+d*x)+-1//2*a*b^-2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*a*b^-2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//2*a*b^-2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^2*(a+b*x^2)^-1*sin(c+d*x), x) == :(-1*b^-1*d^-1*cos(c+d*x)+(1/2)*b^-3//2*(-1a)^(1/2)*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-3//2*(-1a)^(1/2)*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-3//2*(-1a)^(1/2)*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-3//2*(-1a)^(1/2)*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2)))
@test integrate(x*(a+b*x^2)^-1*sin(c+d*x), x) == :((1/2)*b^-1*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+(1/2)*b^-1*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+(1/2)*b^-1*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-1*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate((a+b*x^2)^-1*sin(c+d*x), x) == :((1/2)*b^-1//2*(-1a)^-1//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-1//2*(-1a)^-1//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-1//2*(-1a)^-1//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-1//2*(-1a)^-1//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^-1*(a+b*x^2)^-1*sin(c+d*x), x) == :(a^-1*cos(c)*sinintegral(d*x)+a^-1*cosintegral(d*x)*sin(c)+(1/2)*a^-1*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*a^-1*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*a^-1*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//2*a^-1*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^-2*(a+b*x^2)^-1*sin(c+d*x), x) == :(-1*a^-1*x^-1*sin(c+d*x)+d*a^-1*cos(c)*cosintegral(d*x)+(1/2)*b^(1/2)*(-1a)^-3//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1*d*a^-1*sin(c)*sinintegral(d*x)+-1//2*b^(1/2)*(-1a)^-3//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^(1/2)*(-1a)^-3//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^(1/2)*(-1a)^-3//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^-3*(a+b*x^2)^-1*sin(c+d*x), x) == :(-1//2*a^-1*x^-2*sin(c+d*x)+(1/2)*b*a^-2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+(1/2)*b*a^-2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+(1/2)*b*a^-2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1*b*a^-2*cos(c)*sinintegral(d*x)+-1*b*a^-2*cosintegral(d*x)*sin(c)+-1//2*b*a^-2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*d*a^-1*x^-1*cos(c+d*x)+-1//2*a^-1*d^2*cos(c)*sinintegral(d*x)+-1//2*a^-1*d^2*cosintegral(d*x)*sin(c))
@test integrate(x^4*(a+b*x^2)^-2*sin(c+d*x), x) == :((1/2)*x*b^-2*sin(c+d*x)+-1*b^-2*d^-1*cos(c+d*x)+-3//4*b^-5//2*(-1a)^(1/2)*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-3//4*b^-5//2*(-1a)^(1/2)*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-3//4*b^-5//2*(-1a)^(1/2)*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//2*b^-1*x^3*(a+b*x^2)^-1*sin(c+d*x)+3//4*b^-5//2*(-1a)^(1/2)*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1//4*a*d*b^-3*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//4*a*d*b^-3*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//4*a*d*b^-3*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*a*d*b^-3*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^3*(a+b*x^2)^-2*sin(c+d*x), x) == :((1/2)*b^-2*sin(c+d*x)+(1/2)*b^-2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+(1/2)*b^-2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+(1/2)*b^-2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*b^-1*x^2*(a+b*x^2)^-1*sin(c+d*x)+-1//4*d*b^-5//2*(-1a)^(1/2)*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-5//2*(-1a)^(1/2)*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-5//2*(-1a)^(1/2)*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-5//2*(-1a)^(1/2)*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^2*(a+b*x^2)^-2*sin(c+d*x), x) == :(-1//2*x*b^-1*(a+b*x^2)^-1*sin(c+d*x)+-1//4*d*b^-2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//4*b^-3//2*(-1a)^-1//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//4*b^-3//2*(-1a)^-1//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//4*b^-3//2*(-1a)^-1//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*b^-3//2*(-1a)^-1//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x*(a+b*x^2)^-2*sin(c+d*x), x) == :(-1//2*b^-1*(a+b*x^2)^-1*sin(c+d*x)+-1//4*d*b^-3//2*(-1a)^-1//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-3//2*(-1a)^-1//2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-3//2*(-1a)^-1//2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-3//2*(-1a)^-1//2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate((a+b*x^2)^-2*sin(c+d*x), x) == :(-1//4*a^-1*b^-1//2*((-1a)^(1/2)+-1*x*b^(1/2))^-1*sin(c+d*x)+-1//4*b^-1//2*(-1a)^-3//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+1//4*a^-1*b^-1//2*((-1a)^(1/2)+x*b^(1/2))^-1*sin(c+d*x)+1//4*b^-1//2*(-1a)^-3//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*b^-1//2*(-1a)^-3//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//4*b^-1//2*(-1a)^-3//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//4*d*a^-1*b^-1*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//4*d*a^-1*b^-1*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//4*d*a^-1*b^-1*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*a^-1*b^-1*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^-1*(a+b*x^2)^-2*sin(c+d*x), x) == :(a^-2*cos(c)*sinintegral(d*x)+a^-2*cosintegral(d*x)*sin(c)+(1/2)*a^-1*(a+b*x^2)^-1*sin(c+d*x)+(1/2)*a^-2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*a^-2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*a^-2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//2*a^-2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1//4*d*b^-1//2*(-1a)^-3//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-1//2*(-1a)^-3//2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-1//2*(-1a)^-3//2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*b^-1//2*(-1a)^-3//2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^-2*(a+b*x^2)^-2*sin(c+d*x), x) == :(-1*a^-2*x^-1*sin(c+d*x)+d*a^-2*cos(c)*cosintegral(d*x)+-1*d*a^-2*sin(c)*sinintegral(d*x)+-3//4*b^(1/2)*(-1a)^-5//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1//4*d*a^-2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//4*a^-2*b^(1/2)*((-1a)^(1/2)+x*b^(1/2))^-1*sin(c+d*x)+1//4*d*a^-2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*a^-2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//4*d*a^-2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//4*a^-2*b^(1/2)*((-1a)^(1/2)+-1*x*b^(1/2))^-1*sin(c+d*x)+3//4*b^(1/2)*(-1a)^-5//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+3//4*b^(1/2)*(-1a)^-5//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+3//4*b^(1/2)*(-1a)^-5//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^3*(a+b*x^2)^-3*sin(c+d*x), x) == :(-1//4*b^-2*(a+b*x^2)^-1*sin(c+d*x)+-1//4*b^-1*x^2*(a+b*x^2)^-2*sin(c+d*x)+-1//16*b^-3*d^2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*b^-3*d^2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//16*b^-3*d^2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+1//16*b^-3*d^2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-3//16*d*b^-5//2*(-1a)^-1//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//8*d*x*b^-2*(a+b*x^2)^-1*cos(c+d*x)+3//16*d*b^-5//2*(-1a)^-1//2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+3//16*d*b^-5//2*(-1a)^-1//2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+3//16*d*b^-5//2*(-1a)^-1//2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^2*(a+b*x^2)^-3*sin(c+d*x), x) == :(-1//4*x*b^-1*(a+b*x^2)^-2*sin(c+d*x)+-1//8*d*b^-2*(a+b*x^2)^-1*cos(c+d*x)+-1//16*a^-1*b^-3//2*((-1a)^(1/2)+-1*x*b^(1/2))^-1*sin(c+d*x)+-1//16*b^-3//2*(-1a)^-3//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+1//16*a^-1*b^-3//2*((-1a)^(1/2)+x*b^(1/2))^-1*sin(c+d*x)+1//16*b^-3//2*(-1a)^-3//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-3//2*(-1a)^-3//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-3//2*(-1a)^-3//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//16*d*a^-1*b^-2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*d*a^-1*b^-2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*d*a^-1*b^-2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*b^-5//2*d^2*(-1a)^-1//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+1//16*d*a^-1*b^-2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-5//2*d^2*(-1a)^-1//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-5//2*d^2*(-1a)^-1//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-5//2*d^2*(-1a)^-1//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2)))
@test integrate(x*(a+b*x^2)^-3*sin(c+d*x), x) == :(-1//4*b^-1*(a+b*x^2)^-2*sin(c+d*x)+-1//16*d*a^-1*b^-3//2*((-1a)^(1/2)+-1*x*b^(1/2))^-1*cos(c+d*x)+-1//16*d*b^-3//2*(-1a)^-3//2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*d*b^-3//2*(-1a)^-3//2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*d*b^-3//2*(-1a)^-3//2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*a^-1*b^-2*d^2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//16*d*a^-1*b^-3//2*((-1a)^(1/2)+x*b^(1/2))^-1*cos(c+d*x)+1//16*d*b^-3//2*(-1a)^-3//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//16*a^-1*b^-2*d^2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//16*a^-1*b^-2*d^2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+1//16*a^-1*b^-2*d^2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2)))
@test integrate((a+b*x^2)^-3*sin(c+d*x), x) == :(-3//16*a^-2*b^-1//2*((-1a)^(1/2)+-1*x*b^(1/2))^-1*sin(c+d*x)+-3//16*b^-1//2*(-1a)^-5//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-3//16*b^-1//2*(-1a)^-5//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-3//16*b^-1//2*(-1a)^-5//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//16*b^-1//2*(-1a)^-3//2*((-1a)^(1/2)+-1*x*b^(1/2))^-2*sin(c+d*x)+1//16*b^-1//2*(-1a)^-3//2*((-1a)^(1/2)+x*b^(1/2))^-2*sin(c+d*x)+3//16*a^-2*b^-1//2*((-1a)^(1/2)+x*b^(1/2))^-1*sin(c+d*x)+3//16*b^-1//2*(-1a)^-5//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-3//16*d*a^-2*b^-1*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-3//16*d*a^-2*b^-1*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-3//16*d*a^-2*b^-1*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*b^-3//2*d^2*(-1a)^-3//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+1//16*d*b^-1*(-1a)^-3//2*((-1a)^(1/2)+x*b^(1/2))^-1*cos(c+d*x)+1//16*d*b^-1*(-1a)^-3//2*((-1a)^(1/2)+-1*x*b^(1/2))^-1*cos(c+d*x)+1//16*b^-3//2*d^2*(-1a)^-3//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-3//2*d^2*(-1a)^-3//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-3//2*d^2*(-1a)^-3//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+3//16*d*a^-2*b^-1*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^-1*(a+b*x^2)^-3*sin(c+d*x), x) == :(a^-3*cos(c)*sinintegral(d*x)+a^-3*cosintegral(d*x)*sin(c)+(1/2)*a^-3*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+(1/2)*a^-2*(a+b*x^2)^-1*sin(c+d*x)+-1//2*a^-3*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*a^-3*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//2*a^-3*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+1//4*a^-1*(a+b*x^2)^-2*sin(c+d*x)+-5//16*d*b^-1//2*(-1a)^-5//2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-5//16*d*b^-1//2*(-1a)^-5//2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-5//16*d*b^-1//2*(-1a)^-5//2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*d*a^-2*b^-1//2*((-1a)^(1/2)+x*b^(1/2))^-1*cos(c+d*x)+-1//16*a^-2*b^-1*d^2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*a^-2*b^-1*d^2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-1//16*a^-2*b^-1*d^2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+1//16*d*a^-2*b^-1//2*((-1a)^(1/2)+-1*x*b^(1/2))^-1*cos(c+d*x)+1//16*a^-2*b^-1*d^2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+5//16*d*b^-1//2*(-1a)^-5//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^-2*(a+b*x^2)^-3*sin(c+d*x), x) == :(-1*a^-3*x^-1*sin(c+d*x)+d*a^-3*cos(c)*cosintegral(d*x)+-1*d*a^-3*sin(c)*sinintegral(d*x)+-15//16*b^(1/2)*(-1a)^-7//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-15//16*b^(1/2)*(-1a)^-7//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-15//16*b^(1/2)*(-1a)^-7//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+-7//16*d*a^-3*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-7//16*a^-3*b^(1/2)*((-1a)^(1/2)+x*b^(1/2))^-1*sin(c+d*x)+-1//16*b^(1/2)*(-1a)^-5//2*((-1a)^(1/2)+-1*x*b^(1/2))^-2*sin(c+d*x)+1//16*d*(-1a)^-5//2*((-1a)^(1/2)+x*b^(1/2))^-1*cos(c+d*x)+1//16*d*(-1a)^-5//2*((-1a)^(1/2)+-1*x*b^(1/2))^-1*cos(c+d*x)+1//16*b^(1/2)*(-1a)^-5//2*((-1a)^(1/2)+x*b^(1/2))^-2*sin(c+d*x)+7//16*d*a^-3*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+7//16*d*a^-3*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))+7//16*d*a^-3*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+7//16*a^-3*b^(1/2)*((-1a)^(1/2)+-1*x*b^(1/2))^-1*sin(c+d*x)+15//16*b^(1/2)*(-1a)^-7//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-1//16*b^-1//2*d^2*(-1a)^-5//2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+1//16*b^-1//2*d^2*(-1a)^-5//2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-1//2*d^2*(-1a)^-5//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//16*b^-1//2*d^2*(-1a)^-5//2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^-3*(a+b*x^2)^-3*sin(c+d*x), x) == :(-1//2*a^-3*x^-2*sin(c+d*x)+-1*b*a^-3*(a+b*x^2)^-1*sin(c+d*x)+-3*b*a^-4*cos(c)*sinintegral(d*x)+-3*b*a^-4*cosintegral(d*x)*sin(c)+-3//2*b*a^-4*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-1//2*d*a^-3*x^-1*cos(c+d*x)+-1//2*a^-3*d^2*cos(c)*sinintegral(d*x)+-1//2*a^-3*d^2*cosintegral(d*x)*sin(c)+-1//4*b*a^-2*(a+b*x^2)^-2*sin(c+d*x)+-1//16*a^-3*d^2*cos(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+1//16*a^-3*d^2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+1//16*a^-3*d^2*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+1//16*a^-3*d^2*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+3//2*b*a^-4*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+3//2*b*a^-4*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+-1*d*b^-1//2*(-1a)^(1/2))+3//2*b*a^-4*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))*sin(c+d*b^-1//2*(-1a)^(1/2))+-9//16*d*b^(1/2)*(-1a)^-7//2*cos(c+d*b^-1//2*(-1a)^(1/2))*cosintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-9//16*d*b^(1/2)*(-1a)^-7//2*sin(c+d*b^-1//2*(-1a)^(1/2))*sinintegral(-1*d*x+d*b^-1//2*(-1a)^(1/2))+-9//16*d*b^(1/2)*(-1a)^-7//2*sin(c+-1*d*b^-1//2*(-1a)^(1/2))*sinintegral(d*x+d*b^-1//2*(-1a)^(1/2))+-1//16*d*a^-3*b^(1/2)*((-1a)^(1/2)+-1*x*b^(1/2))^-1*cos(c+d*x)+1//16*d*a^-3*b^(1/2)*((-1a)^(1/2)+x*b^(1/2))^-1*cos(c+d*x)+9//16*d*b^(1/2)*(-1a)^-7//2*cos(c+-1*d*b^-1//2*(-1a)^(1/2))*cosintegral(d*x+d*b^-1//2*(-1a)^(1/2)))
@test integrate(x^3*(a+b*x^3)*sin(c+d*x), x) == :(-6*a*d^-4*sin(c+d*x)+720*b*d^-7*cos(c+d*x)+-1*a*d^-1*x^3*cos(c+d*x)+-1*b*d^-1*x^6*cos(c+d*x)+-360*b*d^-5*x^2*cos(c+d*x)+-120*b*d^-4*x^3*sin(c+d*x)+3*a*d^-2*x^2*sin(c+d*x)+6*a*x*d^-3*cos(c+d*x)+6*b*d^-2*x^5*sin(c+d*x)+30*b*d^-3*x^4*cos(c+d*x)+720*b*x*d^-6*sin(c+d*x))
@test integrate(x^2*(a+b*x^3)*sin(c+d*x), x) == :(2*a*d^-3*cos(c+d*x)+120*b*d^-6*sin(c+d*x)+-1*a*d^-1*x^2*cos(c+d*x)+-1*b*d^-1*x^5*cos(c+d*x)+-120*b*x*d^-5*cos(c+d*x)+-60*b*d^-4*x^2*sin(c+d*x)+2*a*x*d^-2*sin(c+d*x)+5*b*d^-2*x^4*sin(c+d*x)+20*b*d^-3*x^3*cos(c+d*x))
@test integrate(x*(a+b*x^3)*sin(c+d*x), x) == :(a*d^-2*sin(c+d*x)+-24*b*d^-5*cos(c+d*x)+-1*a*x*d^-1*cos(c+d*x)+-1*b*d^-1*x^4*cos(c+d*x)+-24*b*x*d^-4*sin(c+d*x)+4*b*d^-2*x^3*sin(c+d*x)+12*b*d^-3*x^2*cos(c+d*x))
@test integrate((a+b*x^3)*sin(c+d*x), x) == :(-1*a*d^-1*cos(c+d*x)+-6*b*d^-4*sin(c+d*x)+-1*b*d^-1*x^3*cos(c+d*x)+3*b*d^-2*x^2*sin(c+d*x)+6*b*x*d^-3*cos(c+d*x))
@test integrate(x^-1*(a+b*x^3)*sin(c+d*x), x) == :(a*cos(c)*sinintegral(d*x)+a*cosintegral(d*x)*sin(c)+2*b*d^-3*cos(c+d*x)+-1*b*d^-1*x^2*cos(c+d*x)+2*b*x*d^-2*sin(c+d*x))
@test integrate(x^-2*(a+b*x^3)*sin(c+d*x), x) == :(b*d^-2*sin(c+d*x)+-1*a*x^-1*sin(c+d*x)+a*d*cos(c)*cosintegral(d*x)+-1*a*d*sin(c)*sinintegral(d*x)+-1*b*x*d^-1*cos(c+d*x))
@test integrate(x^-3*(a+b*x^3)*sin(c+d*x), x) == :(-1*b*d^-1*cos(c+d*x)+-1//2*a*x^-2*sin(c+d*x)+-1//2*a*d*x^-1*cos(c+d*x)+-1//2*a*d^2*cos(c)*sinintegral(d*x)+-1//2*a*d^2*cosintegral(d*x)*sin(c))
@test integrate(x^-4*(a+b*x^3)*sin(c+d*x), x) == :(b*cos(c)*sinintegral(d*x)+b*cosintegral(d*x)*sin(c)+-1//3*a*x^-3*sin(c+d*x)+-1//6*a*d*x^-2*cos(c+d*x)+-1//6*a*d^3*cos(c)*cosintegral(d*x)+1//6*a*d^2*x^-1*sin(c+d*x)+1//6*a*d^3*sin(c)*sinintegral(d*x))
@test integrate(x*(a+b*x^3)^2*sin(c+d*x), x) == :(a^2*d^-2*sin(c+d*x)+-5040*b^2*d^-8*sin(c+d*x)+-1*x*a^2*d^-1*cos(c+d*x)+-1*b^2*d^-1*x^7*cos(c+d*x)+-840*b^2*d^-5*x^3*cos(c+d*x)+-210*b^2*d^-4*x^4*sin(c+d*x)+-48*a*b*d^-5*cos(c+d*x)+7*b^2*d^-2*x^6*sin(c+d*x)+42*b^2*d^-3*x^5*cos(c+d*x)+2520*b^2*d^-6*x^2*sin(c+d*x)+5040*x*b^2*d^-7*cos(c+d*x)+-48*a*b*x*d^-4*sin(c+d*x)+-2*a*b*d^-1*x^4*cos(c+d*x)+8*a*b*d^-2*x^3*sin(c+d*x)+24*a*b*d^-3*x^2*cos(c+d*x))
@test integrate((a+b*x^3)^2*sin(c+d*x), x) == :(-1*a^2*d^-1*cos(c+d*x)+720*b^2*d^-7*cos(c+d*x)+-1*b^2*d^-1*x^6*cos(c+d*x)+-360*b^2*d^-5*x^2*cos(c+d*x)+-120*b^2*d^-4*x^3*sin(c+d*x)+-12*a*b*d^-4*sin(c+d*x)+6*b^2*d^-2*x^5*sin(c+d*x)+30*b^2*d^-3*x^4*cos(c+d*x)+720*x*b^2*d^-6*sin(c+d*x)+-2*a*b*d^-1*x^3*cos(c+d*x)+6*a*b*d^-2*x^2*sin(c+d*x)+12*a*b*x*d^-3*cos(c+d*x))
@test integrate(x^-1*(a+b*x^3)^2*sin(c+d*x), x) == :(a^2*cos(c)*sinintegral(d*x)+a^2*cosintegral(d*x)*sin(c)+120*b^2*d^-6*sin(c+d*x)+-1*b^2*d^-1*x^5*cos(c+d*x)+-120*x*b^2*d^-5*cos(c+d*x)+-60*b^2*d^-4*x^2*sin(c+d*x)+4*a*b*d^-3*cos(c+d*x)+5*b^2*d^-2*x^4*sin(c+d*x)+20*b^2*d^-3*x^3*cos(c+d*x)+-2*a*b*d^-1*x^2*cos(c+d*x)+4*a*b*x*d^-2*sin(c+d*x))
@test integrate(x^-2*(a+b*x^3)^2*sin(c+d*x), x) == :(-1*a^2*x^-1*sin(c+d*x)+-24*b^2*d^-5*cos(c+d*x)+d*a^2*cos(c)*cosintegral(d*x)+-1*d*a^2*sin(c)*sinintegral(d*x)+-1*b^2*d^-1*x^4*cos(c+d*x)+-24*x*b^2*d^-4*sin(c+d*x)+2*a*b*d^-2*sin(c+d*x)+4*b^2*d^-2*x^3*sin(c+d*x)+12*b^2*d^-3*x^2*cos(c+d*x)+-2*a*b*x*d^-1*cos(c+d*x))
@test integrate(x^-3*(a+b*x^3)^2*sin(c+d*x), x) == :(-6*b^2*d^-4*sin(c+d*x)+-1//2*a^2*x^-2*sin(c+d*x)+-1*b^2*d^-1*x^3*cos(c+d*x)+-2*a*b*d^-1*cos(c+d*x)+3*b^2*d^-2*x^2*sin(c+d*x)+6*x*b^2*d^-3*cos(c+d*x)+-1//2*d*a^2*x^-1*cos(c+d*x)+-1//2*a^2*d^2*cos(c)*sinintegral(d*x)+-1//2*a^2*d^2*cosintegral(d*x)*sin(c))
@test integrate(x^-4*(a+b*x^3)^2*sin(c+d*x), x) == :(2*b^2*d^-3*cos(c+d*x)+-1//3*a^2*x^-3*sin(c+d*x)+-1*b^2*d^-1*x^2*cos(c+d*x)+2*a*b*cos(c)*sinintegral(d*x)+2*a*b*cosintegral(d*x)*sin(c)+2*x*b^2*d^-2*sin(c+d*x)+-1//6*d*a^2*x^-2*cos(c+d*x)+-1//6*a^2*d^3*cos(c)*cosintegral(d*x)+1//6*a^2*d^2*x^-1*sin(c+d*x)+1//6*a^2*d^3*sin(c)*sinintegral(d*x))
@test integrate(x^-5*(a+b*x^3)^2*sin(c+d*x), x) == :(b^2*d^-2*sin(c+d*x)+-1//4*a^2*x^-4*sin(c+d*x)+-1*x*b^2*d^-1*cos(c+d*x)+-2*a*b*x^-1*sin(c+d*x)+-1//12*d*a^2*x^-3*cos(c+d*x)+1//24*a^2*d^2*x^-2*sin(c+d*x)+1//24*a^2*d^3*x^-1*cos(c+d*x)+1//24*a^2*d^4*cos(c)*sinintegral(d*x)+1//24*a^2*d^4*cosintegral(d*x)*sin(c)+-2*a*b*d*sin(c)*sinintegral(d*x)+2*a*b*d*cos(c)*cosintegral(d*x))
@test integrate(x^4*(a+b*x^3)^-1*sin(c+d*x), x) == :(b^-1*d^-2*sin(c+d*x)+-1*x*b^-1*d^-1*cos(c+d*x)+-1//3*a^2//3*b^-5//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//3*a^2//3*b^-5//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//3*(-1)^1//3*a^2//3*b^-5//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//3*(-1)^2//3*a^2//3*b^-5//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*(-1)^1//3*a^2//3*b^-5//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//3*(-1)^2//3*a^2//3*b^-5//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x^3*(a+b*x^3)^-1*sin(c+d*x), x) == :(-1*b^-1*d^-1*cos(c+d*x)+-1//3*a^1//3*b^-4//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//3*a^1//3*b^-4//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//3*(-1)^1//3*a^1//3*b^-4//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//3*(-1)^2//3*a^1//3*b^-4//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//3*(-1)^1//3*a^1//3*b^-4//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*(-1)^2//3*a^1//3*b^-4//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3))
@test integrate(x^2*(a+b*x^3)^-1*sin(c+d*x), x) == :(-1//3*b^-1*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//3*b^-1*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//3*b^-1*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//3*b^-1*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//3*b^-1*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//3*b^-1*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x*(a+b*x^3)^-1*sin(c+d*x), x) == :(-1//3*a^-1//3*b^-2//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//3*a^-1//3*b^-2//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//3*(-1)^1//3*a^-1//3*b^-2//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-1//3*(-1)^2//3*a^-1//3*b^-2//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*(-1)^1//3*a^-1//3*b^-2//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//3*(-1)^2//3*a^-1//3*b^-2//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate((a+b*x^3)^-1*sin(c+d*x), x) == :(-1//3*a^-2//3*b^-1//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//3*a^-2//3*b^-1//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//3*(-1)^1//3*a^-2//3*b^-1//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+-1//3*(-1)^2//3*a^-2//3*b^-1//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//3*(-1)^1//3*a^-2//3*b^-1//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*(-1)^2//3*a^-2//3*b^-1//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3))
@test integrate(x^-1*(a+b*x^3)^-1*sin(c+d*x), x) == :(a^-1*cos(c)*sinintegral(d*x)+a^-1*cosintegral(d*x)*sin(c)+-1//3*a^-1*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//3*a^-1*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//3*a^-1*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*a^-1*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*a^-1*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//3*a^-1*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3))
@test integrate(x^-2*(a+b*x^3)^-1*sin(c+d*x), x) == :(-1*a^-1*x^-1*sin(c+d*x)+d*a^-1*cos(c)*cosintegral(d*x)+-1*d*a^-1*sin(c)*sinintegral(d*x)+-1//3*a^-4//3*b^1//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//3*a^-4//3*b^1//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//3*(-1)^1//3*a^-4//3*b^1//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//3*(-1)^2//3*a^-4//3*b^1//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*(-1)^1//3*a^-4//3*b^1//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//3*(-1)^2//3*a^-4//3*b^1//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x^-3*(a+b*x^3)^-1*sin(c+d*x), x) == :(-1//2*a^-1*x^-2*sin(c+d*x)+-1//2*d*a^-1*x^-1*cos(c+d*x)+-1//2*a^-1*d^2*cos(c)*sinintegral(d*x)+-1//2*a^-1*d^2*cosintegral(d*x)*sin(c)+-1//3*a^-5//3*b^2//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//3*a^-5//3*b^2//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//3*(-1)^1//3*a^-5//3*b^2//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//3*(-1)^2//3*a^-5//3*b^2//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//3*(-1)^1//3*a^-5//3*b^2//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*(-1)^2//3*a^-5//3*b^2//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3))
@test integrate(x^3*(a+b*x^3)^-2*sin(c+d*x), x) == :(-1//3*x*b^-1*(a+b*x^3)^-1*sin(c+d*x)+-1//9*a^-2//3*b^-4//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//9*a^-2//3*b^-4//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//9*d*a^-1//3*b^-5//3*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+-1//9*d*a^-1//3*b^-5//3*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//9*(-1)^1//3*a^-2//3*b^-4//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+-1//9*(-1)^2//3*a^-2//3*b^-4//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*(-1)^1//3*a^-2//3*b^-4//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*(-1)^2//3*a^-2//3*b^-4//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*(-1)^2//3*a^-1//3*b^-5//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//9*d*(-1)^2//3*a^-1//3*b^-5//3*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*(-1)^1//3*a^-1//3*b^-5//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*d*(-1)^1//3*a^-1//3*b^-5//3*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3))
@test integrate(x^2*(a+b*x^3)^-2*sin(c+d*x), x) == :(-1//3*b^-1*(a+b*x^3)^-1*sin(c+d*x)+1//9*d*a^-2//3*b^-4//3*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+1//9*d*a^-2//3*b^-4//3*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//9*d*(-1)^1//3*a^-2//3*b^-4//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//9*d*(-1)^1//3*a^-2//3*b^-4//3*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*(-1)^2//3*a^-2//3*b^-4//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*d*(-1)^2//3*a^-2//3*b^-4//3*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3))
@test integrate(x*(a+b*x^3)^-2*sin(c+d*x), x) == :(-1//3*b^-1*x^-1*(a+b*x^3)^-1*sin(c+d*x)+-1//9*a^-4//3*b^-2//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//3*a^-1*b^-1*x^-1*sin(c+d*x)+1//9*a^-4//3*b^-2//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//9*d*a^-1*b^-1*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//9*d*a^-1*b^-1*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+-1//9*d*a^-1*b^-1*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*a^-1*b^-1*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//9*d*a^-1*b^-1*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//9*d*a^-1*b^-1*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*(-1)^1//3*a^-4//3*b^-2//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*(-1)^2//3*a^-4//3*b^-2//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*(-1)^1//3*a^-4//3*b^-2//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*(-1)^2//3*a^-4//3*b^-2//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate((a+b*x^3)^-2*sin(c+d*x), x) == :(-2//9*a^-5//3*b^-1//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//3*b^-1*x^-2*(a+b*x^3)^-1*sin(c+d*x)+1//3*a^-1*b^-1*x^-2*sin(c+d*x)+2//9*a^-5//3*b^-1//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-2//9*(-1)^1//3*a^-5//3*b^-1//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+-2//9*(-1)^2//3*a^-5//3*b^-1//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*d*a^-4//3*b^-2//3*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+1//9*d*a^-4//3*b^-2//3*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+2//9*(-1)^1//3*a^-5//3*b^-1//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+2//9*(-1)^2//3*a^-5//3*b^-1//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*(-1)^1//3*a^-4//3*b^-2//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*(-1)^1//3*a^-4//3*b^-2//3*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*d*(-1)^2//3*a^-4//3*b^-2//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*(-1)^2//3*a^-4//3*b^-2//3*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x^-1*(a+b*x^3)^-2*sin(c+d*x), x) == :(a^-2*cos(c)*sinintegral(d*x)+a^-2*cosintegral(d*x)*sin(c)+-1//3*a^-2*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//3*a^-2*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//3*a^-2*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*a^-2*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*a^-2*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//3*a^-2*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-1//3*b^-1*x^-3*(a+b*x^3)^-1*sin(c+d*x)+1//3*a^-1*b^-1*x^-3*sin(c+d*x)+-1//9*d*a^-5//3*b^-1//3*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+-1//9*d*a^-5//3*b^-1//3*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//9*d*(-1)^2//3*a^-5//3*b^-1//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*(-1)^2//3*a^-5//3*b^-1//3*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*d*(-1)^1//3*a^-5//3*b^-1//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*(-1)^1//3*a^-5//3*b^-1//3*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x^-2*(a+b*x^3)^-2*sin(c+d*x), x) == :(-4//3*a^-2*x^-1*sin(c+d*x)+d*a^-2*cos(c)*cosintegral(d*x)+-1*d*a^-2*sin(c)*sinintegral(d*x)+-4//9*a^-7//3*b^1//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//3*b^-1*x^-4*(a+b*x^3)^-1*sin(c+d*x)+1//3*a^-1*b^-1*x^-4*sin(c+d*x)+1//9*d*a^-2*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*a^-2*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+1//9*d*a^-2*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*d*a^-2*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*a^-2*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//9*d*a^-2*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+4//9*a^-7//3*b^1//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-4//9*(-1)^1//3*a^-7//3*b^1//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-4//9*(-1)^2//3*a^-7//3*b^1//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+4//9*(-1)^1//3*a^-7//3*b^1//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+4//9*(-1)^2//3*a^-7//3*b^1//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x^-3*(a+b*x^3)^-2*sin(c+d*x), x) == :(-5//6*a^-2*x^-2*sin(c+d*x)+-5//9*a^-8//3*b^2//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//2*d*a^-2*x^-1*cos(c+d*x)+-1//2*a^-2*d^2*cos(c)*sinintegral(d*x)+-1//2*a^-2*d^2*cosintegral(d*x)*sin(c)+-1//3*b^-1*x^-5*(a+b*x^3)^-1*sin(c+d*x)+1//3*a^-1*b^-1*x^-5*sin(c+d*x)+5//9*a^-8//3*b^2//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-5//9*(-1)^1//3*a^-8//3*b^2//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-5//9*(-1)^2//3*a^-8//3*b^2//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*a^-7//3*b^1//3*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+-1//9*d*a^-7//3*b^1//3*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+5//9*(-1)^1//3*a^-8//3*b^2//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+5//9*(-1)^2//3*a^-8//3*b^2//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*(-1)^2//3*a^-7//3*b^1//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//9*d*(-1)^2//3*a^-7//3*b^1//3*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*(-1)^1//3*a^-7//3*b^1//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*d*(-1)^1//3*a^-7//3*b^1//3*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3))
@test integrate(x^3*(a+b*x^3)^-3*sin(c+d*x), x) == :(-1//6*x*b^-1*(a+b*x^3)^-2*sin(c+d*x)+-1//18*b^-2*x^-2*(a+b*x^3)^-1*sin(c+d*x)+-1//27*a^-5//3*b^-4//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//18*a^-1*b^-2*x^-2*sin(c+d*x)+1//27*a^-5//3*b^-4//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//18*d*b^-2*x^-1*(a+b*x^3)^-1*cos(c+d*x)+-1//27*(-1)^1//3*a^-5//3*b^-4//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+-1//27*(-1)^2//3*a^-5//3*b^-4//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-1//54*a^-1*b^-2*d^2*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//54*a^-1*b^-2*d^2*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//54*a^-1*b^-2*d^2*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//18*d*a^-1*b^-2*x^-1*cos(c+d*x)+1//27*(-1)^1//3*a^-5//3*b^-4//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//27*(-1)^2//3*a^-5//3*b^-4//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//54*a^-1*b^-2*d^2*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//54*a^-1*b^-2*d^2*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//54*a^-1*b^-2*d^2*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x^2*(a+b*x^3)^-3*sin(c+d*x), x) == :(-1//6*b^-1*(a+b*x^3)^-2*sin(c+d*x)+-1//18*d*b^-2*x^-2*(a+b*x^3)^-1*cos(c+d*x)+-1//54*a^-4//3*b^-5//3*d^2*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//18*d*a^-1*b^-2*x^-2*cos(c+d*x)+1//27*d*a^-5//3*b^-4//3*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+1//27*d*a^-5//3*b^-4//3*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//54*a^-4//3*b^-5//3*d^2*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//27*d*(-1)^1//3*a^-5//3*b^-4//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//27*d*(-1)^1//3*a^-5//3*b^-4//3*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//54*(-1)^1//3*a^-4//3*b^-5//3*d^2*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-1//54*(-1)^2//3*a^-4//3*b^-5//3*d^2*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//27*d*(-1)^2//3*a^-5//3*b^-4//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//27*d*(-1)^2//3*a^-5//3*b^-4//3*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//54*(-1)^1//3*a^-4//3*b^-5//3*d^2*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//54*(-1)^2//3*a^-4//3*b^-5//3*d^2*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x*(a+b*x^3)^-3*sin(c+d*x), x) == :(-2//27*a^-7//3*b^-2//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//6*b^-1*x^-1*(a+b*x^3)^-2*sin(c+d*x)+-1//18*a^-1*b^-2*x^-4*sin(c+d*x)+1//18*b^-2*x^-4*(a+b*x^3)^-1*sin(c+d*x)+2//9*a^-2*b^-1*x^-1*sin(c+d*x)+2//27*a^-7//3*b^-2//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-2//27*d*a^-2*b^-1*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-2//27*d*a^-2*b^-1*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+-2//27*d*a^-2*b^-1*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-2//27*d*a^-2*b^-1*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-2//27*d*a^-2*b^-1*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-2//27*d*a^-2*b^-1*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-2//27*(-1)^1//3*a^-7//3*b^-2//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-2//27*(-1)^2//3*a^-7//3*b^-2//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+-1//18*d*b^-2*x^-3*(a+b*x^3)^-1*cos(c+d*x)+-1//54*a^-5//3*b^-4//3*d^2*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//18*d*a^-1*b^-2*x^-3*cos(c+d*x)+1//54*a^-5//3*b^-4//3*d^2*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+2//27*(-1)^1//3*a^-7//3*b^-2//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+2//27*(-1)^2//3*a^-7//3*b^-2//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+-1//54*(-1)^1//3*a^-5//3*b^-4//3*d^2*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+-1//54*(-1)^2//3*a^-5//3*b^-4//3*d^2*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//54*(-1)^1//3*a^-5//3*b^-4//3*d^2*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//54*(-1)^2//3*a^-5//3*b^-4//3*d^2*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3))
@test integrate((a+b*x^3)^-3*sin(c+d*x), x) == :(-5//27*a^-8//3*b^-1//3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+-1//6*b^-1*x^-2*(a+b*x^3)^-2*sin(c+d*x)+-1//9*a^-1*b^-2*x^-5*sin(c+d*x)+1//9*b^-2*x^-5*(a+b*x^3)^-1*sin(c+d*x)+5//18*a^-2*b^-1*x^-2*sin(c+d*x)+5//27*a^-8//3*b^-1//3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-5//27*(-1)^1//3*a^-8//3*b^-1//3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+-5//27*(-1)^2//3*a^-8//3*b^-1//3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-1//18*d*a^-2*b^-1*x^-1*cos(c+d*x)+-1//18*d*b^-2*x^-4*(a+b*x^3)^-1*cos(c+d*x)+-1//54*a^-2*b^-1*d^2*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//54*a^-2*b^-1*d^2*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//54*a^-2*b^-1*d^2*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*a^-7//3*b^-2//3*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+1//9*d*a^-7//3*b^-2//3*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+1//18*d*a^-1*b^-2*x^-4*cos(c+d*x)+1//54*a^-2*b^-1*d^2*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//54*a^-2*b^-1*d^2*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//54*a^-2*b^-1*d^2*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+5//27*(-1)^1//3*a^-8//3*b^-1//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+5//27*(-1)^2//3*a^-8//3*b^-1//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*(-1)^1//3*a^-7//3*b^-2//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//9*d*(-1)^1//3*a^-7//3*b^-2//3*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+1//9*d*(-1)^2//3*a^-7//3*b^-2//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//9*d*(-1)^2//3*a^-7//3*b^-2//3*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3))
@test integrate(x^-1*(a+b*x^3)^-3*sin(c+d*x), x) == :(a^-3*cos(c)*sinintegral(d*x)+a^-3*cosintegral(d*x)*sin(c)+-1//3*a^-3*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//3*a^-3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//3*a^-3*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*a^-3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//3*a^-3*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//3*a^-3*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+-1//6*a^-1*b^-2*x^-6*sin(c+d*x)+-1//6*b^-1*x^-3*(a+b*x^3)^-2*sin(c+d*x)+1//3*a^-2*b^-1*x^-3*sin(c+d*x)+1//6*b^-2*x^-6*(a+b*x^3)^-1*sin(c+d*x)+-4//27*d*a^-8//3*b^-1//3*cos(-1c+d*a^1//3*b^-1//3)*cosintegral(d*x+d*a^1//3*b^-1//3)+-4//27*d*a^-8//3*b^-1//3*sin(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-1//18*d*a^-2*b^-1*x^-2*cos(c+d*x)+-1//18*d*b^-2*x^-5*(a+b*x^3)^-1*cos(c+d*x)+-1//54*a^-7//3*b^-2//3*d^2*cosintegral(d*x+d*a^1//3*b^-1//3)*sin(-1c+d*a^1//3*b^-1//3)+1//18*d*a^-1*b^-2*x^-5*cos(c+d*x)+1//54*a^-7//3*b^-2//3*d^2*cos(-1c+d*a^1//3*b^-1//3)*sinintegral(d*x+d*a^1//3*b^-1//3)+-4//27*d*(-1)^2//3*a^-8//3*b^-1//3*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-4//27*d*(-1)^2//3*a^-8//3*b^-1//3*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//54*(-1)^1//3*a^-7//3*b^-2//3*d^2*cos(-1c+d*(-1)^2//3*a^1//3*b^-1//3)*sinintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)+-1//54*(-1)^2//3*a^-7//3*b^-2//3*d^2*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+1//54*(-1)^1//3*a^-7//3*b^-2//3*d^2*cosintegral(d*x+d*(-1)^2//3*a^1//3*b^-1//3)*sin(-1c+d*(-1)^2//3*a^1//3*b^-1//3)+1//54*(-1)^2//3*a^-7//3*b^-2//3*d^2*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)+4//27*d*(-1)^1//3*a^-8//3*b^-1//3*cos(c+d*(-1)^1//3*a^1//3*b^-1//3)*cosintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3)+4//27*d*(-1)^1//3*a^-8//3*b^-1//3*sin(c+d*(-1)^1//3*a^1//3*b^-1//3)*sinintegral(-1*d*x+d*(-1)^1//3*a^1//3*b^-1//3))

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:
function compute_value(cost_tensors, i = 1; init = nothing, ϵ = 0.0)
    sol = compute_equilibrium(cost_tensors; ϵ = ϵ, initialization = init, convergence_tolerance = 1e-10)
    value = expected_cost(sol.x, cost_tensors[i])
end

@testset "derivative computation" begin
    rng = MersenneTwister(1)
    for N ∈ [2, 3, 4]
        for iteration ∈ 1:3
            for min_prob ∈ [0.0, 0.05]
                ϵ = 1e-6
                ϵ2 = 1e-3
                d_max = 50.0 # ignore very large numerical derivatives, as they imply non-local solution
                sol_tol = 1e-10
                d = 3 * ones(Int, N)
                cost_tensors = [randn(rng, d...) for n ∈ 1:N]
                sol = compute_equilibrium(cost_tensors; ϵ = min_prob, convergence_tolerance = 1e-10)
                x = vcat(sol.x...)
                init = [x; sol.λ]

                values = [compute_value(cost_tensors, i; ϵ = min_prob) for i ∈ 1:N]
                compute_val_eps_reverse_mode_ad(CT, ind) = compute_value(CT, ind; ϵ = min_prob)
                compute_val_eps_forward_mode_ad(CT, ind) = begin
                    CT_stacked = cat(CT..., dims = ndims(eltype(CT)) + 1)
                    forwarddiff(CT_stacked) do CT_stacked
                        CT_unstacked = collect(eachslice(CT_stacked; dims = ndims(CT_stacked)))
                        compute_value(CT_unstacked, ind; ϵ = min_prob)
                    end
                end

                for (mode_name, f) in [
                    ("reverse", compute_val_eps_reverse_mode_ad),
                    ("forward", compute_val_eps_forward_mode_ad),
                ]
                    @testset "ndims: $N, ad-mode: $mode_name, \
                              iteration: $iteration, min_prob: $min_prob" begin
                        value_grads_reverse_diff = [gradient(f, cost_tensors, i) for i ∈ 1:N]
                        for n = 1:N
                            cinds = CartesianIndices(cost_tensors[n])
                            for i ∈ eachindex(cost_tensors[n])
                                ct2 = deepcopy(cost_tensors)
                                ct2[n][i] += ϵ

                                values_perturbed = [compute_value(ct2, i; ϵ = min_prob, init = init) for i ∈ 1:N]

                                ii = cinds[i]
                                num_derivs = (values_perturbed - values) ./ ϵ
                                if any(abs.(num_derivs) .≥ d_max)
                                    continue
                                end
                                for j ∈ 1:length(num_derivs)
                                    @test ≈(num_derivs[j], value_grads_reverse_diff[j][1][n][ii]; atol = ϵ2)
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end

ext: jl


text:
## Functions to compute the reduced shape

# for reductions that expand 0 dims to 1
reduced_dims(a::AbstractArray, region) = reduced_dims(size(a), region)

# for reductions that keep 0 dims as 0
reduced_dims0(a::AbstractArray, region) = reduced_dims0(size(a), region)

reduced_dims{N}(siz::NTuple{N,Int}, d::Int, rd::Int) = (d == 1 ? tuple(rd, siz[d+1:N]...) :
                                                        d == N ? tuple(siz[1:N-1]..., rd) :
                                                        1 < d < N ? tuple(siz[1:d-1]..., rd, siz[d+1:N]...) :
                                                        siz)::typeof(siz)

reduced_dims{N}(siz::NTuple{N,Int}, d::Int) = reduced_dims(siz, d, 1)

reduced_dims0{N}(siz::NTuple{N,Int}, d::Int) = 1 <= d <= N ? reduced_dims(siz, d, (siz[d] == 0 ? 0 : 1)) : siz

function reduced_dims{N}(siz::NTuple{N,Int}, region)
    rsiz = [siz...]
    for i in region
        if 1 <= i <= N
            rsiz[i] = 1
        end
    end
    tuple(rsiz...)::typeof(siz)
end

function reduced_dims0{N}(siz::NTuple{N,Int}, region)
    rsiz = [siz...]
    for i in region
        if i <= i <= N
            rsiz[i] = (rsiz[i] == 0 ? 0 : 1)
        end
    end
    tuple(rsiz...)::typeof(siz)
end

function regionsize(a, region)
    s = 1
    for d in region
        s *= size(a,d)
    end
    s
end

### Generic reduction functions

reducedim(f::Function, A, region, initial) = reducedim!(f, reduction_init(A, region, initial), A)

reducedim(f::Function, A, region, initial, R) = reducedim!(f, fill!(R, initial), A)

function reducedim!_function(N::Int, f::Function)
    body = gen_reduction_body(N, f)
    @eval begin
        local _F_
        function _F_(R, A)
            $body
        end
        _F_
    end
end

let reducedim_cache = Dict()
# reducedim! assumes that R has already been initialized with a seed value
global reducedim!
function reducedim!(f::Function, R, A)
    if isempty(R)
        return R
    end
    ndimsA = ndims(A)
    key = (ndimsA, f)
    if !haskey(reducedim_cache,key)
        func = reducedim!_function(ndimsA, f)
        reducedim_cache[key] = func
    else
        func = reducedim_cache[key]
    end
    func(R, A)::typeof(R)
end
end  # let reducedim_cache

# Generate the body for a reduction function reduce!(f, R, A), using binary operation f,
# where R is the output and A is the input.
# R must have already been set to the appropriate size and initialized with the seed value
function gen_reduction_body(N, f::Function)
    F = Expr(:quote, f)
    quote
        (isempty(R) || isempty(A)) && return R
        for i = 1:$N
            (size(R, i) == size(A, i) || size(R, i) == 1) || throw(DimensionMismatch("Reduction on array of size $(size(A)) with output of size $(size(R))"))
        end
        @nextract $N sizeR d->size(R,d)
        # If we're reducing along dimension 1, for efficiency we can make use of a temporary.
        # Otherwise, keep the result in R so that we traverse A in storage order.
        if size(R, 1) < size(A, 1)
            @nloops $N i d->(d>1? (1:size(A,d)) : (1:1)) d->(j_d = sizeR_d==1 ? 1 : i_d) begin
                @inbounds tmp = (@nref $N R j)
                for i_1 = 1:size(A,1)
                    @inbounds tmp = ($F)(tmp, (@nref $N A i))
                end
                @inbounds (@nref $N R j) = tmp
            end
        else
            @nloops $N i A d->(j_d = sizeR_d==1 ? 1 : i_d) begin
                @inbounds (@nref $N R j) = ($F)((@nref $N R j), (@nref $N A i))
            end
        end
        R
    end
end

reduction_init{T}(A::AbstractArray, region, initial::T) = fill!(similar(A,T,reduced_dims(A,region)), initial)

### Pre-generated cases
# For performance, these bypass reducedim_cache

function initarray!{T}(a::AbstractArray{T}, v::T, init::Bool)
    if init
        fill!(a, v)
    end
    return a
end

eval(ngenerate(:N, :(typeof(R)), :(_all!{N}(R::AbstractArray, A::AbstractArray{Bool,N})), N->gen_reduction_body(N, &)))
all!(r::AbstractArray, A::AbstractArray{Bool}; init::Bool=true) = _all!(initarray!(r, true, init), A)
all(A::AbstractArray{Bool}, region) = _all!(reduction_init(A, region, true), A)

eval(ngenerate(:N, :(typeof(R)), :(_any!{N}(R::AbstractArray, A::AbstractArray{Bool,N})), N->gen_reduction_body(N, |)))
any!(r::AbstractArray, A::AbstractArray{Bool}; init::Bool=true) = _any!(initarray!(r, false, init), A)
any(A::AbstractArray{Bool}, region) = any!(reduction_init(A, region, false), A)

eval(ngenerate(:N, :(typeof(R)), :(_maximum!{T,N}(R::AbstractArray, A::AbstractArray{T,N})), N->gen_reduction_body(N, scalarmax)))
maximum!{R}(r::AbstractArray{R}, A::AbstractArray; init::Bool=true) = _maximum!(initarray!(r, typemin(R), init), A)
maximum{T}(A::AbstractArray{T}, region) =
    isempty(A) ? similar(A,reduced_dims0(A,region)) : _maximum!(reduction_init(A, region, typemin(T)), A)

eval(ngenerate(:N, :(typeof(R)), :(_minimum!{T,N}(R::AbstractArray, A::AbstractArray{T,N})), N->gen_reduction_body(N, scalarmin)))
minimum!{R}(r::AbstractArray{R}, A::AbstractArray; init::Bool=true) = _minimum!(initarray!(r, typemax(R), init), A)
minimum{T}(A::AbstractArray{T}, region) =
    isempty(A) ? similar(A, reduced_dims0(A, region)) : _minimum!(reduction_init(A, region, typemax(T)), A)

eval(ngenerate(:N, :(typeof(R)), :(_sum!{T,N}(R::AbstractArray, A::AbstractArray{T,N})), N->gen_reduction_body(N, +)))
sum!{R}(r::AbstractArray{R}, A::AbstractArray; init::Bool=true) = _sum!(initarray!(r, zero(R), init), A)
sum{T}(A::AbstractArray{T}, region) = _sum!(reduction_init(A, region, zero(T)+zero(T)), A)

eval(ngenerate(:N, :(typeof(R)), :(_prod!{T,N}(R::AbstractArray, A::AbstractArray{T,N})), N->gen_reduction_body(N, *)))
prod!{R}(r::AbstractArray{R}, A::AbstractArray; init::Bool=true) = _prod!(initarray!(r, one(R), init), A)
prod{T}(A::AbstractArray{T}, region) = _prod!(reduction_init(A, region, one(T)*one(T)), A)

prod(A::AbstractArray{Bool}, region) = error("use all() instead of prod() for boolean arrays")

max_stars_repo_name: tobig/julia

max_issues_repo_name: tobig/julia

max_forks_repo_name: tobig/julia


text:
# using Base.Terminals: UnixTerminal
# using Base.REPL: BasicREPL, run_repl

# type PipeTerminal <: UnixTerminal
#     in_stream::Base.Pipe
#     out_stream::Base.Pipe
#     err_stream::Base.Pipe
# end

# run_repl(BasicREPL(PipeTerminal(STDIN,STDOUT,STDERR)))

using Base: stdin, stdout, stderr
using REPL.Terminals: TTYTerminal
using REPL: BasicREPL, run_repl

run_repl(BasicREPL(TTYTerminal("emacs",stdin,stdout,stderr)))

max_stars_repo_name: kwstat/dot-emacs

max_issues_repo_name: kwstat/dot-emacs

max_forks_repo_name: kwstat/dot-emacs


text:
import Test

ENV["PREDICTMD_IS_RUNTESTS"] = "true"

Test.@testset "PredictMD.jl" begin
    ENV["PREDICTMD_IS_RUNTESTS"] = "true"
    import PredictMDExtra
    PredictMDExtra.import_all()
    include("intervals.jl")
    include("import-predictmd.jl")
    include("define-test-groups.jl")
    include("define-test-blocks.jl")
    include("get-test-group.jl")
    include("set-predictmd-test-plots.jl")
    include("set-predictmd-open-plots-during-tests.jl")
    include("all-testsets.jl")
    ENV["PREDICTMD_IS_RUNTESTS"] = "false"
end

ENV["PREDICTMD_IS_RUNTESTS"] = "false"


text:
################################################################################
#  Copyright 2020, Tom Van Acker                                               #
################################################################################
# MultiStateSystems.jl                                                         #
# A Julia package to solve multi-state system models.                          #
# See http://github.com/timmyfaraday/MultiStateSystems.jl                      #
################################################################################

"""
Example considering a double bridge network.
"""

# load pkgs
using Unitful
using MultiStateSystems

# include the state-transition diagrams for the pipes
stdᵖ = solvedSTD(prob = [0.1, 0.9], flow = [0.0u"m^3/hr", 1.0u"m^3/hr"])

# initialize the network corresponding with the bridge network
ntwᵈᵇⁿ = Network()

# add the sources, components and users to the network
add_sources!(ntwᵈᵇⁿ, node = [1 ,2])
add_components!(ntwᵈᵇⁿ, edge = [(1,3), (1,4), (2,3), (2,4), (3,5), (4,5)],
                       std  = stdᵖ)
add_bidirectional_component!(ntwᵈᵇⁿ, edge = (3,4), std = stdᵖ)
add_user!(ntwᵈᵇⁿ, node = 5)

# return the network
return ntwᵈᵇⁿ


text:
module test_Quaternion

import ..ModiaMath
using Test
using StaticArrays
using Unitful

angle1 = pi / 2
angle2 = 90u"°"

q1a = ModiaMath.qrot1(angle1)
q1b = ModiaMath.qrot1(angle2)
q1c = ModiaMath.qrot_e([1,0,0], angle1)
q1d = ModiaMath.qrot_e([1,0,0], angle2)
q1e = ModiaMath.qrot_nxy([1,0,0], [0,0,1])

q2a = ModiaMath.qrot2(angle1)
q2b = ModiaMath.qrot2(angle2)
q2c = ModiaMath.qrot_e([0,1,0], angle1)
q2d = ModiaMath.qrot_e([0,1,0], angle2)

q3a = ModiaMath.qrot3(angle1)
q3b = ModiaMath.qrot3(angle2)
q3c = ModiaMath.qrot_e([0,0,1], angle1)
q3d = ModiaMath.qrot_e([0,0,1], angle2)

q4a = ModiaMath.qrot123(angle1, angle1, angle1)
R4a = ModiaMath.rot123(angle1, angle1, angle1)

q5  = ModiaMath.qrot_nxy([1,0,0], [0,0,1])

v1  = SVector{3,Float64}(2.0, -1.0, 4.0)

v2a = ModiaMath.resolve2(q1a, v1)
v1a = ModiaMath.resolve1(q1a, v2a)

q6a = ModiaMath.absoluteRotation(q1a, q2a)
q6b = ModiaMath.qrot123(angle1, angle1, 0.0)
q7  = ModiaMath.relativeRotation(q1a, q6b)

@testset "ModiaMath.Frames: test Quaternions" begin
    @test isapprox(q1b, q1a)
    @test isapprox(q1c, q1a)
    @test isapprox(q1d, q1a)
    @test isapprox(q1e, q1a)

    @test isapprox(q2b, q2a)
    @test isapprox(q2c, q2a)
    @test isapprox(q2d, q2a)

    @test isapprox(q3b, q3a)
    @test isapprox(q3c, q3a)
    @test isapprox(q3d, q3a)

    @test isapprox(R4a, ModiaMath.from_q(q4a))

    @test isapprox(q5, q1a)

    @test isapprox(v1, v1a)

    @test isapprox(q6a, q6b)
    @test isapprox(q7, q2a)

    q4d = ModiaMath.inverseRotation(q4a)
    q4e = ModiaMath.inverseRotation(q4d)
    @test isapprox(q4a, q4e)

    q4d = ModiaMath.from_R(R4a)
    R4d = ModiaMath.from_q(q4d)
    @test isapprox(R4a, R4d)
    @test isapprox(q4a, q4d)
end

end


text:
function works()
    return 'a'*"bc"
end

function parseerr()
    s = 0
    for i [1,2,3]   # this line has a parsing error
        s += i
    end
    return s
end


text:
############################################################################################
"""
$(TYPEDEF)

Default arguments for Particle Filter constructor.

# Fields
$(TYPEDFIELDS)
"""
struct ParticleFilterDefault{
    M<:Union{Nothing, ParticleFilterMemory},
    A<:BaytesCore.ParameterWeighting,
    B<:BaytesCore.ResamplingMethod,
    C<:ParticleReferencing,
    T<:Integer,
    U<:BaytesCore.UpdateBool
}
    "Memory for particles and data."
    memory::M
    "Weighting Methods for particles."
    weighting::A
    "Resampling methods for particle trajectories."
    resampling::B
    "Referencing type for last particle at each iteration - either Conditional, Ancestral or Marginal Implementation."
    referencing::C
    "Coverage of Particles/datapoints."
    coverage::Float64
    "ESS threshold for resampling particle trajectories."
    threshold::Float64
    "Type for ancestors indices"
    ancestortype::Type{T}
    "Boolean if initial parameter are fixed or resampled."
    TunedModel::Bool
    "Boolean if generate(_rng, objective) for corresponding model is stored in PF Diagnostics."
    generated::U
    function ParticleFilterDefault(;
        memory::M=nothing,
        weighting::A=Bootstrap(),
        resampling::B=Systematic(),
        referencing::C=Marginal(),
        coverage=0.50,
        threshold=0.75,
        ancestortype::Type{T}=Int32,
        TunedModel=true,
        generated=BaytesCore.UpdateFalse()
    ) where {
        M<:Union{Nothing, ParticleFilterMemory},
        A<:BaytesCore.ParameterWeighting,
        B<:BaytesCore.ResamplingMethod,
        C<:ParticleReferencing,
        T<:Integer
    }
        ArgCheck.@argcheck 0.0 < coverage
        ArgCheck.@argcheck 0.0 <= threshold <= 1.0
        return new{M,A,B,C,T,typeof(generated)}(
            memory,
            weighting,
            resampling,
            referencing,
            coverage,
            threshold,
            ancestortype,
            TunedModel,
            generated
        )
    end
end

############################################################################################
"""
$(TYPEDEF)

Contains particles, transition kernel and all other relevant tuning information for particle propagation.

# Fields
$(TYPEDFIELDS)
"""
struct ParticleFilter{A<:Particles,B<:ParticleFilterTune} <: AbstractAlgorithm
    "Particle values and kernel."
    particles::A
    "Tuning configuration for particles."
    tune::B
    function ParticleFilter(
        particles::A, tune::B
    ) where {A<:Particles,B<:ParticleFilterTune}
        return new{A,B}(particles, tune)
    end
end

function ParticleFilter(
    _rng::Random.AbstractRNG,
    objective::Objective,
    default::ParticleFilterDefault=ParticleFilterDefault(),
    info::BaytesCore.SampleDefault = BaytesCore.SampleDefault()
)
    ## Checks before algorithm is initiated
    ArgCheck.@argcheck hasmethod(dynamics, Tuple{typeof(objective)}) "No Filter dynamics given your objective exists - assign dynamics(objective::Objective{MyModel})"
    @unpack memory, weighting, resampling, referencing, coverage, threshold, ancestortype, TunedModel, generated = default
    @unpack model, data, tagged = objective
    ## Assign model dynamics
    kernel = ModelWrappers.dynamics(objective)
    ## Initiate a valid reference given model.data and tagged.parameter
    reference = get_reference(referencing, objective)
    ## Guess particle and data memory
    memory = memory isa ParticleFilterMemory ? memory : _guessmemory(_rng, kernel, reference)
    ArgCheck.@argcheck memory isa ParticleFilterMemory
    ## Forward sample new reference if TunedModel == false
    if !TunedModel
        reference = propagate(_rng, kernel, memory, reference)
    end
    ## Assign tuning struct
    Ndata = maximum(size(data))
    Nparticles = Int64(floor(coverage * Ndata))
    tune = ParticleFilterTune(
        objective,
        weighting,
        resampling,
        referencing,
        ParticleFilterConfig(data, reference),
        BaytesCore.ChainsTune(coverage, threshold, Nparticles, Ndata),
        memory,
        generated,
        Iterator(1),
    )
    ## Prediction buffer
    Tprediction = infer(_rng, tune, kernel, model, data)
    prediction_buffer = Vector{Tprediction}(undef, 1)
    ## Create Particles container
    particles = Particles(reference, prediction_buffer, kernel, ancestortype, Nparticles, Ndata)
    ## Return Particle filter
    return ParticleFilter(particles, tune)
end

############################################################################################
"""
$(SIGNATURES)
Run particle filter and do not change reference trajectory.

# Examples
```julia
```

"""
function propose(
    _rng::Random.AbstractRNG,
    pf::ParticleFilter,
    objective::Objective,
    reference::AbstractArray{P}=get_reference(pf.tune.referencing, objective),
) where {P}
    ## Set iterations and log likelihood to initial state and resize proposal
    init!(pf.particles.ℓobjective)
    init!(pf.tune.iter, 1)
    ## Initialize particles
    initial!(_rng, pf.particles, pf.tune, reference, objective)
    ## Propagate particles forward
    propagate!(_rng, pf.particles, pf.tune, reference, objective)
    ## Sort all particles back into correct order
    BaytesCore.shuffle_backward!(pf.particles, pf.tune)
    ## Draw proposal path, update proposal with corresponding path and predict future state
    path = BaytesCore.draw!(_rng, pf.particles.weights)
    prediction = predict(_rng, pf.particles, pf.tune, reference, path)
    pf.particles.buffer.prediction[1] = prediction
    ## Update model parameter with reference trajectory
    ModelWrappers.fill!(
        objective.model,
        objective.tagged,
        #!NOTE: Create new Array with current iteration length to keep same type as in Model
        BaytesCore.to_NamedTuple(
            keys(objective.tagged.parameter),
            pf.particles.val[path, 1:(pf.tune.iter.current - 1)],
        ),
    )
    ## Create Diagnostics and return output
    diagnostics = ParticleFilterDiagnostics(
        BaytesCore.BaseDiagnostics(
            pf.particles.ℓobjective.cumulative,
            objective.temperature,
            prediction,
            pf.tune.iter.current-1
        ),
        pf.particles.ℓobjective.current,
        pf.tune.chains.Nchains,
        mean(pf.particles.buffer.resampled),
        ModelWrappers.generate(_rng, objective, pf.tune.generated)
    )
    ## Return new model parameter and diagnostics
    return objective.model.val, diagnostics
end

############################################################################################
"""
$(SIGNATURES)
Run particle filter and change reference trajectory with proposal trajectory.

# Examples
```julia
```

"""
function propose!(
    _rng::Random.AbstractRNG,
    pf::ParticleFilter,
    model::ModelWrapper,
    data::D,
    temperature::T = model.info.reconstruct.default.output(1.0),
    update::U=BaytesCore.UpdateTrue(),
) where {D, T<:AbstractFloat, U<:BaytesCore.UpdateBool}
    ## Update PF parameter
    objective = Objective(model, data, pf.tune.tagged, temperature)
    ## Collect reference
    reference = get_reference(pf.tune.referencing, objective)
    ## Check if Ndata and Nparticles have to be adjusted
    if update isa BaytesCore.UpdateTrue
        ## Check if number of particles need to be updated
        update_Nparticles, update_Ndata, Ndata = update!(pf.tune, data, reference)
        ## Resize particles if needed
        update!(
            pf.particles,
            update_Nparticles,
            update_Ndata,
            dynamics(objective),
            reference,
            pf.tune.chains.Nchains,
            Ndata,
        )
    end
    ## Propagate particles forward
    val, diagnostics = propose(_rng, pf, objective, reference)
    ## Update ModelWrapper parameter with reference trajectory
    model.val = val
    ## Return diagnostics
    return val, diagnostics
end

############################################################################################
"""
$(SIGNATURES)
Propagate particle filter forward with new data.

# Examples
```julia
```

"""
function propagate!(
    _rng::Random.AbstractRNG,
    pf::ParticleFilter,
    model::ModelWrapper,
    data::D,
    temperature::T = model.info.reconstruct.default.output(1.0),
) where {P, D, T<:AbstractFloat}
    ## Check if pf and data fulfill requirements for particle propagation
    ArgCheck.@argcheck isa(pf.tune.referencing, Marginal) "PF propagation only allowed for marginal particle filter"
    ## Assign new dynamics in case particles dependent on data
    objective = Objective(model, data, pf.tune.tagged, temperature)
    pf.particles.kernel = ModelWrappers.dynamics(objective)
    ## Collect reference trajectory
    reference = get_reference(pf.tune.referencing, objective)
    # Check if reference no larger than data dimension
    ArgCheck.@argcheck size(reference, 1) <= maximum(size(objective.data)) "Reference trajectory is longer than provided data input."
    ## Update maximal number of iterations and resize particles ~ Need to manually resize as want to keep weights and ancestor indices
    pf.tune.chains.Ndata = maximum(size(objective.data))
    resize!(pf.particles.val, pf.tune.chains.Nchains, pf.tune.chains.Ndata)
    resize!(pf.particles.ancestor, pf.tune.chains.Nchains, pf.tune.chains.Ndata)
    update!(pf.particles.buffer, pf.tune.chains.Nchains, pf.tune.chains.Ndata)
    ## Propagate particles forward
    propagate!(_rng, pf.particles, pf.tune, reference, objective)
    ## Sort all particles back into correct order
    BaytesCore.shuffle_backward!(pf.particles, pf.tune)
    ## Draw proposal path, update proposal with corresponding path and predict future state
    path = BaytesCore.draw!(_rng, pf.particles.weights)
    prediction = predict(_rng, pf.particles, pf.tune, reference, path)
    pf.particles.buffer.prediction[1] = prediction
    ## Update model parameter with reference trajectory
    ModelWrappers.fill!(
        model,
        pf.tune.tagged,
        #!NOTE: Create new Array with current iteration length to keep same type as in Model
        BaytesCore.to_NamedTuple(
            keys(pf.tune.tagged.parameter),
            pf.particles.val[path, 1:(pf.tune.iter.current - 1)],
        ),
    )
    ## Create Diagnostics and return output
    diagnostics = ParticleFilterDiagnostics(
        BaytesCore.BaseDiagnostics(
            pf.particles.ℓobjective.cumulative,
            temperature,
            prediction,
            pf.tune.iter.current-1
        ),
        pf.particles.ℓobjective.current,
        pf.tune.chains.Nchains,
        mean(pf.particles.buffer.resampled),
        ModelWrappers.generate(_rng, objective, pf.tune.generated)
    )
    return model.val, diagnostics
end

############################################################################################
#export
export ParticleFilter, ParticleFilterDefault, propose, propose!, propagate!


text:
struct HailstoneSeq{T<:Integer}
    count::T
end

Base.eltype(::HailstoneSeq{T}) where T = T

function Base.iterate(h::HailstoneSeq, state=h.count)
    if state == 1
        (1, 0)
    elseif state < 1
        nothing
    elseif iseven(state)
        (state, state ÷ 2)
    elseif isodd(state)
        (state, 3state + 1)
    end
end

function Base.length(h::HailstoneSeq)
    len = 0
    for _ in h
        len += 1
    end
    return len
end

function Base.show(io::IO, h::HailstoneSeq)
    f5 = collect(Iterators.take(h, 5))
    print(io, "HailstoneSeq{", join(f5, ", "), "...}")
end

hs = HailstoneSeq(27)
println("Collection of the Hailstone sequence from 27: $hs")
cl = collect(hs)
println("First 5 elements: ", join(cl[1:5], ", "))
println("Last 5 elements: ", join(cl[end-4:end], ", "))

Base.isless(h::HailstoneSeq, s::HailstoneSeq) = length(h) < length(s)
println("The number with the longest sequence under 100,000 is: ", maximum(HailstoneSeq.(1:100_000)))

max_stars_repo_name: ethansaxenian/RosettaDecode

max_issues_repo_name: ethansaxenian/RosettaDecode

max_forks_repo_name: ethansaxenian/RosettaDecode


text:
@recipe function f(p::FrequencyDirectionSpectra.FDSpectralModel,compass=false;Δ=1,func=freqdirspectra)
    projection --> :polar
    seriestype --> :contour
    legend --> false
    Ω = range(0, π/Δ, length = 100)
    Φ = range(-pi, pi, length = 100)
    if compass
        xticks := (0:π/2:3π/2, ["E", "N", "W", "S"])
        return Φ, Ω, (ϕ,ω) -> func(p,ω,-ϕ+pi/2)
    else
        xticks := (0:π/4:7π/4, ["0", "π/4", "π/2", "3π/4", "π", "-3π/4", "-π/2", "-π/4"])
        return Φ, Ω, (ϕ,ω) -> func(p,ω,ϕ)
    end
end


text:
function CL(ALPHA,BETA)
    A=[   0.     0.     0.     0.     0.     0.     0.     0.     0.     0.     0.     0.
       -.001  -.004  -.008  -.012  -.016  -.019  -.020  -.020  -.015  -.008  -.013  -.015
       -.003  -.009  -.017  -.024  -.030  -.034  -.040  -.037  -.016  -.002  -.010  -.019
       -.001  -.010  -.020  -.030  -.039  -.044  -.050  -.049  -.023  -.006  -.014  -.027
        .000  -.010  -.022  -.034  -.047  -.046  -.059  -.061  -.033  -.036  -.035  -.035
        .007  -.010  -.023  -.034  -.049  -.046  -.068  -.071  -.060  -.058  -.062  -.059
        .009  -.011  -.023  -.037  -.050  -.047  -.074  -.079  -.091  -.076  -.077  -.076]'
      #
      S= 0.2 * ALPHA
      K= floor(S)+3
      if(K <= 1)
          K= 2
      end
      if(K >=  12)
          K=  11
      end
      DA= S - K +3
      L = K + fix( 1.1*sign(DA) )
      #
      S= .2* abs(BETA)
      M= floor(S)+1
      if(M <=  1)
          M= 2
      end
      if(M >=  7)
          M= 6
      end
      DB= S - M +1
      N= M + fix( 1.1*sign(DB) )
      #
      K=convert(Int64, K)
      L=convert(Int64, L)
      M=convert(Int64, M)
      N=convert(Int64, N)
      T= A[K,M]
      U= A[K,N]
      V= T + abs(DA) * (A[L,M] - T)
      W= U + abs(DA) * (A[L,N] - U)
      DUM= V + (W-V)  * abs(DB)
      return clv = DUM * sign(BETA)
end


text:
# *****************************************************************************
# Written by Ritchie Lee, ritchie.lee@sv.cmu.edu
# *****************************************************************************
# Copyright ã 2015, United States Government, as represented by the
# Administrator of the National Aeronautics and Space Administration. All
# rights reserved.  The Reinforcement Learning Encounter Simulator (RLES)
# platform is licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You
# may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable
# law or agreed to in writing, software distributed under the License is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
# _____________________________________________________________________________
# Reinforcement Learning Encounter Simulator (RLES) includes the following
# third party software. The SISLES.jl package is licensed under the MIT Expat
# License: Copyright (c) 2014: Youngjun Kim.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED
# "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# *****************************************************************************

using ExprSearch, SymbolicRegression, DerivTreeVis
using ExprSearch.PMC
import ExprSearch.MC
using RLESUtils, Observers, LogSystems, Loggers
using Base.Test

const DIR = dirname(@__FILE__)
const RESULTDIR = joinpath(DIR, "..", "..", "..", "results")

"""
Example usage:
symbolic_pmc(; seed=1)
"""
function symbolic_pmc(;outdir::AbstractString=joinpath(RESULTDIR, "Symbolic_PMC"),
                     seed=1,
                     logfileroot::AbstractString="symbolic_pmc_log",

                     n_threads::Int64=1,
                     maxsteps::Int64=40,
                     n_samples::Int64=10000,

                     gt_file::AbstractString="gt_easy.jl",

                     loginterval::Int64=1000,
                     vis::Bool=true)
    srand(seed)
    mkpath(outdir)

    logsys = MC.logsystem()
    send_to!(STDOUT, logsys, "current_best_print"; interval=loginterval)

    plogsys = PMC.logsystem()
    send_to!(STDOUT, plogsys, ["verbose1", "result"])
    logs = TaggedDFLogger()
    send_to!(logs, plogsys, ["computeinfo", "parameters", "result"])

    problem = Symbolic(gt_file)
    mc_params = MCESParams(maxsteps, n_samples, logsys)
    pmc_params = PMCESParams(n_threads, mc_params, plogsys)
    result = exprsearch(pmc_params, problem)

    outfile = joinpath(outdir, "$(logfileroot).txt")
    save_log(outfile, logs)

    if vis
        derivtreevis(get_derivtree(result), joinpath(outdir, "$(logfileroot)_derivtreevis"))
    end
    @show result.expr
    return result
end

max_stars_repo_name: sisl/ExprSearch

max_issues_repo_name: sisl/ExprSearch


text:
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
#  Niccolò Antonello <nantonel@idiap.ch>

export get_scc
"""
  `get_scc(fst::WFST, i = get_initial(fst;single=true); filter=arc->true)`

Calculates the strongly connected components of 'fst' using Tarjan's algorithm.
Returns a tuple `(scc,c,v)`:
  * `scc` are the strongly connected components of `fst`
  * `c` is a boolean array containing the accessibility form the `i`
  * `v` are the visited states of the `fst`
The function `filter` can be used to consider only arcs with specific properties.
"""
function get_scc(fst::WFST, i = get_initial(fst;single=true); kwargs...)
  if isempty(fst)
    return Bool[]
  else
    stack=Int[]
    sccs=Vector{Vector{Int}}()
    lowlink=zeros(Int,size(fst,1))
    order=zeros(Int,size(fst,1))
    onstack=zeros(Bool,size(fst,1))
    coaccess=zeros(Bool,size(fst,1))

    dfs = DFS(fst,i; kwargs...)
    cnt = 1
    lowlink[1] = cnt
    order[1] = cnt
    onstack[1] = true
    push!(stack,i)

    for (p,s,n,d,e,a) in dfs
      if d # discovering new nodes
        cnt +=1
        lowlink[n] = cnt
        order[n] = cnt
        onstack[n] = true
        push!(stack,n)
      else
        if e # state explored
          if isfinal(fst,s)
            coaccess[s] = true
          end
          if lowlink[s] == order[s]
            scc = Vector{Int}()
            c_coaccess = false
            a = 0
            while a != s
              a = pop!(stack)
              onstack[a] = false
              if coaccess[a] c_coaccess = true end
              push!(scc,a)
            end
            if c_coaccess
              for z in scc coaccess[s] = true end
            end
            reverse!(scc)
            push!(sccs,scc)
          end
          if p != 0
            lowlink[p] = min(lowlink[p],lowlink[s])
            if coaccess[s] coaccess[p] = true end
          end
        else
          # n already visited
          lowlink[s] = min(order[n],lowlink[s])
          if coaccess[n] coaccess[s] = true end
        end
      end
    end
    reverse!(sccs)
    return sccs, coaccess, dfs.is_visited
  end
end