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

@test integrate(cos(c+d*x)^7*(A+C*cos(c+d*x)^2), x) == :(d^-1*(A+C)*sin(c+d*x)+-1//3*d^-1*sin(c+d*x)^3*(3A+4C)+-1//7*d^-1*sin(c+d*x)^7*(A+4C)+1//5*d^-1*sin(c+d*x)^5*(3A+6C)+1//9*C*d^-1*sin(c+d*x)^9)
@test integrate(cos(c+d*x)^5*(A+C*cos(c+d*x)^2), x) == :(d^-1*(A+C)*sin(c+d*x)+-1//3*d^-1*sin(c+d*x)^3*(2A+3C)+-1//7*C*d^-1*sin(c+d*x)^7+1//5*d^-1*sin(c+d*x)^5*(A+3C))
@test integrate(cos(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(d^-1*(A+C)*sin(c+d*x)+-1//3*d^-1*sin(c+d*x)^3*(A+2C)+1//5*C*d^-1*sin(c+d*x)^5)
@test integrate((A+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(d^-1*(A+C)*sin(c+d*x)+-1//3*C*d^-1*sin(c+d*x)^3)
@test integrate((A+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(A*d^-1*arctanh(sin(c+d*x))+C*d^-1*sin(c+d*x))
@test integrate(sec(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :((1/2)*d^-1*(A+2C)*arctanh(sin(c+d*x))+(1/2)*A*d^-1*sec(c+d*x)*tan(c+d*x))
@test integrate(sec(c+d*x)^5*(A+C*cos(c+d*x)^2), x) == :(1//8*d^-1*(3A+4C)*arctanh(sin(c+d*x))+1//4*A*d^-1*sec(c+d*x)^3*tan(c+d*x)+1//8*d^-1*(3A+4C)*sec(c+d*x)*tan(c+d*x))
@test integrate(sec(c+d*x)^7*(A+C*cos(c+d*x)^2), x) == :(1//16*d^-1*(5A+6C)*arctanh(sin(c+d*x))+1//6*A*d^-1*sec(c+d*x)^5*tan(c+d*x)+1//16*d^-1*(5A+6C)*sec(c+d*x)*tan(c+d*x)+1//24*d^-1*sec(c+d*x)^3*(5A+6C)*tan(c+d*x))
@test integrate(cos(c+d*x)^6*(A+C*cos(c+d*x)^2), x) == :(1//128*x*(35C+40A)+1//8*C*d^-1*cos(c+d*x)^7*sin(c+d*x)+1//48*d^-1*cos(c+d*x)^5*(7C+8A)*sin(c+d*x)+1//128*d^-1*(35C+40A)*cos(c+d*x)*sin(c+d*x)+1//192*d^-1*cos(c+d*x)^3*(35C+40A)*sin(c+d*x))
@test integrate(cos(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(1//16*x*(5C+6A)+1//6*C*d^-1*cos(c+d*x)^5*sin(c+d*x)+1//16*d^-1*(5C+6A)*cos(c+d*x)*sin(c+d*x)+1//24*d^-1*cos(c+d*x)^3*(5C+6A)*sin(c+d*x))
@test integrate(cos(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(1//8*x*(3C+4A)+1//4*C*d^-1*cos(c+d*x)^3*sin(c+d*x)+1//8*d^-1*(3C+4A)*cos(c+d*x)*sin(c+d*x))
@test integrate(sec(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(C*x+A*d^-1*tan(c+d*x))
@test integrate(sec(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(1//3*d^-1*(2A+3C)*tan(c+d*x)+1//3*A*d^-1*sec(c+d*x)^2*tan(c+d*x))
@test integrate(sec(c+d*x)^6*(A+C*cos(c+d*x)^2), x) == :(1//5*d^-1*(4A+5C)*tan(c+d*x)+1//15*d^-1*tan(c+d*x)^3*(4A+5C)+1//5*A*d^-1*sec(c+d*x)^4*tan(c+d*x))
@test integrate(sec(c+d*x)^8*(A+C*cos(c+d*x)^2), x) == :(1//7*d^-1*(6A+7C)*tan(c+d*x)+1//21*d^-1*tan(c+d*x)^3*(12A+14C)+1//35*d^-1*tan(c+d*x)^5*(6A+7C)+1//7*A*d^-1*sec(c+d*x)^6*tan(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*(A+C*cos(c+d*x)^2), x) == :(2//9*C*b^-1*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+2//45*b*d^-1*(b*cos(c+d*x))^3//2*(7C+9A)*sin(c+d*x)+2//15*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(7C+9A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*(A+C*cos(c+d*x)^2), x) == :(2//7*C*b^-1*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//21*b*d^-1*(b*cos(c+d*x))^(1/2)*(5C+7A)*sin(c+d*x)+2//21*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5C+7A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*(A+C*cos(c+d*x)^2), x) == :(1//5*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//5*C*b^-1*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*(A+C*cos(c+d*x)^2), x) == :(1//3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+6A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//3*C*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*(A+C*cos(c+d*x)^2), x) == :(2*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-1*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*(A+C*cos(c+d*x)^2), x) == :(2//3*A*b^-1*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+1//3*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2A+6C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-7//2*(A+C*cos(c+d*x)^2), x) == :(1//5*b^-3*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+2//5*A*b^-1*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+-1//5*b^-4*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-9//2*(A+C*cos(c+d*x)^2), x) == :(1//21*b^-3*d^-1*(b*cos(c+d*x))^-3//2*(10A+14C)*sin(c+d*x)+2//7*A*b^-1*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+1//21*b^-4*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10A+14C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate(cos(c+d*x)^(1/2)*(3+-5*cos(c+d*x)^2), x) == :(-2*d^-1*cos(c+d*x)^3//2*sin(c+d*x))
@test integrate(cos(c+d*x)^-1//2*(1+-3*cos(c+d*x)^2), x) == :(-2*d^-1*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*sec(c+d*x))^9//2*(A+C*cos(c+d*x)^2), x) == :(2//7*A*b^2*d^-1*(b*sec(c+d*x))^5//2*tan(c+d*x)+2//21*b^3*d^-1*(b*sec(c+d*x))^3//2*(5A+7C)*sin(c+d*x)+2//21*b^4*d^-1*(b*sec(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(5A+7C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*sec(c+d*x))^7//2*(A+C*cos(c+d*x)^2), x) == :(2//5*A*b^2*d^-1*(b*sec(c+d*x))^3//2*tan(c+d*x)+2//5*b^3*d^-1*(b*sec(c+d*x))^(1/2)*(3A+5C)*sin(c+d*x)+-2//5*b^4*d^-1*(b*sec(c+d*x))^-1//2*cos(c+d*x)^-1//2*(3A+5C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*sec(c+d*x))^5//2*(A+C*cos(c+d*x)^2), x) == :(2//3*A*b^2*d^-1*(b*sec(c+d*x))^(1/2)*tan(c+d*x)+2//3*b^2*d^-1*(b*sec(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(A+3C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*sec(c+d*x))^3//2*(A+C*cos(c+d*x)^2), x) == :(2*A*b^2*d^-1*(b*sec(c+d*x))^-1//2*tan(c+d*x)+-2*b^2*d^-1*(b*sec(c+d*x))^-1//2*cos(c+d*x)^-1//2*(A+-1C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*sec(c+d*x))^(1/2)*(A+C*cos(c+d*x)^2), x) == :(1//3*d^-1*(b*sec(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(2C+6A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//3*C*b^2*d^-1*(b*sec(c+d*x))^-3//2*tan(c+d*x))
@test integrate((b*sec(c+d*x))^-1//2*(A+C*cos(c+d*x)^2), x) == :(1//5*d^-1*(b*sec(c+d*x))^-1//2*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//5*C*b^2*d^-1*(b*sec(c+d*x))^-5//2*tan(c+d*x))
@test integrate((b*sec(c+d*x))^-3//2*(A+C*cos(c+d*x)^2), x) == :(1//21*b^-1*d^-1*(b*sec(c+d*x))^-1//2*(10C+14A)*sin(c+d*x)+2//7*C*b^2*d^-1*(b*sec(c+d*x))^-7//2*tan(c+d*x)+1//21*b^-2*d^-1*(b*sec(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(10C+14A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*sec(c+d*x))^-5//2*(A+C*cos(c+d*x)^2), x) == :(1//45*b^-1*d^-1*(b*sec(c+d*x))^-3//2*(14C+18A)*sin(c+d*x)+2//9*C*b^2*d^-1*(b*sec(c+d*x))^-9//2*tan(c+d*x)+1//15*b^-2*d^-1*(b*sec(c+d*x))^-1//2*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^m*(C*cos(c+d*x)^2+-1*C*(2+m)^-1*(1+m)), x) == :(C*b^-1*d^-1*(b*cos(c+d*x))^(1+m)*(2+m)^-1*sin(c+d*x))
@test integrate((b*cos(c+d*x))^m*(A+-1*A*(1+m)^-1*cos(c+d*x)^2*(2+m)), x) == :(-1*A*b^-1*d^-1*(b*cos(c+d*x))^(1+m)*(1+m)^-1*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(1//15*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+1//45*b^-1*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//9*C*b^-3*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*(A+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(1//21*d^-1*(b*cos(c+d*x))^(1/2)*(10C+14A)*sin(c+d*x)+2//7*C*b^-2*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//21*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5C+7A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*(A+C*cos(c+d*x)^2), x) == :(1//5*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//5*C*b^-1*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*(A+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//3*C*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//3*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(C+3A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*sec(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2*A*b*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*sec(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(2//3*A*b^2*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//3*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+3C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*sec(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(-1//5*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//5*A*b^3*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//5*b*d^-1*(b*cos(c+d*x))^-1//2*(3A+5C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*sec(c+d*x)^5*(A+C*cos(c+d*x)^2), x) == :(2//7*A*b^4*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+2//21*b^2*d^-1*(b*cos(c+d*x))^-3//2*(5A+7C)*sin(c+d*x)+2//21*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5A+7C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*(A+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(1//45*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//9*C*b^-2*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+2//15*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(7C+9A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*(A+C*cos(c+d*x)^2), x) == :(2//7*C*b^-1*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//21*b*d^-1*(b*cos(c+d*x))^(1/2)*(5C+7A)*sin(c+d*x)+2//21*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5C+7A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*(A+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//5*C*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//5*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+5A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(2//3*C*b*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//3*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(C+3A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(2*A*b^2*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-2*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+-1C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(2//3*A*b^3*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//3*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+3C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^5*(A+C*cos(c+d*x)^2), x) == :(2//5*A*b^4*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//5*b^2*d^-1*(b*cos(c+d*x))^-1//2*(3A+5C)*sin(c+d*x)+-2//5*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+5C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^6*(A+C*cos(c+d*x)^2), x) == :(2//7*A*b^5*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+2//21*b^3*d^-1*(b*cos(c+d*x))^-3//2*(5A+7C)*sin(c+d*x)+2//21*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5A+7C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*(A+C*cos(c+d*x)^2), x) == :(2//9*C*b^-1*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+2//45*b*d^-1*(b*cos(c+d*x))^3//2*(7C+9A)*sin(c+d*x)+2//15*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(7C+9A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*(A+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//7*C*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//21*b^2*d^-1*(b*cos(c+d*x))^(1/2)*(5C+7A)*sin(c+d*x)+2//21*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5C+7A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(2//5*C*b*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//5*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+5A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(2//3*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//3*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(C+3A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(2*A*b^3*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-2*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+-1C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^5*(A+C*cos(c+d*x)^2), x) == :(2//3*A*b^4*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//3*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+3C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^6*(A+C*cos(c+d*x)^2), x) == :(2//5*A*b^5*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//5*b^3*d^-1*(b*cos(c+d*x))^-1//2*(3A+5C)*sin(c+d*x)+-2//5*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+5C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^7*(A+C*cos(c+d*x)^2), x) == :(2//7*A*b^6*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+2//21*b^4*d^-1*(b*cos(c+d*x))^-3//2*(5A+7C)*sin(c+d*x)+2//21*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5A+7C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(1//77*b^-3*d^-1*(b*cos(c+d*x))^5//2*(18C+22A)*sin(c+d*x)+1//231*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*(90C+110A)*sin(c+d*x)+1//231*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(90C+110A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//11*C*b^-5*d^-1*(b*cos(c+d*x))^9//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(1//45*b^-2*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//9*C*b^-4*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+1//15*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(1//21*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*(10C+14A)*sin(c+d*x)+1//21*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10C+14A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//7*C*b^-3*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*(A+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(2//5*C*b^-2*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+1//5*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*(A+C*cos(c+d*x)^2), x) == :(1//3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+6A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//3*C*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*(A+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2*A*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-1*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*sec(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(1//3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2A+6C)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//3*A*b*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*sec(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(1//5*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+2//5*A*b^2*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+-1//5*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*sec(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(1//21*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10A+14C)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//7*A*b^3*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+2//21*b*d^-1*(b*cos(c+d*x))^-3//2*(5A+7C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*sec(c+d*x)^5*(A+C*cos(c+d*x)^2), x) == :(1//15*d^-1*(b*cos(c+d*x))^-1//2*(14A+18C)*sin(c+d*x)+2//9*A*b^4*d^-1*(b*cos(c+d*x))^-9//2*sin(c+d*x)+2//45*b^2*d^-1*(b*cos(c+d*x))^-5//2*(7A+9C)*sin(c+d*x)+-1//15*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14A+18C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(1//45*b^-3*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//9*C*b^-5*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+1//15*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(1//21*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*(10C+14A)*sin(c+d*x)+2//7*C*b^-4*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+1//21*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10C+14A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(2//5*C*b^-3*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+1//5*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*(A+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(2//3*C*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+1//3*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+6A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*(A+C*cos(c+d*x)^2), x) == :(2*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-1*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*(A+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//3*A*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+1//3*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2A+6C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*sec(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(1//5*b^-1*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+2//5*A*b*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+-1//5*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*sec(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(1//21*d^-1*(b*cos(c+d*x))^-3//2*(10A+14C)*sin(c+d*x)+2//7*A*b^2*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+1//21*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10A+14C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^5*(A+C*cos(c+d*x)^2), x) == :(1//45*b^-4*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//9*C*b^-6*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+1//15*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^4*(A+C*cos(c+d*x)^2), x) == :(1//21*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*(10C+14A)*sin(c+d*x)+2//7*C*b^-5*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+1//21*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10C+14A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^3*(A+C*cos(c+d*x)^2), x) == :(2//5*C*b^-4*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+1//5*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(2//3*C*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+1//3*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+6A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*(A+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(2*A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-1*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*(A+C*cos(c+d*x)^2), x) == :(2//3*A*b^-1*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+1//3*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2A+6C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*(A+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//5*A*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+1//5*b^-2*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+-1//5*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*sec(c+d*x)^2*(A+C*cos(c+d*x)^2), x) == :(1//21*b^-1*d^-1*(b*cos(c+d*x))^-3//2*(10A+14C)*sin(c+d*x)+2//7*A*b*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+1//21*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10A+14C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-7//2*(A+C*cos(c+d*x)^2), x) == :(1//5*b^-3*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+2//5*A*b^-1*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+-1//5*b^-4*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-9//2*(A+C*cos(c+d*x)^2), x) == :(1//21*b^-3*d^-1*(b*cos(c+d*x))^-3//2*(10A+14C)*sin(c+d*x)+2//7*A*b^-1*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+1//21*b^-4*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10A+14C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*(A+C*cos(c+d*x)^2), x) == :(d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+C)*sin(c+d*x)+-1//3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3*(A+2C)+1//5*C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^5)
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^3//2*(A+C*cos(c+d*x)^2), x) == :(1//8*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+4A)+1//4*C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(A+C*cos(c+d*x)^2), x) == :(d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+C)*sin(c+d*x)+-1//3*C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3)
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+C*cos(c+d*x)^2), x) == :(A*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*(A+C*cos(c+d*x)^2), x) == :(A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*(A+C*cos(c+d*x)^2), x) == :(C*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*(A+C*cos(c+d*x)^2), x) == :((1/2)*A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-9//2*(A+C*cos(c+d*x)^2), x) == :(1//3*A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)+1//3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-11//2*(A+C*cos(c+d*x)^2), x) == :(1//4*A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-9//2*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*(3A+4C)*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+4C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^3//2*(A+C*cos(c+d*x)^2), x) == :(b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+C)*sin(c+d*x)+-1//3*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3*(A+2C)+1//5*C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^5)
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^(1/2)*(A+C*cos(c+d*x)^2), x) == :(1//8*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+4A)+1//4*C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//8*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-1//2*(A+C*cos(c+d*x)^2), x) == :(b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+C)*sin(c+d*x)+-1//3*C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3)
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-3//2*(A+C*cos(c+d*x)^2), x) == :(A*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-5//2*(A+C*cos(c+d*x)^2), x) == :(A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-7//2*(A+C*cos(c+d*x)^2), x) == :(C*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-9//2*(A+C*cos(c+d*x)^2), x) == :((1/2)*A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-11//2*(A+C*cos(c+d*x)^2), x) == :(1//3*A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)+1//3*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-13//2*(A+C*cos(c+d*x)^2), x) == :(1//4*A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-9//2*sin(c+d*x)+1//8*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*(3A+4C)*sin(c+d*x)+1//8*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+4C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^(1/2)*(A+C*cos(c+d*x)^2), x) == :(b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+C)*sin(c+d*x)+-1//3*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3*(A+2C)+1//5*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^5)
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-1//2*(A+C*cos(c+d*x)^2), x) == :(1//8*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+4A)+1//4*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//8*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-3//2*(A+C*cos(c+d*x)^2), x) == :(b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+C)*sin(c+d*x)+-1//3*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3)
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-5//2*(A+C*cos(c+d*x)^2), x) == :(A*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-7//2*(A+C*cos(c+d*x)^2), x) == :(A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-9//2*(A+C*cos(c+d*x)^2), x) == :(C*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-11//2*(A+C*cos(c+d*x)^2), x) == :((1/2)*A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-13//2*(A+C*cos(c+d*x)^2), x) == :(1//3*A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)+1//3*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-15//2*(A+C*cos(c+d*x)^2), x) == :(1//4*A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-9//2*sin(c+d*x)+1//8*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*(3A+4C)*sin(c+d*x)+1//8*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+4C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^5//2*(A+C*cos(c+d*x)^2), x) == :(1//8*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3C+4A)+1//4*C*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^7//2*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*(A+C*cos(c+d*x)^2), x) == :(d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+C)*sin(c+d*x)+-1//3*C*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)^3)
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+C*cos(c+d*x)^2), x) == :(A*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*(A+C*cos(c+d*x)^2), x) == :(A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+C*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*(A+C*cos(c+d*x)^2), x) == :(C*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*(A+C*cos(c+d*x)^2), x) == :((1/2)*A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-7//2*(A+C*cos(c+d*x)^2), x) == :(1//3*A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)+1//3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-9//2*(A+C*cos(c+d*x)^2), x) == :(1//4*A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-7//2*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3A+4C)*arctanh(sin(c+d*x))+1//8*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*(3A+4C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^7//2*(A+C*cos(c+d*x)^2), x) == :(1//8*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3C+4A)+1//4*C*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^7//2*sin(c+d*x)+1//8*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^5//2*(A+C*cos(c+d*x)^2), x) == :(b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+C)*sin(c+d*x)+-1//3*C*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)^3)
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^3//2*(A+C*cos(c+d*x)^2), x) == :(A*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^(1/2)*(A+C*cos(c+d*x)^2), x) == :(A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+C*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^-1//2*(A+C*cos(c+d*x)^2), x) == :(C*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^-3//2*(A+C*cos(c+d*x)^2), x) == :((1/2)*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^-5//2*(A+C*cos(c+d*x)^2), x) == :(1//3*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)+1//3*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^-7//2*(A+C*cos(c+d*x)^2), x) == :(1//4*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-7//2*sin(c+d*x)+1//8*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3A+4C)*arctanh(sin(c+d*x))+1//8*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*(3A+4C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^9//2*(A+C*cos(c+d*x)^2), x) == :(1//8*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3C+4A)+1//4*C*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^7//2*sin(c+d*x)+1//8*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^7//2*(A+C*cos(c+d*x)^2), x) == :(b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+C)*sin(c+d*x)+-1//3*C*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)^3)
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^5//2*(A+C*cos(c+d*x)^2), x) == :(A*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^3//2*(A+C*cos(c+d*x)^2), x) == :(A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+C*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^(1/2)*(A+C*cos(c+d*x)^2), x) == :(C*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^-1//2*(A+C*cos(c+d*x)^2), x) == :((1/2)*A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^-3//2*(A+C*cos(c+d*x)^2), x) == :(1//3*A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)+1//3*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^-5//2*(A+C*cos(c+d*x)^2), x) == :(1//4*A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-7//2*sin(c+d*x)+1//8*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3A+4C)*arctanh(sin(c+d*x))+1//8*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*(3A+4C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(10//21*B*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+1//15*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+1//45*b^-1*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//7*B*b^-2*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//9*C*b^-3*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+10//21*B*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(1//21*d^-1*(b*cos(c+d*x))^(1/2)*(10C+14A)*sin(c+d*x)+2//5*B*b^-1*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//7*C*b^-2*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+6//5*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//21*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5C+7A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*B*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+1//5*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//5*C*b^-1*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//3*B*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//3*C*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(C+3A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*sec(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2*A*b*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+2*B*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*sec(c+d*x)^3*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(-2*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2*B*b*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+2//3*A*b^2*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//3*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+3C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*sec(c+d*x)^4*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(-1//5*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*B*b^2*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//5*A*b^3*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//5*b*d^-1*(b*cos(c+d*x))^-1//2*(3A+5C)*sin(c+d*x)+2//3*B*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*sec(c+d*x)^5*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(-6//5*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//5*B*b^3*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//7*A*b^4*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+2//21*b^2*d^-1*(b*cos(c+d*x))^-3//2*(5A+7C)*sin(c+d*x)+6//5*B*b*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+2//21*b*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5A+7C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(1//45*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//7*B*b^-1*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//9*C*b^-2*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+10//21*B*b*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//15*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(7C+9A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+10//21*B*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//5*B*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//7*C*b^-1*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//21*b*d^-1*(b*cos(c+d*x))^(1/2)*(5C+7A)*sin(c+d*x)+2//21*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5C+7A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+6//5*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//5*C*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//3*B*b*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//3*B*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//5*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+5A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*C*b*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(C+3A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^3*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2*A*b^2*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-2*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+-1C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2*B*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^4*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2*B*b^2*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+2//3*A*b^3*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+-2*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+3C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^5*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*B*b^3*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//5*A*b^4*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//5*b^2*d^-1*(b*cos(c+d*x))^-1//2*(3A+5C)*sin(c+d*x)+-2//5*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+5C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*B*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^3//2*sec(c+d*x)^6*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//5*B*b^4*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//7*A*b^5*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+2//21*b^3*d^-1*(b*cos(c+d*x))^-3//2*(5A+7C)*sin(c+d*x)+6//5*B*b^2*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-6//5*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//21*b^2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5A+7C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//7*B*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//9*C*b^-1*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+2//45*b*d^-1*(b*cos(c+d*x))^3//2*(7C+9A)*sin(c+d*x)+10//21*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//15*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(7C+9A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+10//21*B*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//7*C*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//5*B*b*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//21*b^2*d^-1*(b*cos(c+d*x))^(1/2)*(5C+7A)*sin(c+d*x)+2//21*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5C+7A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+6//5*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//5*C*b*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//3*B*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//5*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+5A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^3*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(C+3A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^4*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2*A*b^3*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-2*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+-1C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2*B*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^5*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2*B*b^3*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+2//3*A*b^4*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+-2*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+3C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^6*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*B*b^4*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//5*A*b^5*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//5*b^3*d^-1*(b*cos(c+d*x))^-1//2*(3A+5C)*sin(c+d*x)+-2//5*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+5C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*B*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^5//2*sec(c+d*x)^7*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//5*B*b^5*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//7*A*b^6*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+2//21*b^4*d^-1*(b*cos(c+d*x))^-3//2*(5A+7C)*sin(c+d*x)+6//5*B*b^3*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-6//5*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//21*b^3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(5A+7C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^3*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//45*b^-2*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//7*B*b^-3*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//9*C*b^-4*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+10//21*B*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+10//21*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+1//15*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//21*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*(10C+14A)*sin(c+d*x)+1//21*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10C+14A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//5*B*b^-2*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//7*C*b^-3*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+6//5*B*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(2//3*B*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//3*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//5*C*b^-2*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+1//5*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+6A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//3*C*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2*B*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2*A*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+2*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+-1*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*sec(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2*B*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+1//3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2A+6C)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//3*A*b*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+-2*B*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*sec(c+d*x)^3*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//5*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+2//3*B*b*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//3*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//5*A*b^2*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+-1//5*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-1//2*sec(c+d*x)^4*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(6//5*B*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+1//21*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10A+14C)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+2//5*B*b^2*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//7*A*b^3*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+2//21*b*d^-1*(b*cos(c+d*x))^-3//2*(5A+7C)*sin(c+d*x)+-6//5*B*b^-1*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^4*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//45*b^-3*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//7*B*b^-4*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//9*C*b^-5*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+10//21*B*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+1//15*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+10//21*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^3*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//21*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*(10C+14A)*sin(c+d*x)+2//5*B*b^-3*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//7*C*b^-4*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+1//21*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10C+14A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+6//5*B*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*B*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//5*C*b^-3*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+1//5*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(2//3*C*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2*B*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+1//3*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+6A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-1*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//3*A*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-2*B*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+1//3*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2A+6C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*sec(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*B*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+1//5*b^-1*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+2//5*A*b*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+-1//5*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-3//2*sec(c+d*x)^3*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//21*d^-1*(b*cos(c+d*x))^-3//2*(10A+14C)*sin(c+d*x)+2//5*B*b*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+2//7*A*b^2*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+6//5*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-6//5*B*b^-2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+1//21*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10A+14C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^5*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//45*b^-4*d^-1*(b*cos(c+d*x))^3//2*(14C+18A)*sin(c+d*x)+2//7*B*b^-5*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+2//9*C*b^-6*d^-1*(b*cos(c+d*x))^7//2*sin(c+d*x)+10//21*B*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+1//15*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(14C+18A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+10//21*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^4*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//21*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*(10C+14A)*sin(c+d*x)+2//5*B*b^-4*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+2//7*C*b^-5*d^-1*(b*cos(c+d*x))^5//2*sin(c+d*x)+1//21*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10C+14A)*Elliptic.F((1/2)*c+(1/2)*d*x,2)+6//5*B*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^3*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*B*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2//5*C*b^-4*d^-1*(b*cos(c+d*x))^3//2*sin(c+d*x)+1//5*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6C+10A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//3*C*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*sin(c+d*x)+2*B*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+1//3*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+6A)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*cos(c+d*x), x) == :(2*A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-1*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(-2C+2A)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+2//3*A*b^-1*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+-2*B*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+1//3*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2A+6C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2)*sec(c+d*x), x) == :(2//5*A*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+1//5*b^-2*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+2//3*B*b^-1*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+-1//5*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-5//2*sec(c+d*x)^2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(2//5*B*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+1//21*b^-1*d^-1*(b*cos(c+d*x))^-3//2*(10A+14C)*sin(c+d*x)+2//7*A*b*d^-1*(b*cos(c+d*x))^-7//2*sin(c+d*x)+6//5*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*sin(c+d*x)+-6//5*B*b^-3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*Elliptic.E((1/2)*c+(1/2)*d*x,2)+1//21*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(10A+14C)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^-7//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//5*b^-3*d^-1*(b*cos(c+d*x))^-1//2*(6A+10C)*sin(c+d*x)+2//3*B*b^-2*d^-1*(b*cos(c+d*x))^-3//2*sin(c+d*x)+2//5*A*b^-1*d^-1*(b*cos(c+d*x))^-5//2*sin(c+d*x)+-1//5*b^-4*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(6A+10C)*Elliptic.E((1/2)*c+(1/2)*d*x,2)+2//3*B*b^-3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*Elliptic.F((1/2)*c+(1/2)*d*x,2))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(3//8*B*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+-1//15*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3*(4C+5A)+1//4*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//5*C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^7//2*sin(c+d*x)+1//5*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(4C+5A)*sin(c+d*x)+3//8*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//8*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+4A)+B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)+-1//3*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3+1//4*C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x)+1//3*C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^3//2*sin(c+d*x)+1//3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(2C+3A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(A*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)+(1/2)*C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+C*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(C*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-9//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+1//3*A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)+1//3*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^(1/2)*cos(c+d*x)^-11//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+1//3*B*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)^3+1//4*A*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-9//2*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*(3A+4C)*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+4C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(3//8*B*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+-1//15*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3*(4C+5A)+1//4*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//5*C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^7//2*sin(c+d*x)+1//5*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(4C+5A)*sin(c+d*x)+3//8*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//8*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+4A)+B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)+-1//3*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3+1//4*C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//8*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x)+1//3*C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^3//2*sin(c+d*x)+1//3*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(2C+3A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(A*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)+(1/2)*C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+C*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-7//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(C*b*x*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-9//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-11//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+1//3*A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)+1//3*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^3//2*cos(c+d*x)^-13//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+1//3*B*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)^3+1//4*A*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-9//2*sin(c+d*x)+1//8*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*(3A+4C)*sin(c+d*x)+1//8*b*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+4C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(3//8*B*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+-1//15*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3*(4C+5A)+1//4*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//5*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^7//2*sin(c+d*x)+1//5*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(4C+5A)*sin(c+d*x)+3//8*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//8*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3C+4A)+B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)+-1//3*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)^3+1//4*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^5//2*sin(c+d*x)+1//8*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x)+1//3*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^3//2*sin(c+d*x)+1//3*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(2C+3A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(A*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+(1/2)*C*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x)+(1/2)*C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-7//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+C*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-9//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(C*x*b^2*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2+A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-11//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-13//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*sin(c+d*x)+(1/2)*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*arctanh(sin(c+d*x))+1//3*A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)+1//3*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^5//2*cos(c+d*x)^-15//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-3//2*sin(c+d*x)+1//3*B*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-7//2*sin(c+d*x)^3+1//4*A*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-9//2*sin(c+d*x)+1//8*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-5//2*(3A+4C)*sin(c+d*x)+1//8*b^2*d^-1*(b*cos(c+d*x))^(1/2)*cos(c+d*x)^-1//2*(3A+4C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//8*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3C+4A)+B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)+-1//3*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)^3+1//4*C*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^7//2*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x)+1//3*C*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^5//2*sin(c+d*x)+1//3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+3A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(A*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)+(1/2)*C*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+C*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(C*x*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+(1/2)*A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-7//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+(1/2)*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+1//3*A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)+1//3*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-1//2*cos(c+d*x)^-9//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+1//3*B*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)^3+1//4*A*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-7//2*sin(c+d*x)+1//8*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3A+4C)*arctanh(sin(c+d*x))+1//8*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*(3A+4C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^7//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//8*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3C+4A)+B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)+-1//3*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)^3+1//4*C*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^7//2*sin(c+d*x)+1//8*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x)+1//3*C*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^5//2*sin(c+d*x)+1//3*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+3A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(A*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)+(1/2)*C*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+C*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(C*x*b^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+(1/2)*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+(1/2)*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+1//3*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)+1//3*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-3//2*cos(c+d*x)^-7//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+1//3*B*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)^3+1//4*A*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-7//2*sin(c+d*x)+1//8*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3A+4C)*arctanh(sin(c+d*x))+1//8*b^-1*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*(3A+4C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^9//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(1//8*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3C+4A)+B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)+-1//3*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)^3+1//4*C*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^7//2*sin(c+d*x)+1//8*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*(3C+4A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^7//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x)+1//3*C*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^5//2*sin(c+d*x)+1//3*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(2C+3A)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(A*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+(1/2)*C*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x)+(1/2)*C*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^3//2*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+C*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^(1/2)*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(C*x*b^-2*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)+A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^-1//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+(1/2)*A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+(1/2)*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(A+2C)*arctanh(sin(c+d*x)))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^-3//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :((1/2)*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*arctanh(sin(c+d*x))+(1/2)*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*sin(c+d*x)+1//3*A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)+1//3*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*(2A+3C)*sin(c+d*x))
@test integrate((b*cos(c+d*x))^-5//2*cos(c+d*x)^-5//2*(A+B*cos(c+d*x)+C*cos(c+d*x)^2), x) == :(B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-1//2*sin(c+d*x)+1//3*B*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-5//2*sin(c+d*x)^3+1//4*A*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-7//2*sin(c+d*x)+1//8*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^(1/2)*(3A+4C)*arctanh(sin(c+d*x))+1//8*b^-2*d^-1*(b*cos(c+d*x))^-1//2*cos(c+d*x)^-3//2*(3A+4C)*sin(c+d*x))

max_stars_repo_path: test/4 Trig functions/4.2 Cosine/4.2.4.1 (a+b cos)^m (A+B cos+C cos^2).jl


text:
@testset "code generation" begin

############################################################################################

@testset "LLVM IR" begin

@testset "basic reflection" begin
    valid_kernel() = return
    invalid_kernel() = 1

    ir = sprint(io->CUDAnative.code_llvm(io, valid_kernel, Tuple{}; optimize=false, dump_module=true))

    # module should contain our function + a generic call wrapper
    @test occursin("define void @julia_valid_kernel", ir)
    @test !occursin("define %jl_value_t* @jlcall_", ir)

    # there should be no debug metadata
    @test !occursin("!dbg", ir)

    @test CUDAnative.code_llvm(devnull, invalid_kernel, Tuple{}) == nothing
    @test_throws CUDAnative.KernelError CUDAnative.code_llvm(devnull, invalid_kernel, Tuple{}; kernel=true) == nothing
end

@testset "unbound typevars" begin
    invalid_kernel() where {unbound} = return
    @test_throws CUDAnative.KernelError CUDAnative.code_llvm(devnull, invalid_kernel, Tuple{})
end

@testset "exceptions" begin
    foobar() = throw(DivideError())
    ir = sprint(io->CUDAnative.code_llvm(io, foobar, Tuple{}))

    # plain exceptions should get lowered to a call to the CUDAnative run-time
    @test occursin("ptx_report_exception", ir)
    # not a jl_throw referencing a jl_value_t representing the exception
    @test !occursin("jl_value_t", ir)
    @test !occursin("jl_throw", ir)
end

@testset "sysimg" begin
    # bug: use a system image function

    function foobar(a,i)
        Base.pointerset(a, 0, mod1(i,10), 8)
    end

    ir = sprint(io->CUDAnative.code_llvm(io, foobar, Tuple{Ptr{Int},Int}))
    @test !occursin("jlsys_", ir)
end

@testset "child functions" begin
    # we often test using `@noinline sink` child functions, so test whether these survive
    @noinline child(i) = sink(i)
    parent(i) = child(i)

    ir = sprint(io->CUDAnative.code_llvm(io, parent, Tuple{Int}))
    @test occursin(r"call .+ @julia_child_", ir)
end

@testset "JuliaLang/julia#21121" begin
    function foobar()
        weight_matrix = @cuStaticSharedMem(Float32, (16, 16))
        sync_threads()
        weight_matrix[1, 16] *= 2
        sync_threads()
    end

    ir = sprint(io->CUDAnative.code_llvm(io, foobar, Tuple{}))
    @test !occursin("inttoptr", ir)
end

@testset "kernel functions" begin
@testset "wrapper function aggregate rewriting" begin
    kernel(x) = return

    @eval struct Aggregate
        x::Int
    end

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{Aggregate}))
    @test occursin(r"@julia_kernel_\d+\(({ i64 }|\[1 x i64\]) addrspace\(\d+\)?\*", ir)

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{Aggregate}; kernel=true))
    @test occursin(r"@ptxcall_kernel_\d+\(({ i64 }|\[1 x i64\])\)", ir)
end

@testset "property_annotations" begin
    kernel() = return

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{}; dump_module=true))
    @test !occursin("nvvm.annotations", ir)

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{};
                                         dump_module=true, kernel=true))
    @test occursin("nvvm.annotations", ir)
    @test !occursin("maxntid", ir)
    @test !occursin("reqntid", ir)
    @test !occursin("minctasm", ir)
    @test !occursin("maxnreg", ir)

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{};
                                         dump_module=true, kernel=true, maxthreads=42))
    @test occursin("maxntidx\", i32 42", ir)
    @test occursin("maxntidy\", i32 1", ir)
    @test occursin("maxntidz\", i32 1", ir)

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{};
                                         dump_module=true, kernel=true, minthreads=42))
    @test occursin("reqntidx\", i32 42", ir)
    @test occursin("reqntidy\", i32 1", ir)
    @test occursin("reqntidz\", i32 1", ir)

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{};
                                         dump_module=true, kernel=true, blocks_per_sm=42))
    @test occursin("minctasm\", i32 42", ir)

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{};
                                         dump_module=true, kernel=true, maxregs=42))
    @test occursin("maxnreg\", i32 42", ir)
end
end

@testset "LLVM D32593" begin
    @eval struct D32593_struct
        foo::Float32
        bar::Float32
    end

    D32593(arr) = arr[1].foo

    CUDAnative.code_llvm(devnull, D32593, Tuple{CuDeviceVector{D32593_struct,AS.Global}})
end

@testset "kernel names" begin
    regular() = return
    closure = ()->return

    function test_name(f, name; kwargs...)
        code = sprint(io->CUDAnative.code_llvm(io, f, Tuple{}; kwargs...))
        @test occursin(name, code)
    end

    test_name(regular, "julia_regular")
    test_name(regular, "ptxcall_regular"; kernel=true)
    test_name(closure, "julia_anonymous")
    test_name(closure, "ptxcall_anonymous"; kernel=true)
end

@testset "PTX TBAA" begin
    load(ptr) = unsafe_load(ptr)
    store(ptr) = unsafe_store!(ptr, 0)

    for f in (load, store)
        ir = sprint(io->CUDAnative.code_llvm(io, f,
                                             Tuple{CUDAnative.DevicePtr{Float32,AS.Global}};
                                             dump_module=true))
        @test occursin("ptxtbaa_global", ir)

        # no TBAA on generic pointers
        ir = sprint(io->CUDAnative.code_llvm(io, f,
                                             Tuple{CUDAnative.DevicePtr{Float32,AS.Generic}};
                                             dump_module=true))
        @test !occursin("ptxtbaa", ir)
    end

    cached_load(ptr) = unsafe_cached_load(ptr)

    ir = sprint(io->CUDAnative.code_llvm(io, cached_load,
                                         Tuple{CUDAnative.DevicePtr{Float32,AS.Global}};
                                         dump_module=true))
    @test occursin("ptxtbaa_global", ir)
end

@testset "tracked pointers" begin
    function kernel(a)
        a[1] = 1
        return
    end

    # this used to throw an LLVM assertion (#223)
    CUDAnative.code_llvm(devnull, kernel, Tuple{Vector{Int}}; kernel=true)
end

if VERSION >= v"1.0.2"
@testset "CUDAnative.jl#278" begin
    # codegen idempotency
    # NOTE: this isn't fixed, but surfaces here due to bad inference of checked_sub
    # NOTE: with the fix to print_to_string this doesn't error anymore,
    #       but still have a test to make sure it doesn't regress
    CUDAnative.code_llvm(devnull, Base.checked_sub, Tuple{Int,Int}; optimize=false)
    CUDAnative.code_llvm(devnull, Base.checked_sub, Tuple{Int,Int}; optimize=false)

    # breaking recursion in print_to_string makes it possible to compile
    # even in the presence of the above bug
    CUDAnative.code_llvm(devnull, Base.print_to_string, Tuple{Int,Int}; optimize=false)
end
end

end

############################################################################################

@testset "PTX assembly" begin

@testset "basic reflection" begin
    valid_kernel() = return
    invalid_kernel() = 1

    @test CUDAnative.code_ptx(devnull, valid_kernel, Tuple{}) == nothing
    @test CUDAnative.code_ptx(devnull, invalid_kernel, Tuple{}) == nothing
    @test_throws CUDAnative.KernelError CUDAnative.code_ptx(devnull, invalid_kernel, Tuple{}; kernel=true)
end

@testset "child functions" begin
    # we often test using @noinline child functions, so test whether these survive
    # (despite not having side-effects)
    @noinline child(i) = sink(i)
    function parent(i)
        child(i)
        return
    end

    asm = sprint(io->CUDAnative.code_ptx(io, parent, Tuple{Int64}))
    @test occursin(r"call.uni\s+julia_child_"m, asm)
end

@testset "kernel functions" begin
    @noinline nonentry(i) = sink(i)
    function entry(i)
        nonentry(i)
        return
    end

    asm = sprint(io->CUDAnative.code_ptx(io, entry, Tuple{Int64}; kernel=true))
    @test occursin(r"\.visible \.entry ptxcall_entry_", asm)
    @test !occursin(r"\.visible \.func julia_nonentry_", asm)
    @test occursin(r"\.func julia_nonentry_", asm)

@testset "property_annotations" begin
    asm = sprint(io->CUDAnative.code_ptx(io, entry, Tuple{Int64}; kernel=true))
    @test !occursin("maxntid", asm)

    asm = sprint(io->CUDAnative.code_ptx(io, entry, Tuple{Int64};
                                         kernel=true, maxthreads=42))
    @test occursin(".maxntid 42, 1, 1", asm)

    asm = sprint(io->CUDAnative.code_ptx(io, entry, Tuple{Int64};
                                         kernel=true, minthreads=42))
    @test occursin(".reqntid 42, 1, 1", asm)

    asm = sprint(io->CUDAnative.code_ptx(io, entry, Tuple{Int64};
                                         kernel=true, blocks_per_sm=42))
    @test occursin(".minnctapersm 42", asm)

    if LLVM.version() >= v"4.0"
        asm = sprint(io->CUDAnative.code_ptx(io, entry, Tuple{Int64};
                                             kernel=true, maxregs=42))
        @test occursin(".maxnreg 42", asm)
    end
end
end

@testset "idempotency" begin
    # bug: generate code twice for the same kernel (jl_to_ptx wasn't idempotent)

    kernel() = return
    CUDAnative.code_ptx(devnull, kernel, Tuple{})
    CUDAnative.code_ptx(devnull, kernel, Tuple{})
end

@testset "child function reuse" begin
    # bug: depending on a child function from multiple parents resulted in
    #      the child only being present once

    @noinline child(i) = sink(i)
    function parent1(i)
        child(i)
        return
    end

    asm = sprint(io->CUDAnative.code_ptx(io, parent1, Tuple{Int}))
    @test occursin(r".func julia_child_", asm)

    function parent2(i)
        child(i+1)
        return
    end

    asm = sprint(io->CUDAnative.code_ptx(io, parent2, Tuple{Int}))
    @test occursin(r".func julia_child_", asm)
end

@testset "child function reuse bis" begin
    # bug: similar, but slightly different issue as above
    #      in the case of two child functions
    @noinline child1(i) = sink(i)
    @noinline child2(i) = sink(i+1)
    function parent1(i)
        child1(i) + child2(i)
        return
    end
    CUDAnative.code_ptx(devnull, parent1, Tuple{Int})

    function parent2(i)
        child1(i+1) + child2(i+1)
        return
    end
    CUDAnative.code_ptx(devnull, parent2, Tuple{Int})
end

@testset "indirect sysimg function use" begin
    # issue #9: re-using sysimg functions should force recompilation
    #           (host fldmod1->mod1 throws, so the PTX code shouldn't contain a throw)

    # NOTE: Int32 to test for #49

    function kernel(out)
        wid, lane = fldmod1(unsafe_load(out), Int32(32))
        unsafe_store!(out, wid)
        return
    end

    asm = sprint(io->CUDAnative.code_ptx(io, kernel, Tuple{Ptr{Int32}}))
    @test !occursin("jl_throw", asm)
    @test !occursin("jl_invoke", asm)   # forced recompilation should still not invoke
end

@testset "compile for host after PTX" begin
    # issue #11: re-using host functions after PTX compilation
    @noinline child(i) = sink(i+1)

    function fromhost()
        child(10)
    end

    function fromptx()
        child(10)
        return
    end

    CUDAnative.code_ptx(devnull, fromptx, Tuple{})
    @test fromhost() == 11
end

@testset "LLVM intrinsics" begin
    # issue #13 (a): cannot select trunc
    function kernel(x)
        unsafe_trunc(Int, x)
        return
    end
    CUDAnative.code_ptx(devnull, kernel, Tuple{Float64})
end

@testset "kernel names" begin
    regular() = nothing
    closure = ()->nothing

    function test_name(f, name; kwargs...)
        code = sprint(io->CUDAnative.code_ptx(io, f, Tuple{}; kwargs...))
        @test occursin(name, code)
    end

    test_name(regular, "julia_regular")
    test_name(regular, "ptxcall_regular"; kernel=true)
    test_name(closure, "julia_anonymous")
    test_name(closure, "ptxcall_anonymous"; kernel=true)
end

@testset "exception arguments" begin
    function kernel(a)
        unsafe_store!(a, trunc(Int, unsafe_load(a)))
        return
    end

    CUDAnative.code_ptx(devnull, kernel, Tuple{Ptr{Float64}})
end

@testset "GC and TLS lowering" begin
    @eval mutable struct PleaseAllocate
        y::Csize_t
    end

    # common pattern in Julia 0.7: outlined throw to avoid a GC frame in the calling code
    @noinline function inner(x)
        @cuprintln(x.y)
        nothing
    end

    function kernel(i)
        inner(PleaseAllocate(Csize_t(42)))
        nothing
    end

    asm = sprint(io->CUDAnative.code_ptx(io, kernel, Tuple{Int}))
    @test occursin("ptx_gc_pool_alloc", asm)

    # make sure that we can still ellide allocations
    function ref_kernel(out, i)
        data = Ref{Int64}()
        data[] = 0
        if i > 1
            data[] = 1
        else
            data[] = 2
        end
        out[i] = data[]
        return nothing
    end

    asm = sprint(io->CUDAnative.code_ptx(io, ref_kernel, Tuple{CuDeviceVector{Int64, AS.Global}, Int}))

    if VERSION < v"1.2.0-DEV.375"
        @test_broken !occursin("ptx_gc_pool_alloc", asm)
    else
        @test !occursin("ptx_gc_pool_alloc", asm)
    end
end

@testset "float boxes" begin
    function kernel(a,b)
        c = Int32(a)
        # the conversion to Int32 may fail, in which case the input Float32 is boxed in order to
        # pass it to the @nospecialize exception constructor. we should really avoid that (eg.
        # by avoiding @nospecialize, or optimize the unused arguments away), but for now the box
        # should just work.
        unsafe_store!(b, c)
        return
    end

    ir = sprint(io->CUDAnative.code_llvm(io, kernel, Tuple{Float32,Ptr{Float32}}))
    @test occursin("jl_box_float32", ir)
    CUDAnative.code_ptx(devnull, kernel, Tuple{Float32,Ptr{Float32}})
end

end

############################################################################################

@testset "errors" begin

# some validation happens in the emit_function hook, which is called by code_llvm

@testset "recursion" begin
    @eval recurse_outer(i) = i > 0 ? i : recurse_inner(i)
    @eval @noinline recurse_inner(i) = i < 0 ? i : recurse_outer(i)

    @test_throws_message(CUDAnative.KernelError, CUDAnative.code_llvm(devnull, recurse_outer, Tuple{Int})) do msg
        occursin("recursion is currently not supported", msg) &&
        occursin("[1] recurse_outer", msg) &&
        occursin("[2] recurse_inner", msg) &&
        occursin("[3] recurse_outer", msg)
    end
end

@testset "base intrinsics" begin
    foobar(i) = sin(i)

    # NOTE: we don't use test_logs in order to test all of the warning (exception, backtrace)
    logs, _ = Test.collect_test_logs() do
        CUDAnative.code_llvm(devnull, foobar, Tuple{Int})
    end
    @test length(logs) == 1
    record = logs[1]
    @test record.level == Base.CoreLogging.Warn
    @test record.message == "calls to Base intrinsics might be GPU incompatible"
    @test haskey(record.kwargs, :exception)
    err,bt = record.kwargs[:exception]
    err_msg = sprint(showerror, err)
    @test occursin(r"You called sin(.+) in Base.Math .+, maybe you intended to call sin(.+) in CUDAnative .+ instead?", err_msg)
    bt_msg = sprint(Base.show_backtrace, bt)
    @test occursin("[1] sin", bt_msg)
    @test occursin(r"\[2\] .+foobar", bt_msg)
end

# some validation happens in `compile`

@eval Main begin
struct CleverType{T}
    x::T
end
Base.unsafe_trunc(::Type{Int}, x::CleverType) = unsafe_trunc(Int, x.x)
end

@testset "non-isbits arguments" begin
    foobar(i) = (sink(unsafe_trunc(Int,i)); return)

    @test_throws_message(CUDAnative.KernelError,
                         CUDAnative.code_llvm(foobar, Tuple{BigInt}; strict=true)) do msg
        occursin("passing and using non-bitstype argument", msg) &&
        occursin("BigInt", msg)
    end

    # test that we can handle abstract types
    @test_throws_message(CUDAnative.KernelError,
                         CUDAnative.code_llvm(foobar, Tuple{Any}; strict=true)) do msg
        occursin("passing and using non-bitstype argument", msg) &&
        occursin("Any", msg)
    end

    @test_throws_message(CUDAnative.KernelError,
                         CUDAnative.code_llvm(foobar, Tuple{Union{Int32, Int64}}; strict=true)) do msg
        occursin("passing and using non-bitstype argument", msg) &&
        occursin("Union{Int32, Int64}", msg)
    end

    @test_throws_message(CUDAnative.KernelError,
                         CUDAnative.code_llvm(foobar, Tuple{Union{Int32, Int64}}; strict=true)) do msg
        occursin("passing and using non-bitstype argument", msg) &&
        occursin("Union{Int32, Int64}", msg)
    end

    # test that we get information about fields and reason why something is not isbits
    @test_throws_message(CUDAnative.KernelError,
                         CUDAnative.code_llvm(foobar, Tuple{CleverType{BigInt}}; strict=true)) do msg
        occursin("passing and using non-bitstype argument", msg) &&
        occursin("CleverType", msg) &&
        occursin("BigInt", msg)
    end
end

@testset "invalid LLVM IR" begin
    foobar(i) = println(i)

    @test_throws_message(CUDAnative.InvalidIRError,
                         CUDAnative.code_llvm(foobar, Tuple{Int}; strict=true)) do msg
        occursin("invalid LLVM IR", msg) &&
        occursin(CUDAnative.RUNTIME_FUNCTION, msg) &&
        occursin("[1] println", msg) &&
        occursin(r"\[2\] .+foobar", msg)
    end
end

@testset "invalid LLVM IR (ccall)" begin
    foobar(p) = (unsafe_store!(p, ccall(:time, Cint, ())); nothing)

    @test_throws_message(CUDAnative.InvalidIRError,
                         CUDAnative.code_llvm(foobar, Tuple{Ptr{Int}}; strict=true)) do msg
        occursin("invalid LLVM IR", msg) &&
        occursin(CUDAnative.POINTER_FUNCTION, msg) &&
        occursin(r"\[1\] .+foobar", msg)
    end
end

@testset "delayed bindings" begin
    kernel() = (undefined; return)

    @test_throws_message(CUDAnative.InvalidIRError,
                         CUDAnative.code_llvm(kernel, Tuple{}; strict=true)) do msg
        occursin("invalid LLVM IR", msg) &&
        occursin(CUDAnative.DELAYED_BINDING, msg) &&
        occursin("use of 'undefined'", msg) &&
        occursin(r"\[1\] .+kernel", msg)
    end
end

@testset "dynamic call (invoke)" begin
    @eval @noinline nospecialize_child(@nospecialize(i)) = i
    kernel(a, b) = (unsafe_store!(b, nospecialize_child(a)); return)

    @test_throws_message(CUDAnative.InvalidIRError,
                         CUDAnative.code_llvm(kernel, Tuple{Int,Ptr{Int}}; strict=true)) do msg
        occursin("invalid LLVM IR", msg) &&
        occursin(CUDAnative.DYNAMIC_CALL, msg) &&
        occursin("call to nospecialize_child", msg) &&
        occursin(r"\[1\] .+kernel", msg)
    end
end

@testset "dynamic call (apply)" begin
    func() = pointer(1)

    @test_throws_message(CUDAnative.InvalidIRError,
                         CUDAnative.code_llvm(func, Tuple{}; strict=true)) do msg
        occursin("invalid LLVM IR", msg) &&
        occursin(CUDAnative.DYNAMIC_CALL, msg) &&
        occursin("call to pointer", msg) &&
        occursin("[1] func", msg)
    end
end

end

############################################################################################

end

ext: jl


text:
module DayCounts

using Dates
import Dates: adjust

using BusinessDays

export DayCount, Actual360, Actual365, Thirty360, BondThirty360, EuroBondThirty360,
    ItalianThirty360, ISMAActualActual, ISDAActualActual, AFBActualActual,
    daycount, yearfraction,
    Unadjusted, Following, ModFollowing, Preceding, ModPreceding, adjust

abstract type DayCount end

struct Actual360 <: DayCount; end
struct Actual365 <: DayCount; end

abstract type Thirty360 <: DayCount end
struct BondThirty360     <: Thirty360; end
struct EuroBondThirty360 <: Thirty360; end
struct ItalianThirty360  <: Thirty360; end

const USAThirty360 = BondThirty360
const EuroThirty360 = EuroBondThirty360

abstract type ActualActual <: DayCount end
struct ISMAActualActual <: ActualActual; end
struct ISDAActualActual <: ActualActual; end
struct AFBActualActual  <: ActualActual; end

# immutable BusinessDay252 <: DayCount
# 	bc::BusinessCalendar
# end

string(::Actual360) = "Actual/360"
string(::Actual365) = "Actual/365 Fixed"
string(::BondThirty360) = "Thirty/360 Bond/USA basis"
string(::EuroBondThirty360) = "Thirty/360 EuroBond basis"
string(::ItalianThirty360) = "Thirty/360 Italian basis"

string(::ISMAActualActual) = "Actual/Actual ISMA basis"
string(::ISDAActualActual) = "Actual/Actual ISDA basis"
string(::AFBActualActual) = "Actual/Actual AFB basis"

#Fallback method just subtracts the dates
daycount(c::DayCount,  d_start::Date,  d_end::Date) = Dates.value(d_end - d_start)

function daycount(c::BondThirty360,  d_start::Date,  d_end::Date)
    dd1 = day(d_start)
    dd2 = day(d_end)
    mm1 = month(d_start)
    mm2 = month(d_end)
    yy1 = year(d_start)
    yy2 = year(d_end)

    if dd2 == 31 && dd1 < 30
    	dd2 = 1
    	mm2 = mm2+1
    end

    return 360*(yy2-yy1) + 30*(mm2-mm1-1) + max(0, 30-dd1) + min(30, dd2)
end

function daycount(c::EuroBondThirty360,  d_start::Date,  d_end::Date)
    dd1 = day(d_start)
    dd2 = day(d_end)
    mm1 = month(d_start)
    mm2 = month(d_end)
    yy1 = year(d_start)
    yy2 = year(d_end)

    return 360*(yy2-yy1) + 30*(mm2-mm1-1) + max(0, 30-dd1) + min(30, dd2)
end

function daycount(c::ItalianThirty360,  d_start::Date,  d_end::Date)
    dd1 = day(d_start)
    dd2 = day(d_end)
    mm1 = month(d_start)
    mm2 = month(d_end)
    yy1 = year(d_start)
    yy2 = year(d_end)

    if (mm1 == 2 && dd1 > 27)
        dd1 = 30
    end
    if (mm2 == 2 && dd2 > 27)
        dd2 = 30
    end

    return 360*(yy2-yy1) + 30*(mm2-mm1-1) + max(0, 30-dd1) + min(30, dd2)
end

# daycount(c::BusinessDay252, d_start::Date, d_end::Date) = businessDaysBetween(c.bc, d_start, d_end)

yearfraction(c::Union{Actual360,Thirty360},  d_start::Date,  d_end::Date) = daycount(c, d_start, d_end) / 360

yearfraction(c::Actual365, d_start::Date,  d_end::Date) = daycount(c, d_start, d_end) / 365
yearfraction(c::Actual365, d::Dates.Day) = Dates.value(d) / 365

function yearfraction(c::ISDAActualActual,  d_start::Date,  d_end::Date )

    if d_start == d_end
        return 0.0
    elseif d_start > d_end
        return -yearfraction(d_end, d_start)
    end

    y1 = year(d_start)
    y2 = year(d_end)
    dib1 = isleapyear(d_start) ? 366.0 : 365.0
    dib2 = isleapyear(d_end)   ? 366.0 : 365.0

    sum = y2 - y1 - 1

    #Days from start to starting of following year
    sum += (dib1 - dayofyear(d_start) + 1) / dib1
    #Days from beginning of year to the endDate
    sum += (dayofyear(d_end) - 1) / dib2
    return sum
end

function yearfraction(c::AFBActualActual,  d_start::Date,  d_end::Date )
    if (d_start == d_end ); return 0.0; end

    if (d_start > d_end)
        return -yearfraction(d_end, d_start)
    end

    newD2 = d_end
    temp = d_end
    sum = 0.0
    while (temp>d_start)
	temp = newD2-Year(1)
	if (day(temp) == 28 && month(temp) == 2 && isleapyear(temp))
	    temp + Day(1)
	end
	if (temp>=(d_start))
	    sum += 1.0
	    newD2 = temp
	end
    end

    den = 365.0

    if isleapyear(newD2)
	if (newD2 > Date(year(newD2), February, 29) && d_start < Date(year(newD2), February, 29) )
	    den += 1.0
	end
    elseif (isleapyear(d_start))
	if (newD2 > (ymd(year(d_start), February, 29)) && d_start < (ymd(year(d_start), February, 29)))
	    den += 1.0
	end
    end
    return sum + daycount(c, d_start, newD2) / den
end

yearfraction(c::ISMAActualActual,  d_start::Date,  d_end::Date ) = yearfraction(c, d_start, d_end, d_start, d_end)

function yearfraction(c::ISMAActualActual,  d_start::Date,  d_end::Date,  ref_start::Date,  ref_end::Date)

    if (d_start == d_end ); return 0.0; end

    if (d_start > d_end)
        return -yearfraction(d_end, d_start, ref_start, ref_end)
    end

    ref_period_start =  ref_start
    ref_period_end   = ref_end

    @assert ref_period_end > ref_period_start && ref_period_end > d_start

    # estimate roughly the length in months of a period
    mnths = floor(Int, 0.5 + 12 * daycount(c,  ref_period_start, ref_period_end) / 365)

    # for short periods, take the reference period as 1 year from d_start
    if (mnths == 0)
        ref_period_start = d_start
        ref_period_end = d_start + year(1)
        mnths = 12
    end

    period = mnths / 12.0

    if (d_end<=ref_period_end)
        # here ref_period_end is a future (notional?) payment date
        if (d_start>=ref_period_start)
            # here ref_period_start is the last (maybe notional)
            # payment date.
            # ref_period_start <= d_start <= d_end <= ref_period_end
            # [maybe the equality should be enforced, since
            # ref_period_start < d_start <= d_end < ref_period_end
            # could give wrong results] ???
            return period * daycount(c,d_start, d_end) / daycount(c,ref_period_start, ref_period_end)
        else
            # here ref_period_start is the next (maybe notional)
            # payment date and ref_period_end is the second next
            # (maybe notional) payment date.
            # d_start < ref_period_start < ref_period_end
            # AND d_end <= ref_period_end
            # this case is long first coupon

            # the last notional payment date
            previousRef = ref_period_start - Month(mnths)
            if (d_end>ref_period_start)
                return yearfraction(c, d_start, ref_period_start, previousRef,ref_period_start) + yearfraction(c,ref_period_start, d_end, ref_period_start, ref_period_end)
            else
                return yearfraction(d_start, d_end, previousRef,ref_period_start)
            end
        end
    else
        # here ref_period_end is the last notional payment date
        # d_start < ref_period_end < d_end AND ref_period_start < ref_period_end
        @assert ref_period_start<=d_start
        # now it is: ref_period_start <= d_start < ref_period_end < d_end

        # the part from d_start to ref_period_end
        sum = yearfraction(c,d_start, ref_period_end, ref_period_start, ref_period_end)

        # the part from ref_period_end to d_end
        # count how many regular periods are in [ref_period_end, d_end],
        # then add the remaining time
        i = 0
        local newRefStart, newRefEnd
        while true
            newRefStart = ref_period_end + months(months * i)
            newRefEnd = ref_period_end+ months(months * (i + 1))
            if (d_end<newRefEnd)
                break
            else
                sum += period
                i += 1
            end
        end
        sum += yearfraction(c, newRefStart, d_end, newRefStart, newRefEnd)
        return sum
    end
end

# yearfraction(c::BusinessDay252, d_start::Date, d_end::Date) = daycount(c, d_start, d_end) / 252

abstract type DateRoll end

struct Unadjusted <: DateRoll; end
struct Following <: DateRoll; end
struct ModFollowing <: DateRoll; end
struct Preceding <: DateRoll; end
struct ModPreceding <: DateRoll; end

adust(::Unadjusted, c::BusinessDays.HolidayCalendar, d::Date) = d

function adjust(::ModFollowing, c::BusinessDays.HolidayCalendar, dt::Date)
    newDt=adjust(Following(), c, dt)
    if month(newDt) != month(dt)
        return adjust(Preceding(), c, dt);
    end
    return newDt
end

function adjust(::Following, c::BusinessDays.HolidayCalendar, dt::Date)
    newDt=dt
    while (!isbday(c, newDt))
            newDt = newDt + Day(1)
    end
    return newDt
end

function adjust(::ModPreceding, c::BusinessDays.HolidayCalendar, dt::Date)
    newDt=adjust(Preceding(), c, dt)
    if month(newDt) != month(dt)
        return adjust(Following(), c, dt);
    end
    return newDt
end

function adjust(::Preceding, c::BusinessDays.HolidayCalendar, dt::Date)
    newDt=dt
    while (!isbday(c, newDt))
            newDt = newDt - Day(1)
    end
    return newDt
end

end #Module DayCounts