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

@test integrate(x^6*(a+b*arccsch(c*x)), x) == :(1//7*x^7*(a+b*arccsch(c*x))+-5//112*b*c^-7*arctanh((1+c^-2*x^-2)^(1/2))+-5//168*b*c^-3*x^4*(1+c^-2*x^-2)^(1/2)+1//42*b*c^-1*x^6*(1+c^-2*x^-2)^(1/2)+5//112*b*c^-5*x^2*(1+c^-2*x^-2)^(1/2))
@test integrate(x^5*(a+b*arccsch(c*x)), x) == :(1//6*x^6*(a+b*arccsch(c*x))+-2//45*b*c^-3*x^3*(1+c^-2*x^-2)^(1/2)+1//30*b*c^-1*x^5*(1+c^-2*x^-2)^(1/2)+4//45*b*x*c^-5*(1+c^-2*x^-2)^(1/2))
@test integrate(x^4*(a+b*arccsch(c*x)), x) == :(1//5*x^5*(a+b*arccsch(c*x))+3//40*b*c^-5*arctanh((1+c^-2*x^-2)^(1/2))+-3//40*b*c^-3*x^2*(1+c^-2*x^-2)^(1/2)+1//20*b*c^-1*x^4*(1+c^-2*x^-2)^(1/2))
@test integrate(x^3*(a+b*arccsch(c*x)), x) == :(1//4*x^4*(a+b*arccsch(c*x))+-1//6*b*x*c^-3*(1+c^-2*x^-2)^(1/2)+1//12*b*c^-1*x^3*(1+c^-2*x^-2)^(1/2))
@test integrate(x^2*(a+b*arccsch(c*x)), x) == :(1//3*x^3*(a+b*arccsch(c*x))+-1//6*b*c^-3*arctanh((1+c^-2*x^-2)^(1/2))+1//6*b*c^-1*x^2*(1+c^-2*x^-2)^(1/2))
@test integrate(x*(a+b*arccsch(c*x)), x) == :((1/2)*x^2*(a+b*arccsch(c*x))+(1/2)*b*x*c^-1*(1+c^-2*x^-2)^(1/2))
@test integrate(a+b*arccsch(c*x), x) == :(a*x+b*x*arccsch(c*x)+b*c^-1*arctanh((1+c^-2*x^-2)^(1/2)))
@test integrate(x^-1*(a+b*arccsch(c*x)), x) == :((1/2)*b^-1*(a+b*arccsch(c*x))^2+-1*(a+b*arccsch(c*x))*log(1+-1*exp(2*arccsch(c*x)))+-1//2*b*Polylogarithms.polylog(2,exp(2*arccsch(c*x))))
@test integrate(x^-2*(a+b*arccsch(c*x)), x) == :(-1*x^-1*(a+b*arccsch(c*x))+b*c*(1+c^-2*x^-2)^(1/2))
@test integrate(x^-3*(a+b*arccsch(c*x)), x) == :(-1//2*x^-2*(a+b*arccsch(c*x))+-1//4*b*c^2*arccsch(c*x)+1//4*b*c*x^-1*(1+c^-2*x^-2)^(1/2))
@test integrate(x^-4*(a+b*arccsch(c*x)), x) == :(-1//3*x^-3*(a+b*arccsch(c*x))+-1//3*b*c^3*(1+c^-2*x^-2)^(1/2)+1//9*b*c^3*(1+c^-2*x^-2)^3//2)
@test integrate(x^-5*(a+b*arccsch(c*x)), x) == :(-1//4*x^-4*(a+b*arccsch(c*x))+3//32*b*c^4*arccsch(c*x)+-3//32*b*c^3*x^-1*(1+c^-2*x^-2)^(1/2)+1//16*b*c*x^-3*(1+c^-2*x^-2)^(1/2))
@test integrate(x^-6*(a+b*arccsch(c*x)), x) == :(-1//5*x^-5*(a+b*arccsch(c*x))+-2//15*b*c^5*(1+c^-2*x^-2)^3//2+1//5*b*c^5*(1+c^-2*x^-2)^(1/2)+1//25*b*c^5*(1+c^-2*x^-2)^5//2)
@test integrate(x^-7*(a+b*arccsch(c*x)), x) == :(-1//6*x^-6*(a+b*arccsch(c*x))+-5//96*b*c^6*arccsch(c*x)+-5//144*b*c^3*x^-3*(1+c^-2*x^-2)^(1/2)+1//36*b*c*x^-5*(1+c^-2*x^-2)^(1/2)+5//96*b*c^5*x^-1*(1+c^-2*x^-2)^(1/2))
@test integrate(x^3*(a+b*arccsch(c*x))^2, x) == :(1//4*x^4*(a+b*arccsch(c*x))^2+-1//3*b^2*c^-4*log(x)+1//12*b^2*c^-2*x^2+-1//3*b*x*c^-3*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))+1//6*b*c^-1*x^3*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x)))
@test integrate(x^2*(a+b*arccsch(c*x))^2, x) == :(1//3*x^3*(a+b*arccsch(c*x))^2+-1//3*b^2*c^-3*Polylogarithms.polylog(2,-1*exp(arccsch(c*x)))+1//3*x*b^2*c^-2+1//3*b^2*c^-3*Polylogarithms.polylog(2,exp(arccsch(c*x)))+-2//3*b*c^-3*(a+b*arccsch(c*x))*arctanh(exp(arccsch(c*x)))+1//3*b*c^-1*x^2*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x)))
@test integrate(x*(a+b*arccsch(c*x))^2, x) == :((1/2)*x^2*(a+b*arccsch(c*x))^2+b^2*c^-2*log(x)+b*x*c^-1*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x)))
@test integrate((a+b*arccsch(c*x))^2, x) == :(x*(a+b*arccsch(c*x))^2+-2*b^2*c^-1*Polylogarithms.polylog(2,exp(arccsch(c*x)))+2*b^2*c^-1*Polylogarithms.polylog(2,-1*exp(arccsch(c*x)))+4*b*c^-1*(a+b*arccsch(c*x))*arctanh(exp(arccsch(c*x))))
@test integrate(x^-1*(a+b*arccsch(c*x))^2, x) == :((1/2)*b^2*Polylogarithms.polylog(3,exp(2*arccsch(c*x)))+-1*(a+b*arccsch(c*x))^2*log(1+-1*exp(2*arccsch(c*x)))+1//3*b^-1*(a+b*arccsch(c*x))^3+-1*b*(a+b*arccsch(c*x))*Polylogarithms.polylog(2,exp(2*arccsch(c*x))))
@test integrate(x^-2*(a+b*arccsch(c*x))^2, x) == :(-1*x^-1*(a+b*arccsch(c*x))^2+-2*b^2*x^-1+2*b*c*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x)))
@test integrate(x^-3*(a+b*arccsch(c*x))^2, x) == :(-1//2*x^-2*(a+b*arccsch(c*x))^2+-1//4*b^2*x^-2+-1//4*b^2*c^2*arccsch(c*x)^2+-1//2*a*b*c^2*arccsch(c*x)+(1/2)*b*c*x^-1*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x)))
@test integrate(x^-4*(a+b*arccsch(c*x))^2, x) == :(-2//27*b^2*x^-3+-1//3*x^-3*(a+b*arccsch(c*x))^2+4//9*b^2*c^2*x^-1+-4//9*b*c^3*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))+2//9*b*c*x^-2*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x)))
@test integrate(x^-5*(a+b*arccsch(c*x))^2, x) == :(-1//4*x^-4*(a+b*arccsch(c*x))^2+-1//32*b^2*x^-4+3//32*b^2*c^2*x^-2+3//32*b^2*c^4*arccsch(c*x)^2+3//16*a*b*c^4*arccsch(c*x)+-3//16*b*c^3*x^-1*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))+1//8*b*c*x^-3*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x)))
@test integrate(x^3*(a+b*arccsch(c*x))^3, x) == :(1//4*x^4*(a+b*arccsch(c*x))^3+(1/2)*b^3*c^-4*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+-1//2*b*c^-4*(a+b*arccsch(c*x))^2+b^2*c^-4*(a+b*arccsch(c*x))*log(1+-1*exp(2*arccsch(c*x)))+1//4*x*b^3*c^-3*(1+c^-2*x^-2)^(1/2)+1//4*b^2*c^-2*x^2*(a+b*arccsch(c*x))+-1//2*b*x*c^-3*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2+1//4*b*c^-1*x^3*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2)
@test integrate(x^2*(a+b*arccsch(c*x))^3, x) == :(1//3*x^3*(a+b*arccsch(c*x))^3+b^3*c^-3*Polylogarithms.polylog(3,-1*exp(arccsch(c*x)))+b^3*c^-3*arctanh((1+c^-2*x^-2)^(1/2))+-1*b^3*c^-3*Polylogarithms.polylog(3,exp(arccsch(c*x)))+x*b^2*c^-2*(a+b*arccsch(c*x))+b^2*c^-3*(a+b*arccsch(c*x))*Polylogarithms.polylog(2,exp(arccsch(c*x)))+-1*b*c^-3*(a+b*arccsch(c*x))^2*arctanh(exp(arccsch(c*x)))+-1*b^2*c^-3*(a+b*arccsch(c*x))*Polylogarithms.polylog(2,-1*exp(arccsch(c*x)))+(1/2)*b*c^-1*x^2*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2)
@test integrate(x*(a+b*arccsch(c*x))^3, x) == :((1/2)*x^2*(a+b*arccsch(c*x))^3+-3//2*b^3*c^-2*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+3//2*b*c^-2*(a+b*arccsch(c*x))^2+-3*b^2*c^-2*(a+b*arccsch(c*x))*log(1+-1*exp(2*arccsch(c*x)))+3//2*b*x*c^-1*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2)
@test integrate((a+b*arccsch(c*x))^3, x) == :(x*(a+b*arccsch(c*x))^3+-6*b^3*c^-1*Polylogarithms.polylog(3,-1*exp(arccsch(c*x)))+6*b^3*c^-1*Polylogarithms.polylog(3,exp(arccsch(c*x)))+-6*b^2*c^-1*(a+b*arccsch(c*x))*Polylogarithms.polylog(2,exp(arccsch(c*x)))+6*b*c^-1*(a+b*arccsch(c*x))^2*arctanh(exp(arccsch(c*x)))+6*b^2*c^-1*(a+b*arccsch(c*x))*Polylogarithms.polylog(2,-1*exp(arccsch(c*x))))
@test integrate(x^-1*(a+b*arccsch(c*x))^3, x) == :(-1*(a+b*arccsch(c*x))^3*log(1+-1*exp(2*arccsch(c*x)))+-3//4*b^3*Polylogarithms.polylog(4,exp(2*arccsch(c*x)))+1//4*b^-1*(a+b*arccsch(c*x))^4+-3//2*b*(a+b*arccsch(c*x))^2*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+3//2*b^2*(a+b*arccsch(c*x))*Polylogarithms.polylog(3,exp(2*arccsch(c*x))))
@test integrate(x^-2*(a+b*arccsch(c*x))^3, x) == :(-1*x^-1*(a+b*arccsch(c*x))^3+-6*b^2*x^-1*(a+b*arccsch(c*x))+6*c*b^3*(1+c^-2*x^-2)^(1/2)+3*b*c*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2)
@test integrate(x^-3*(a+b*arccsch(c*x))^3, x) == :(-1//2*x^-2*(a+b*arccsch(c*x))^3+-1//4*c^2*(a+b*arccsch(c*x))^3+-3//4*b^2*x^-2*(a+b*arccsch(c*x))+-3//8*b^3*c^2*arccsch(c*x)+3//8*c*b^3*x^-1*(1+c^-2*x^-2)^(1/2)+3//4*b*c*x^-1*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2)
@test integrate(x^-4*(a+b*arccsch(c*x))^3, x) == :(-1//3*x^-3*(a+b*arccsch(c*x))^3+-14//9*b^3*c^3*(1+c^-2*x^-2)^(1/2)+-2//9*b^2*x^-3*(a+b*arccsch(c*x))+2//27*b^3*c^3*(1+c^-2*x^-2)^3//2+-2//3*b*c^3*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2+4//3*b^2*c^2*x^-1*(a+b*arccsch(c*x))+1//3*b*c*x^-2*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2)
@test integrate(x^-5*(a+b*arccsch(c*x))^3, x) == :(-1//4*x^-4*(a+b*arccsch(c*x))^3+3//32*c^4*(a+b*arccsch(c*x))^3+-3//32*b^2*x^-4*(a+b*arccsch(c*x))+45//256*b^3*c^4*arccsch(c*x)+-45//256*b^3*c^3*x^-1*(1+c^-2*x^-2)^(1/2)+3//128*c*b^3*x^-3*(1+c^-2*x^-2)^(1/2)+9//32*b^2*c^2*x^-2*(a+b*arccsch(c*x))+-9//32*b*c^3*x^-1*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2+3//16*b*c*x^-3*(1+c^-2*x^-2)^(1/2)*(a+b*arccsch(c*x))^2)
@test integrate(x^-2*(a+b*arccsch(c*x))^-1, x) == :(c*b^-1*sinh(a*b^-1)*sinhintegral(a*b^-1+arccsch(c*x))+-1*c*b^-1*cosh(a*b^-1)*coshintegral(a*b^-1+arccsch(c*x)))
@test integrate(x^-3*(a+b*arccsch(c*x))^-1, x) == :((1/2)*b^-1*c^2*coshintegral(2*arccsch(c*x)+2*a*b^-1)*sinh(2*a*b^-1)+-1//2*b^-1*c^2*cosh(2*a*b^-1)*sinhintegral(2*arccsch(c*x)+2*a*b^-1))
@test integrate(x^-4*(a+b*arccsch(c*x))^-1, x) == :(-1//4*b^-1*c^3*cosh(3*a*b^-1)*coshintegral(3*arccsch(c*x)+3*a*b^-1)+-1//4*b^-1*c^3*sinh(a*b^-1)*sinhintegral(a*b^-1+arccsch(c*x))+1//4*b^-1*c^3*cosh(a*b^-1)*coshintegral(a*b^-1+arccsch(c*x))+1//4*b^-1*c^3*sinh(3*a*b^-1)*sinhintegral(3*arccsch(c*x)+3*a*b^-1))
@test integrate((d+e*x)^3*(a+b*arccsch(c*x)), x) == :(1//4*e^-1*(d+e*x)^4*(a+b*arccsch(c*x))+-1//4*b*d^4*e^-1*arccsch(c*x)+(1/2)*b*d*c^-3*(-1*e^2+2*c^2*d^2)*arctanh((1+c^-2*x^-2)^(1/2))+1//12*b*c^-1*e^3*x^3*(1+c^-2*x^-2)^(1/2)+(1/2)*b*d*c^-1*e^2*x^2*(1+c^-2*x^-2)^(1/2)+1//6*b*e*x*c^-3*(1+c^-2*x^-2)^(1/2)*(-1*e^2+9*c^2*d^2))
@test integrate((d+e*x)^2*(a+b*arccsch(c*x)), x) == :(1//3*e^-1*(d+e*x)^3*(a+b*arccsch(c*x))+-1//3*b*d^3*e^-1*arccsch(c*x)+1//6*b*c^-3*(-1*e^2+6*c^2*d^2)*arctanh((1+c^-2*x^-2)^(1/2))+1//6*b*c^-1*e^2*x^2*(1+c^-2*x^-2)^(1/2)+b*d*e*x*c^-1*(1+c^-2*x^-2)^(1/2))
@test integrate((a+b*arccsch(c*x))*(d+e*x), x) == :((1/2)*e^-1*(d+e*x)^2*(a+b*arccsch(c*x))+b*d*c^-1*arctanh((1+c^-2*x^-2)^(1/2))+-1//2*b*d^2*e^-1*arccsch(c*x)+(1/2)*b*e*x*c^-1*(1+c^-2*x^-2)^(1/2))
@test integrate(a+b*arccsch(c*x), x) == :(a*x+b*x*arccsch(c*x)+b*c^-1*arctanh((1+c^-2*x^-2)^(1/2)))
@test integrate((d+e*x)^-1*(a+b*arccsch(c*x)), x) == :(b*e^-1*Polylogarithms.polylog(2,c^-1*d^-1*(e+(e^2+c^2*d^2)^(1/2))*exp(arccsch(c*x)))+b*e^-1*Polylogarithms.polylog(2,c^-1*d^-1*(e+-1*(e^2+c^2*d^2)^(1/2))*exp(arccsch(c*x)))+e^-1*(a+b*arccsch(c*x))*log(1+-1*c^-1*d^-1*(e+(e^2+c^2*d^2)^(1/2))*exp(arccsch(c*x)))+e^-1*(a+b*arccsch(c*x))*log(1+-1*c^-1*d^-1*(e+-1*(e^2+c^2*d^2)^(1/2))*exp(arccsch(c*x)))+-1*e^-1*(a+b*arccsch(c*x))*log(1+-1*exp(2*arccsch(c*x)))+-1//2*b*e^-1*Polylogarithms.polylog(2,exp(2*arccsch(c*x))))
@test integrate((d+e*x)^-2*(a+b*arccsch(c*x)), x) == :(-1*e^-1*(d+e*x)^-1*(a+b*arccsch(c*x))+b*d^-1*e^-1*arccsch(c*x)+b*d^-1*(e^2+c^2*d^2)^-1//2*arctanh(c^-1*(1+c^-2*x^-2)^-1//2*(e^2+c^2*d^2)^-1//2*(d*c^2+-1*e*x^-1)))
@test integrate((d+e*x)^-3*(a+b*arccsch(c*x)), x) == :(-1//2*e^-1*(d+e*x)^-2*(a+b*arccsch(c*x))+(1/2)*b*d^-2*e^-1*arccsch(c*x)+(1/2)*b*d^-2*(e^2+c^2*d^2)^-3//2*(e^2+2*c^2*d^2)*arctanh(c^-1*(1+c^-2*x^-2)^-1//2*(e^2+c^2*d^2)^-1//2*(d*c^2+-1*e*x^-1))+-1//2*b*c*e*d^-1*(1+c^-2*x^-2)^(1/2)*(e+d*x^-1)^-1*(e^2+c^2*d^2)^-1)
@test integrate(x^4*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(1//5*d*x^5*(a+b*arccsch(c*x))+1//7*e*x^7*(a+b*arccsch(c*x))+-1//560*b*x*c^-6*(-1*c^2*x^2)^-1//2*(-25*e+42*d*c^2)*arctan(c*x*(-1+-1*c^2*x^2)^-1//2)+-1//560*b*c^-5*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-25*e+42*d*c^2)+1//42*b*e*c^-1*x^6*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+1//840*b*c^-3*x^4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-25*e+42*d*c^2))
@test integrate(x^2*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(1//3*d*x^3*(a+b*arccsch(c*x))+1//5*e*x^5*(a+b*arccsch(c*x))+1//20*b*e*c^-1*x^4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+1//120*b*x*c^-4*(-1*c^2*x^2)^-1//2*(-9*e+20*d*c^2)*arctan(c*x*(-1+-1*c^2*x^2)^-1//2)+1//120*b*c^-3*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-9*e+20*d*c^2))
@test integrate((a+b*arccsch(c*x))*(d+e*x^2), x) == :(d*x*(a+b*arccsch(c*x))+1//3*e*x^3*(a+b*arccsch(c*x))+-1//6*b*x*c^-2*(-1*c^2*x^2)^-1//2*(-1*e+6*d*c^2)*arctan(c*x*(-1+-1*c^2*x^2)^-1//2)+1//6*b*e*c^-1*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2))
@test integrate(x^-2*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(e*x*(a+b*arccsch(c*x))+-1*d*x^-1*(a+b*arccsch(c*x))+b*c*d*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+-1*b*e*x*(-1*c^2*x^2)^-1//2*arctan(c*x*(-1+-1*c^2*x^2)^-1//2))
@test integrate(x^-4*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(-1*e*x^-1*(a+b*arccsch(c*x))+-1//3*d*x^-3*(a+b*arccsch(c*x))+-1//9*b*c*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-9*e+2*d*c^2)+1//9*b*c*d*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2))
@test integrate(x^-6*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(-1//3*e*x^-3*(a+b*arccsch(c*x))+-1//5*d*x^-5*(a+b*arccsch(c*x))+2//225*b*c^3*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-25*e+12*d*c^2)+-1//225*b*c*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-25*e+12*d*c^2)+1//25*b*c*d*x^-4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2))
@test integrate(x^-8*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(-1//5*e*x^-5*(a+b*arccsch(c*x))+-1//7*d*x^-7*(a+b*arccsch(c*x))+-8//3675*b*c^5*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-49*e+30*d*c^2)+-1//1225*b*c*x^-4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-49*e+30*d*c^2)+1//49*b*c*d*x^-6*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+4//3675*b*c^3*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-49*e+30*d*c^2))
@test integrate(x^5*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(1//6*d*x^6*(a+b*arccsch(c*x))+1//8*e*x^8*(a+b*arccsch(c*x))+-1//56*b*e*x*c^-7*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^7//2+1//24*b*x*c^-7*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-3*e+4*d*c^2)+1//72*b*x*c^-7*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^3//2*(-9*e+8*d*c^2)+1//120*b*x*c^-7*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^5//2*(-9*e+4*d*c^2))
@test integrate(x^3*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(1//4*d*x^4*(a+b*arccsch(c*x))+1//6*e*x^6*(a+b*arccsch(c*x))+-1//12*b*x*c^-5*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-2*e+3*d*c^2)+-1//36*b*x*c^-5*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^3//2*(-4*e+3*d*c^2)+1//30*b*e*x*c^-5*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^5//2)
@test integrate(x*(a+b*arccsch(c*x))*(d+e*x^2), x) == :(1//4*e^-1*(d+e*x^2)^2*(a+b*arccsch(c*x))+-1//12*b*e*x*c^-3*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^3//2+1//4*b*x*c^-3*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-1*e+2*d*c^2)+-1//4*b*c*x*d^2*e^-1*(-1*c^2*x^2)^-1//2*arctan((-1+-1*c^2*x^2)^(1/2)))
@test integrate(x^-1*(a+b*arccsch(c*x))*(d+e*x^2), x) == :((1/2)*b*d*arccsch(c*x)^2+(1/2)*e*x^2*(a+b*arccsch(c*x))+-1*d*(a+b*arccsch(c*x))*log(x^-1)+-1//2*b*d*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+b*d*arccsch(c*x)*log(x^-1)+-1*b*d*arccsch(c*x)*log(1+-1*exp(2*arccsch(c*x)))+(1/2)*b*e*x*c^-1*(1+c^-2*x^-2)^(1/2))
@test integrate(x^-3*(a+b*arccsch(c*x))*(d+e*x^2), x) == :((1/2)*b*e*arccsch(c*x)^2+-1*e*(a+b*arccsch(c*x))*log(x^-1)+-1//2*b*e*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+-1//2*d*x^-2*(a+b*arccsch(c*x))+b*e*arccsch(c*x)*log(x^-1)+-1*b*e*arccsch(c*x)*log(1+-1*exp(2*arccsch(c*x)))+-1//4*b*d*c^2*arccsch(c*x)+1//4*b*c*d*x^-1*(1+c^-2*x^-2)^(1/2))
@test integrate(x^2*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :(1//3*d^2*x^3*(a+b*arccsch(c*x))+1//7*e^2*x^7*(a+b*arccsch(c*x))+2//5*d*e*x^5*(a+b*arccsch(c*x))+1//42*b*c^-1*e^2*x^6*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+1//1680*b*x*c^-6*(-1*c^2*x^2)^-1//2*(75*e^2+280*c^4*d^2+-252*d*e*c^2)*arctan(c*x*(-1+-1*c^2*x^2)^-1//2)+1//1680*b*c^-5*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(75*e^2+280*c^4*d^2+-252*d*e*c^2)+1//840*b*e*c^-3*x^4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-25*e+84*d*c^2))
@test integrate((d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :(x*d^2*(a+b*arccsch(c*x))+1//5*e^2*x^5*(a+b*arccsch(c*x))+2//3*d*e*x^3*(a+b*arccsch(c*x))+-1//120*b*x*c^-4*(-1*c^2*x^2)^-1//2*(9*e^2+120*c^4*d^2+-40*d*e*c^2)*arctan(c*x*(-1+-1*c^2*x^2)^-1//2)+1//20*b*c^-1*e^2*x^4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+1//120*b*e*c^-3*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-9*e+40*d*c^2))
@test integrate(x^-2*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :(-1*d^2*x^-1*(a+b*arccsch(c*x))+1//3*e^2*x^3*(a+b*arccsch(c*x))+2*d*e*x*(a+b*arccsch(c*x))+b*c*d^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+1//6*b*c^-1*e^2*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+-1//6*b*e*x*c^-2*(-1*c^2*x^2)^-1//2*(-1*e+12*d*c^2)*arctan(c*x*(-1+-1*c^2*x^2)^-1//2))
@test integrate(x^-4*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :(x*e^2*(a+b*arccsch(c*x))+-1//3*d^2*x^-3*(a+b*arccsch(c*x))+-2*d*e*x^-1*(a+b*arccsch(c*x))+-1*b*x*e^2*(-1*c^2*x^2)^-1//2*arctan(c*x*(-1+-1*c^2*x^2)^-1//2)+-2//9*b*c*d*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-9*e+d*c^2)+1//9*b*c*d^2*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2))
@test integrate(x^-6*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :(-1*e^2*x^-1*(a+b*arccsch(c*x))+-1//5*d^2*x^-5*(a+b*arccsch(c*x))+-2//3*d*e*x^-3*(a+b*arccsch(c*x))+1//225*b*c*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(225*e^2+24*c^4*d^2+-100*d*e*c^2)+1//25*b*c*d^2*x^-4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+-2//225*b*c*d*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-25*e+6*d*c^2))
@test integrate(x^-8*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :(-1//3*e^2*x^-3*(a+b*arccsch(c*x))+-1//7*d^2*x^-7*(a+b*arccsch(c*x))+-2//5*d*e*x^-5*(a+b*arccsch(c*x))+-2//11025*b*c^3*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(1225*e^2+360*c^4*d^2+-1176*d*e*c^2)+1//49*b*c*d^2*x^-6*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)+1//11025*b*c*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(1225*e^2+360*c^4*d^2+-1176*d*e*c^2)+-2//1225*b*c*d*x^-4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(-49*e+15*d*c^2))
@test integrate(x^3*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :(1//4*d^2*x^4*(a+b*arccsch(c*x))+1//8*e^2*x^8*(a+b*arccsch(c*x))+1//3*d*e*x^6*(a+b*arccsch(c*x))+-1//24*b*x*c^-7*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(3*e^2+6*c^4*d^2+-8*d*e*c^2)+-1//56*b*x*c^-7*e^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^7//2+-1//72*b*x*c^-7*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^3//2*(9*e^2+6*c^4*d^2+-16*d*e*c^2)+1//120*b*e*x*c^-7*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^5//2*(-9*e+8*d*c^2))
@test integrate(x*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :(1//6*e^-1*(d+e*x^2)^3*(a+b*arccsch(c*x))+1//6*b*x*c^-5*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(e^2+3*c^4*d^2+-3*d*e*c^2)+1//30*b*x*c^-5*e^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^5//2+-1//6*b*c*x*d^3*e^-1*(-1*c^2*x^2)^-1//2*arctan((-1+-1*c^2*x^2)^(1/2))+-1//18*b*e*x*c^-5*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^3//2*(-2*e+3*d*c^2))
@test integrate(x^-1*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :((1/2)*b*d^2*arccsch(c*x)^2+-1*d^2*(a+b*arccsch(c*x))*log(x^-1)+-1//2*b*d^2*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+1//4*e^2*x^4*(a+b*arccsch(c*x))+b*d^2*arccsch(c*x)*log(x^-1)+d*e*x^2*(a+b*arccsch(c*x))+-1*b*d^2*arccsch(c*x)*log(1+-1*exp(2*arccsch(c*x)))+1//12*b*c^-1*e^2*x^3*(1+c^-2*x^-2)^(1/2)+1//6*b*e*x*c^-3*(1+c^-2*x^-2)^(1/2)*(-1*e+6*d*c^2))
@test integrate(x^-3*(d+e*x^2)^2*(a+b*arccsch(c*x)), x) == :((1/2)*e^2*x^2*(a+b*arccsch(c*x))+-1//2*d^2*x^-2*(a+b*arccsch(c*x))+b*d*e*arccsch(c*x)^2+-1*b*d*e*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+-2*d*e*(a+b*arccsch(c*x))*log(x^-1)+-1//4*b*c^2*d^2*arccsch(c*x)+(1/2)*b*x*c^-1*e^2*(1+c^-2*x^-2)^(1/2)+-2*b*d*e*arccsch(c*x)*log(1+-1*exp(2*arccsch(c*x)))+2*b*d*e*arccsch(c*x)*log(x^-1)+1//4*b*c*d^2*x^-1*(1+c^-2*x^-2)^(1/2))
@test integrate(x^2*(d+e*x^2)^-1*(a+b*arccsch(c*x)), x) == :(x*e^-1*(a+b*arccsch(c*x))+b*c^-1*e^-1*arctanh((1+c^-2*x^-2)^(1/2))+(1/2)*b*e^-3//2*(-1d)^(1/2)*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-3//2*(-1d)^(1/2)*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-3//2*(-1d)^(1/2)*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-3//2*(-1d)^(1/2)*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*e^-3//2*(-1d)^(1/2)*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*e^-3//2*(-1d)^(1/2)*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*e^-3//2*(-1d)^(1/2)*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*e^-3//2*(-1d)^(1/2)*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x))))
@test integrate(x*(d+e*x^2)^-1*(a+b*arccsch(c*x)), x) == :((1/2)*b*e^-1*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-1*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-1*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-1*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-1*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-1*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-1*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-1*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*e^-1*(a+b*arccsch(c*x))*log(1+-1*exp(2*arccsch(c*x)))+-1//2*b*e^-1*Polylogarithms.polylog(2,exp(2*arccsch(c*x))))
@test integrate((d+e*x^2)^-1*(a+b*arccsch(c*x)), x) == :((1/2)*b*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-1//2*(-1d)^-1//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-1//2*(-1d)^-1//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*e^-1//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*e^-1//2*(-1d)^-1//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*e^-1//2*(-1d)^-1//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x))))
@test integrate(x^-1*(d+e*x^2)^-1*(a+b*arccsch(c*x)), x) == :((1/2)*b^-1*d^-1*(a+b*arccsch(c*x))^2+-1//2*b*d^-1*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-1*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-1*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-1*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-1*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-1*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-1*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-1*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x))))
@test integrate(x^-2*(d+e*x^2)^-1*(a+b*arccsch(c*x)), x) == :(-1*a*d^-1*x^-1+b*c*d^-1*(1+c^-2*x^-2)^(1/2)+(1/2)*b*e^(1/2)*(-1d)^-3//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^(1/2)*(-1d)^-3//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^(1/2)*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^(1/2)*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*b*d^-1*x^-1*arccsch(c*x)+-1//2*b*e^(1/2)*(-1d)^-3//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*e^(1/2)*(-1d)^-3//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*e^(1/2)*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*e^(1/2)*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x))))
@test integrate(x^5*(d+e*x^2)^-2*(a+b*arccsch(c*x)), x) == :((1/2)*e^-2*x^2*(a+b*arccsch(c*x))+b*d*e^-3*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+(1/2)*d*e^-2*(e+d*x^-2)^-1*(a+b*arccsch(c*x))+-1*b*d*e^-3*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*b*d*e^-3*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*b*d*e^-3*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*b*d*e^-3*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*d*e^-3*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*d*e^-3*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*d*e^-3*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*d*e^-3*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+2*d*e^-3*(a+b*arccsch(c*x))*log(1+-1*exp(2*arccsch(c*x)))+(1/2)*b*x*c^-1*e^-2*(1+c^-2*x^-2)^(1/2)+-1//2*b*d*e^-5//2*(-1*e+d*c^2)^-1//2*arctan(c^-1*e^-1//2*x^-1*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^(1/2)))
@test integrate(x^3*(d+e*x^2)^-2*(a+b*arccsch(c*x)), x) == :((1/2)*b*e^-2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*e^-2*(a+b*arccsch(c*x))*log(1+-1*exp(2*arccsch(c*x)))+-1//2*b*e^-2*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+-1//2*e^-1*(e+d*x^-2)^-1*(a+b*arccsch(c*x))+(1/2)*b*e^-3//2*(-1*e+d*c^2)^-1//2*arctan(c^-1*e^-1//2*x^-1*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^(1/2)))
@test integrate(x*(d+e*x^2)^-2*(a+b*arccsch(c*x)), x) == :(-1//2*e^-1*(d+e*x^2)^-1*(a+b*arccsch(c*x))+(1/2)*b*c*x*d^-1*e^-1*(-1*c^2*x^2)^-1//2*arctan((-1+-1*c^2*x^2)^(1/2))+(1/2)*b*c*x*d^-1*e^-1//2*(-1*c^2*x^2)^-1//2*(-1*e+d*c^2)^-1//2*arctanh(e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(-1*e+d*c^2)^-1//2))
@test integrate(x^-1*(d+e*x^2)^-2*(a+b*arccsch(c*x)), x) == :((1/2)*b^-1*d^-2*(a+b*arccsch(c*x))^2+-1//2*b*d^-2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*e*d^-2*(e+d*x^-2)^-1*(a+b*arccsch(c*x))+(1/2)*b*d^-2*e^(1/2)*(-1*e+d*c^2)^-1//2*arctan(c^-1*e^-1//2*x^-1*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^(1/2)))
@test integrate(x^4*(d+e*x^2)^-2*(a+b*arccsch(c*x)), x) == :(x*e^-2*(a+b*arccsch(c*x))+b*c^-1*e^-2*arctanh((1+c^-2*x^-2)^(1/2))+-3//4*b*e^-5//2*(-1d)^(1/2)*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//4*b*e^-5//2*(-1d)^(1/2)*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//4*e^-5//2*(-1d)^(1/2)*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//4*e^-5//2*(-1d)^(1/2)*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*d*e^-2*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1*(a+b*arccsch(c*x))+1//4*d*e^-2*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1*(a+b*arccsch(c*x))+3//4*b*e^-5//2*(-1d)^(1/2)*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//4*b*e^-5//2*(-1d)^(1/2)*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//4*e^-5//2*(-1d)^(1/2)*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//4*e^-5//2*(-1d)^(1/2)*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*b*d^(1/2)*e^-2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+1//4*b*d^(1/2)*e^-2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2))))
@test integrate(x^2*(d+e*x^2)^-2*(a+b*arccsch(c*x)), x) == :(-1//4*e^-1*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1*(a+b*arccsch(c*x))+1//4*e^-1*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1*(a+b*arccsch(c*x))+-1//4*b*e^-3//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*b*e^-3//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*e^-3//2*(-1d)^-1//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*e^-3//2*(-1d)^-1//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*b*e^-3//2*(-1d)^-1//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*b*e^-3//2*(-1d)^-1//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*e^-3//2*(-1d)^-1//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*e^-3//2*(-1d)^-1//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*b*d^-1//2*e^-1*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+-1//4*b*d^-1//2*e^-1*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2))))
@test integrate((d+e*x^2)^-2*(a+b*arccsch(c*x)), x) == :(-1//4*d^-1*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1*(a+b*arccsch(c*x))+1//4*d^-1*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1*(a+b*arccsch(c*x))+-1//4*b*e^-1//2*(-1d)^-3//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*b*e^-1//2*(-1d)^-3//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*e^-1//2*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*e^-1//2*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*b*d^-3//2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+1//4*b*d^-3//2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2)))+1//4*b*e^-1//2*(-1d)^-3//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*b*e^-1//2*(-1d)^-3//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*e^-1//2*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//4*e^-1//2*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x))))
@test integrate(x^-2*(d+e*x^2)^-2*(a+b*arccsch(c*x)), x) == :(-1*a*d^-2*x^-1+b*c*d^-2*(1+c^-2*x^-2)^(1/2)+-1*b*d^-2*x^-1*arccsch(c*x)+-3//4*b*e^(1/2)*(-1d)^-5//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//4*b*e^(1/2)*(-1d)^-5//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//4*e^(1/2)*(-1d)^-5//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//4*e^(1/2)*(-1d)^-5//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*e*d^-2*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1*(a+b*arccsch(c*x))+1//4*e*d^-2*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1*(a+b*arccsch(c*x))+3//4*b*e^(1/2)*(-1d)^-5//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//4*b*e^(1/2)*(-1d)^-5//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//4*e^(1/2)*(-1d)^-5//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//4*e^(1/2)*(-1d)^-5//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//4*b*e*d^-5//2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+-1//4*b*e*d^-5//2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2))))
@test integrate(x^5*(d+e*x^2)^-3*(a+b*arccsch(c*x)), x) == :((1/2)*b*e^-3*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-3*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-3*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*b*e^-3*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-3*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-3*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-3*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+(1/2)*e^-3*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*e^-3*(a+b*arccsch(c*x))*log(1+-1*exp(2*arccsch(c*x)))+-1//2*b*e^-3*Polylogarithms.polylog(2,exp(2*arccsch(c*x)))+-1//2*e^-2*(e+d*x^-2)^-1*(a+b*arccsch(c*x))+-1//4*e^-1*(e+d*x^-2)^-2*(a+b*arccsch(c*x))+(1/2)*b*e^-5//2*(-1*e+d*c^2)^-1//2*arctan(c^-1*e^-1//2*x^-1*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^(1/2))+1//8*b*e^-5//2*(-1*e+d*c^2)^-3//2*(-2*e+d*c^2)*arctan(c^-1*e^-1//2*x^-1*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^(1/2))+b*c*d*e^-2*x^-1*(1+c^-2*x^-2)^(1/2)*(e+d*x^-2)^-1*(-8*e+8*d*c^2)^-1)
@test integrate(x^3*(d+e*x^2)^-3*(a+b*arccsch(c*x)), x) == :(1//4*d^-1*x^4*(d+e*x^2)^-2*(a+b*arccsch(c*x))+-1*b*c*x*e^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1*(-8*e+8*d*c^2)^-1+1//8*b*c*x*d^-1*e^-3//2*(-1*c^2*x^2)^-1//2*(-1*e+d*c^2)^-3//2*(-2*e+d*c^2)*arctanh(e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(-1*e+d*c^2)^-1//2))
@test integrate(x*(d+e*x^2)^-3*(a+b*arccsch(c*x)), x) == :(-1//4*e^-1*(d+e*x^2)^-2*(a+b*arccsch(c*x))+1//4*b*c*x*d^-2*e^-1*(-1*c^2*x^2)^-1//2*arctan((-1+-1*c^2*x^2)^(1/2))+1//8*b*c*x*d^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1*(-1*e+d*c^2)^-1+1//8*b*c*x*d^-2*e^-1//2*(-1*c^2*x^2)^-1//2*(-1*e+d*c^2)^-3//2*(-2*e+3*d*c^2)*arctanh(e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(-1*e+d*c^2)^-1//2))
@test integrate(x^-1*(d+e*x^2)^-3*(a+b*arccsch(c*x)), x) == :((1/2)*b^-1*d^-3*(a+b*arccsch(c*x))^2+-1//2*b*d^-3*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-3*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-3*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*b*d^-3*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-3*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-3*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-3*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//2*d^-3*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1*e*d^-3*(e+d*x^-2)^-1*(a+b*arccsch(c*x))+1//4*d^-3*e^2*(e+d*x^-2)^-2*(a+b*arccsch(c*x))+b*d^-3*e^(1/2)*(-1*e+d*c^2)^-1//2*arctan(c^-1*e^-1//2*x^-1*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^(1/2))+-1//8*b*d^-3*e^(1/2)*(-1*e+d*c^2)^-3//2*(-2*e+d*c^2)*arctan(c^-1*e^-1//2*x^-1*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^(1/2))+-1//8*b*c*e*d^-2*x^-1*(1+c^-2*x^-2)^(1/2)*(e+d*x^-2)^-1*(-1*e+d*c^2)^-1)
@test integrate(x^4*(d+e*x^2)^-3*(a+b*arccsch(c*x)), x) == :(-1//16*e^-2*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1*(3a+3*b*arccsch(c*x))+1//16*e^-2*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1*(3a+3*b*arccsch(c*x))+-3//16*b*e^-5//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//16*b*e^-5//2*(-1d)^-1//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*e^-5//2*(-1d)^-1//2*(3a+3*b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*e^-5//2*(-1d)^-1//2*(3a+3*b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*e^-3//2*(-1d)^(1/2)*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-2*(a+b*arccsch(c*x))+1//16*e^-5//2*(-1d)^-1//2*(3a+3*b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//16*e^-5//2*(-1d)^-1//2*(3a+3*b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//16*e^-3//2*(-1d)^(1/2)*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-2*(a+b*arccsch(c*x))+3//16*b*e^-5//2*(-1d)^-1//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//16*b*e^-5//2*(-1d)^-1//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//16*b*d^-1//2*e^-2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+-3//16*b*d^-1//2*e^-2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2)))+1//16*b*d^-1//2*e^-1*(-1*e+d*c^2)^-3//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+1//16*b*d^-1//2*e^-1*(-1*e+d*c^2)^-3//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2)))+-1*b*c*e^-3//2*(-1d)^(1/2)*(1+c^-2*x^-2)^(1/2)*(-16*e+16*d*c^2)^-1*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1+-1*b*c*e^-3//2*(-1d)^(1/2)*(1+c^-2*x^-2)^(1/2)*(-16*e+16*d*c^2)^-1*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1)
@test integrate(x^2*(d+e*x^2)^-3*(a+b*arccsch(c*x)), x) == :(-1//16*b*d^-3//2*(-1*e+d*c^2)^-3//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+-1//16*b*d^-3//2*(-1*e+d*c^2)^-3//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2)))+-1//16*b*e^-3//2*(-1d)^-3//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*b*e^-3//2*(-1d)^-3//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*d^-1*e^-1*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1*(a+b*arccsch(c*x))+-1//16*e^-3//2*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*e^-3//2*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*e^-1//2*(-1d)^-1//2*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-2*(a+b*arccsch(c*x))+1//16*b*e^-3//2*(-1d)^-3//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//16*b*e^-3//2*(-1d)^-3//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//16*d^-1*e^-1*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1*(a+b*arccsch(c*x))+1//16*e^-3//2*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//16*e^-3//2*(-1d)^-3//2*(a+b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//16*e^-1//2*(-1d)^-1//2*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-2*(a+b*arccsch(c*x))+-1//16*b*d^-3//2*e^-1*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+-1//16*b*d^-3//2*e^-1*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2)))+-1//16*b*c*e^-1//2*(-1d)^-1//2*(1+c^-2*x^-2)^(1/2)*(-1*e+d*c^2)^-1*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1+-1//16*b*c*e^-1//2*(-1d)^-1//2*(1+c^-2*x^-2)^(1/2)*(-1*e+d*c^2)^-1*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1)
@test integrate((d+e*x^2)^-3*(a+b*arccsch(c*x)), x) == :(-1//16*d^-2*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1*(5a+5*b*arccsch(c*x))+1//16*d^-2*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1*(5a+5*b*arccsch(c*x))+-3//16*b*e^-1//2*(-1d)^-5//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-3//16*b*e^-1//2*(-1d)^-5//2*Polylogarithms.polylog(2,-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*e^(1/2)*(-1d)^-3//2*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-2*(a+b*arccsch(c*x))+-1//16*e^-1//2*(-1d)^-5//2*(3a+3*b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+-1//16*e^-1//2*(-1d)^-5//2*(3a+3*b*arccsch(c*x))*log(1+c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//16*e^(1/2)*(-1d)^-3//2*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-2*(a+b*arccsch(c*x))+1//16*e^-1//2*(-1d)^-5//2*(3a+3*b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+1//16*e^-1//2*(-1d)^-5//2*(3a+3*b*arccsch(c*x))*log(1+-1*c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//16*b*e^-1//2*(-1d)^-5//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+3//16*b*e^-1//2*(-1d)^-5//2*Polylogarithms.polylog(2,c*(-1d)^(1/2)*(e^(1/2)+-1*(e+-1*d*c^2)^(1/2))^-1*exp(arccsch(c*x)))+5//16*b*d^-5//2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+5//16*b*d^-5//2*(-1*e+d*c^2)^-1//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2)))+1//16*b*e*d^-5//2*(-1*e+d*c^2)^-3//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+e^(1/2)*x^-1*(-1d)^(1/2)))+1//16*b*e*d^-5//2*(-1*e+d*c^2)^-3//2*arctanh(c^-1*d^-1//2*(1+c^-2*x^-2)^-1//2*(-1*e+d*c^2)^-1//2*(d*c^2+-1*e^(1/2)*x^-1*(-1d)^(1/2)))+-1//16*b*c*e^(1/2)*(-1d)^-3//2*(1+c^-2*x^-2)^(1/2)*(-1*e+d*c^2)^-1*(d*x^-1+e^(1/2)*(-1d)^(1/2))^-1+-1//16*b*c*e^(1/2)*(-1d)^-3//2*(1+c^-2*x^-2)^(1/2)*(-1*e+d*c^2)^-1*(e^(1/2)*(-1d)^(1/2)+-1*d*x^-1)^-1)
@test integrate(x^5*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x)), x) == :(1//7*e^-3*(d+e*x^2)^7//2*(a+b*arccsch(c*x))+-2//5*d*e^-3*(d+e*x^2)^5//2*(a+b*arccsch(c*x))+1//3*d^2*e^-3*(d+e*x^2)^3//2*(a+b*arccsch(c*x))+1//42*b*x*c^-1*e^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^5//2+1//1680*b*x*c^-6*e^-5//2*(-1*c^2*x^2)^-1//2*(-75*e^3+105*c^6*d^3+35*e*c^4*d^2+63*d*c^2*e^2)*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+8//105*b*c*x*d^7//2*e^-3*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+-1//840*b*x*c^-3*e^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3//2*(25*e+29*d*c^2)+-1//1680*b*x*c^-5*e^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(-75*e^2+23*c^4*d^2+-12*d*e*c^2))
@test integrate(x^3*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x)), x) == :(1//5*e^-2*(d+e*x^2)^5//2*(a+b*arccsch(c*x))+-1//3*d*e^-2*(d+e*x^2)^3//2*(a+b*arccsch(c*x))+-2//15*b*c*x*d^5//2*e^-2*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+-1//120*b*x*c^-4*e^-3//2*(-1*c^2*x^2)^-1//2*(-9*e^2+15*c^4*d^2+10*d*e*c^2)*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+1//20*b*x*c^-1*e^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3//2+1//120*b*x*c^-3*e^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(-9*e+d*c^2))
@test integrate(x*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x)), x) == :(1//3*e^-1*(d+e*x^2)^3//2*(a+b*arccsch(c*x))+1//6*b*x*c^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)+1//3*b*c*x*d^3//2*e^-1*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+1//6*b*x*c^-2*e^-1//2*(-1*c^2*x^2)^-1//2*(-1*e+3*d*c^2)*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2))
@test integrate(x^-4*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x)), x) == :(-1//3*d^-1*x^-3*(d+e*x^2)^3//2*(a+b*arccsch(c*x))+1//9*b*c*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)+-2//9*b*c*d^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(-2*e+d*c^2)+-2//9*b*c^3*d^-1*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(-2*e+d*c^2)+-1//9*b*e*x*d^-2*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(-3*e+d*c^2)*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1)+2//9*b*x*c^2*d^-1*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(-2*e+d*c^2)*Elliptic.E(arctan(c*x),1+-1*e*c^-2*d^-1))
@test integrate(x^3*(d+e*x^2)^3//2*(a+b*arccsch(c*x)), x) == :(1//7*e^-2*(d+e*x^2)^7//2*(a+b*arccsch(c*x))+-1//5*d*e^-2*(d+e*x^2)^5//2*(a+b*arccsch(c*x))+-2//35*b*c*x*d^7//2*e^-2*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+-1//560*b*x*c^-6*e^-3//2*(-1*c^2*x^2)^-1//2*(25*e^3+35*c^6*d^3+-63*d*c^2*e^2+35*e*c^4*d^2)*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+1//42*b*x*c^-1*e^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^5//2+-1//560*b*x*c^-5*e^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(-25*e^2+3*c^4*d^2+38*d*e*c^2)+1//840*b*x*c^-3*e^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3//2*(-25*e+13*d*c^2))
@test integrate(x*(d+e*x^2)^3//2*(a+b*arccsch(c*x)), x) == :(1//5*e^-1*(d+e*x^2)^5//2*(a+b*arccsch(c*x))+1//20*b*x*c^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3//2+1//5*b*c*x*d^5//2*e^-1*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+1//40*b*x*c^-4*e^-1//2*(-1*c^2*x^2)^-1//2*(3*e^2+15*c^4*d^2+-10*d*e*c^2)*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+1//40*b*x*c^-3*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(-3*e+7*d*c^2))
@test integrate(x^-6*(d+e*x^2)^3//2*(a+b*arccsch(c*x)), x) == :(-1//5*d^-1*x^-5*(d+e*x^2)^5//2*(a+b*arccsch(c*x))+1//25*b*c*x^-4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3//2+-4//75*b*c*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(-2*e+d*c^2)+1//75*b*c*d^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(23*e^2+8*c^4*d^2+-23*d*e*c^2)+1//75*b*c^3*d^-1*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(23*e^2+8*c^4*d^2+-23*d*e*c^2)+-1//75*b*x*c^2*d^-1*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(23*e^2+8*c^4*d^2+-23*d*e*c^2)*Elliptic.E(arctan(c*x),1+-1*e*c^-2*d^-1)+1//75*b*e*x*d^-2*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(15*e^2+4*c^4*d^2+-11*d*e*c^2)*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1))
@test integrate(x^-8*(d+e*x^2)^3//2*(a+b*arccsch(c*x)), x) == :(-1//7*d^-1*x^-7*(d+e*x^2)^5//2*(a+b*arccsch(c*x))+2//35*e*d^-2*x^-5*(d+e*x^2)^5//2*(a+b*arccsch(c*x))+-1//3675*b*c*d^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(247*e^3+240*c^6*d^3+-528*e*c^4*d^2+193*d*c^2*e^2)+1//49*b*c*d^-1*x^-6*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^5//2+-1//1225*b*c*d^-1*x^-4*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3//2*(-11*e+30*d*c^2)+-1//3675*b*c^3*d^-2*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(247*e^3+240*c^6*d^3+-528*e*c^4*d^2+193*d*c^2*e^2)+1//3675*b*c*d^-1*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(-37*e^2+120*c^4*d^2+-159*d*e*c^2)+-1//3675*b*e*x*d^-3*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(210*e^3+120*c^6*d^3+-249*e*c^4*d^2+71*d*c^2*e^2)*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1)+1//3675*b*x*c^2*d^-2*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(247*e^3+240*c^6*d^3+-528*e*c^4*d^2+193*d*c^2*e^2)*Elliptic.E(arctan(c*x),1+-1*e*c^-2*d^-1))
@test integrate(x^5*(d+e*x^2)^-1//2*(a+b*arccsch(c*x)), x) == :(1//5*e^-3*(d+e*x^2)^5//2*(a+b*arccsch(c*x))+d^2*e^-3*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+-2//3*d*e^-3*(d+e*x^2)^3//2*(a+b*arccsch(c*x))+1//20*b*x*c^-1*e^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^3//2+1//120*b*x*c^-4*e^-5//2*(-1*c^2*x^2)^-1//2*(9*e^2+45*c^4*d^2+10*d*e*c^2)*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+8//15*b*c*x*d^5//2*e^-3*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+-1//120*b*x*c^-3*e^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(9*e+19*d*c^2))
@test integrate(x^3*(d+e*x^2)^-1//2*(a+b*arccsch(c*x)), x) == :(1//3*e^-2*(d+e*x^2)^3//2*(a+b*arccsch(c*x))+-1*d*e^-2*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+-2//3*b*c*x*d^3//2*e^-2*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+-1//6*b*x*c^-2*e^-3//2*(-1*c^2*x^2)^-1//2*(e+3*d*c^2)*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+1//6*b*x*c^-1*e^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2))
@test integrate(x*(d+e*x^2)^-1//2*(a+b*arccsch(c*x)), x) == :(e^-1*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+b*x*e^-1//2*(-1*c^2*x^2)^-1//2*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+b*c*x*d^(1/2)*e^-1*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)))
@test integrate(x^-2*(d+e*x^2)^-1//2*(a+b*arccsch(c*x)), x) == :(-1*d^-1*x^-1*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+b*c*d^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)+b*c^3*d^-1*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)+b*e*x*d^-2*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1)+-1*b*x*c^2*d^-1*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*Elliptic.E(arctan(c*x),1+-1*e*c^-2*d^-1))
@test integrate(x^-4*(d+e*x^2)^-1//2*(a+b*arccsch(c*x)), x) == :(-1//3*d^-1*x^-3*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+2//3*e*d^-2*x^-1*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+-1//9*b*c*d^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)*(5*e+2*d*c^2)+1//9*b*c*d^-1*x^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)+-1//9*b*c^3*d^-2*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(5*e+2*d*c^2)+-1//9*b*e*x*d^-3*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(6*e+d*c^2)*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1)+1//9*b*x*c^2*d^-2*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(5*e+2*d*c^2)*Elliptic.E(arctan(c*x),1+-1*e*c^-2*d^-1))
@test integrate(x^5*(d+e*x^2)^-3//2*(a+b*arccsch(c*x)), x) == :(1//3*e^-3*(d+e*x^2)^3//2*(a+b*arccsch(c*x))+-1*d^2*e^-3*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+-2*d*e^-3*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+-8//3*b*c*x*d^3//2*e^-3*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+-1//6*b*x*c^-2*e^-5//2*(-1*c^2*x^2)^-1//2*(e+9*d*c^2)*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+1//6*b*x*c^-1*e^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2))
@test integrate(x^3*(d+e*x^2)^-3//2*(a+b*arccsch(c*x)), x) == :(e^-2*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+d*e^-2*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+b*x*e^-3//2*(-1*c^2*x^2)^-1//2*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+2*b*c*x*d^(1/2)*e^-2*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)))
@test integrate(x*(d+e*x^2)^-3//2*(a+b*arccsch(c*x)), x) == :(-1*e^-1*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+-1*b*c*x*d^-1//2*e^-1*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)))
@test integrate((d+e*x^2)^-3//2*(a+b*arccsch(c*x)), x) == :(x*d^-1*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+-1*b*x*d^-2*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1))
@test integrate(x^-2*(d+e*x^2)^-3//2*(a+b*arccsch(c*x)), x) == :(-1*d^-1*x^-1*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+-2*e*x*d^-2*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+b*c*d^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^(1/2)+b*c^3*d^-2*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)+-1*b*x*c^2*d^-2*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*Elliptic.E(arctan(c*x),1+-1*e*c^-2*d^-1)+2*b*e*x*d^-3*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1))
@test integrate(x^5*(d+e*x^2)^-5//2*(a+b*arccsch(c*x)), x) == :(e^-3*(d+e*x^2)^(1/2)*(a+b*arccsch(c*x))+2*d*e^-3*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+-1//3*d^2*e^-3*(d+e*x^2)^-3//2*(a+b*arccsch(c*x))+b*x*e^-5//2*(-1*c^2*x^2)^-1//2*arctan(c^-1*e^(1/2)*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2)+8//3*b*c*x*d^(1/2)*e^-3*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+b*c*d*x*e^-2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2*(-3*e+3*d*c^2)^-1)
@test integrate(x^3*(d+e*x^2)^-5//2*(a+b*arccsch(c*x)), x) == :(-1*e^-2*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+1//3*d*e^-2*(d+e*x^2)^-3//2*(a+b*arccsch(c*x))+-2//3*b*c*x*d^-1//2*e^-2*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+-1*b*c*x*e^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2*(-3*e+3*d*c^2)^-1)
@test integrate(x*(d+e*x^2)^-5//2*(a+b*arccsch(c*x)), x) == :(-1//3*e^-1*(d+e*x^2)^-3//2*(a+b*arccsch(c*x))+-1//3*b*c*x*d^-3//2*e^-1*(-1*c^2*x^2)^-1//2*arctan(d^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2))+1//3*b*c*x*d^-1*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2*(-1*e+d*c^2)^-1)
@test integrate(x^2*(d+e*x^2)^-5//2*(a+b*arccsch(c*x)), x) == :(1//3*d^-1*x^3*(d+e*x^2)^-3//2*(a+b*arccsch(c*x))+1//3*b*c*d^-1*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2*(-1*e+d*c^2)^-1+1//3*b*x*d^-2*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(-1*e+d*c^2)^-1*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1)+1//3*b*c^3*d^-1*e^-1*x^2*(-1*c^2*x^2)^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(-1*e+d*c^2)^-1+-1//3*b*x*c^2*d^-1*e^-1*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(-1*e+d*c^2)^-1*Elliptic.E(arctan(c*x),1+-1*e*c^-2*d^-1))
@test integrate((d+e*x^2)^-5//2*(a+b*arccsch(c*x)), x) == :(1//3*x*d^-1*(d+e*x^2)^-3//2*(a+b*arccsch(c*x))+2//3*x*d^-2*(d+e*x^2)^-1//2*(a+b*arccsch(c*x))+-1//3*b*x*d^-3*(-1*c^2*x^2)^-1//2*(d^-1*(1+c^2*x^2)^-1*(d+e*x^2))^-1//2*(-1+-1*c^2*x^2)^-1//2*(d+e*x^2)^(1/2)*(-1*e+d*c^2)^-1*(-2*e+3*d*c^2)*Elliptic.F(arctan(c*x),1+-1*e*c^-2*d^-1)+-1//3*b*c*x*d^-3//2*e^(1/2)*(-1*c^2*x^2)^-1//2*(d*(d+e*x^2)^-1*(1+c^2*x^2))^-1//2*(-1+-1*c^2*x^2)^(1/2)*(d+e*x^2)^-1//2*(-1*e+d*c^2)^-1*Elliptic.E(arctan(x*d^-1//2*e^(1/2)),1+-1*d*c^2*e^-1))
@test integrate(x^11*(1+-1*c^4*x^4)^-1//2*(a+b*arccsch(c*x)), x) == :(-1//2*c^-12*(1+-1*c^4*x^4)^(1/2)*(a+b*arccsch(c*x))+-1//10*c^-12*(1+-1*c^4*x^4)^5//2*(a+b*arccsch(c*x))+1//3*c^-12*(1+-1*c^4*x^4)^3//2*(a+b*arccsch(c*x))+-13//150*b*c^-13*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*(1+-1*c^2*x^2)^5//2+-4//15*b*c^-13*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*(1+-1*c^2*x^2)^(1/2)+-1//90*b*c^-13*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*(1+-1*c^2*x^2)^9//2+3//70*b*c^-13*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*(1+-1*c^2*x^2)^7//2+4//15*b*c^-13*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*arctanh((1+-1*c^2*x^2)^(1/2))+7//90*b*c^-13*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*(1+-1*c^2*x^2)^3//2)
@test integrate(x^7*(1+-1*c^4*x^4)^-1//2*(a+b*arccsch(c*x)), x) == :(-1//2*c^-8*(1+-1*c^4*x^4)^(1/2)*(a+b*arccsch(c*x))+1//6*c^-8*(1+-1*c^4*x^4)^3//2*(a+b*arccsch(c*x))+-1//3*b*c^-9*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*(1+-1*c^2*x^2)^(1/2)+-1//30*b*c^-9*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*(1+-1*c^2*x^2)^5//2+1//3*b*c^-9*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*arctanh((1+-1*c^2*x^2)^(1/2))+1//18*b*c^-9*x^-1*(1+c^-2*x^-2)^-1//2*(1+c^2*x^2)^(1/2)*(1+-1*c^2*x^2)^3//2)

max_stars_repo_path: test/7 Inverse hyperbolic functions/7.6 Inverse hyperbolic cosecant/7.6.1 u (a+b arccsch(c x))^n.jl


text:
using .VegaLite

"""
    vlplot(b::Bandstructure{1}; size = 640, points = false, labels = ("φ/2π", "ε"), scaling = (1/2π, 1))

Plots the 1D bandstructure `b` using VegaLite.

    vlplot(h::Hamiltonian; size = 800, labels = ("x", "y"), axes::Tuple{Int,Int} = (1,2))

Plots the the Hamiltonian lattice projected along `axes` using VegaLite.

# Options:
    - `size`: the `(width, height)` of the plot (or `width == height` if a single number)
    - `points`: whether to plot points on line plots
    - `labels`: labels for the x and y plot axes
    - `scaling`: `(scalex, scaley)` scalings for the x (Bloch phase) and y (energy) variables
    - `axes`: lattice axes to project onto the plot x-y plane
"""
function VegaLite.vlplot(b::Bandstructure; labels = ("φ/2π", "ε"), scaling = (1/2π, 1), size = 640, points = false)
    labelx, labely = labels
    table = bandtable(b, make_it_two(scaling))
    sizes = make_it_two(size)
    corners = _corners(table)
    (domainx, domainy), _ = domain_size(corners, size)
    p = table |> vltheme(sizes, points) + @vlplot(
        mark = :line,
        x = {:x, scale = {domain = domainx, nice = false}, title = labelx},
        y = {:y, scale = {domain = domainy, nice = false}, title = labely},
        color = "band:n",
        selection = {grid = {type = :interval, bind = :scales}})
    return p
end

function bandtable(b::Bandstructure{1}, (scalingx, scalingy) = (1, 1))
    ks = vertices(b.kmesh)
    table = [(x = v[1] * scalingx, y = v[2] * scalingy, band = i, tooltip = string(v))
             for (i, bnd) in enumerate(bands(b)) for v in vertices(bnd)]
    return table
end

function VegaLite.vlplot(h::Hamiltonian{LA};
                         labels = ("x","y"), size = 800, axes::Tuple{Int,Int} = (1,2)) where {E,LA<:Lattice{E}}
    table = linkstable(h, axes)
    corners = _corners(table)
    (domainx, domainy), sizes = domain_size(corners, size)
    p = table |> vltheme(sizes) +
        @vlplot(:rule, color = :sublat, opacity = {:opacity, legend = nothing},
            transform = [{filter = "datum.islink"}],
            selection = {grid2 = {type = :interval, bind = :scales}},
            encoding = {x = :x, y = :y, x2 = :x2, y2 = :y2}) +
        @vlplot(:circle, color = :sublat, opacity = {:opacity, legend = nothing},
            selection = {grid1 = {type = :interval, bind = :scales}},
            transform = [{filter = "!datum.islink"}],
            encoding = {
                x = {:x, scale = {domain = domainx, nice = false}, axis = {grid = false}, title = labels[1]},
                y = {:y, scale = {domain = domainy, nice = false}, axis = {grid = false}, title = labels[2]}
            })
    return p
end

function linkstable(h::Hamiltonian, (a1, a2) = (1, 2))
    lat = h.lattice
    T = numbertype(lat)
    slats = sublats(lat)
    rs = sites(lat)
    table = NamedTuple{(:x, :y, :x2, :y2, :sublat, :tooltip, :opacity, :islink),
                       Tuple{T,T,T,T,NameType,String,Float64,Bool}}[]
    h0 = h.harmonics[1].h
    rows = Int[] # list of plotted destination sites for dn != 0
    for har in h.harmonics
        resize!(rows, 0)
        for ssrc in slats
            if iszero(har.dn)
                for (i, r) in enumeratesites(lat, ssrc)
                    x = get(r, a1, zero(T)); y = get(r, a2, zero(T))
                    push!(table, (x = x, y = y, x2 = x, y2 = y,
                                sublat = sublatname(lat, ssrc), tooltip = matrixstring_inline(i, h0[i, i]),
                                opacity = 1.0, islink = false))
                end
            end
            for sdst in slats
                itr = nonzero_indices(har, siterange(lat, sdst), siterange(lat, ssrc))
                for (row, col) in itr
                    iszero(har.dn) && col == row && continue
                    rsrc = rs[col]
                    rdst = (rs[row] + bravais(lat) * har.dn)
                    # sites in neighboring cells connected to dn=0 cell. But add only once.
                    if !iszero(har.dn) && !in(row, rows)
                        x = get(rdst, a1, zero(T)); y = get(rdst, a2, zero(T))
                        push!(table,
                            (x = x, y = y, x2 = x, y2 = y,
                            sublat = sublatname(lat, sdst), tooltip = matrixstring_inline(row, h0[row, row]),
                            opacity = 0.5, islink = false))
                        push!(rows, row)
                    end
                    rdst = (rsrc + rdst)/2
                    x  = get(rsrc, a1, zero(T)); y  = get(rsrc, a2, zero(T))
                    x´ = get(rdst, a1, zero(T)); y´ = get(rdst, a2, zero(T))
                    # Exclude links perpendicular to the screen
                    rdst ≈ rsrc || push!(table,
                        (x = x, y = y, x2 = x´, y2 = y´,
                        sublat = sublatname(lat, ssrc), tooltip = matrixstring_inline(row, col, har.h[row, col]),
                        opacity = iszero(har.dn) ? 1.0 : 0.5, islink = true))
                end
            end
        end
    end
    return table
end

function vltheme((sizex, sizey), points = false)
    p = @vlplot(
        tooltip = :tooltip,
        width = sizex, height = sizey,
        config = {
            circle = {stroke = :black, strokeWidth = 1, size = 200},
            line = {point = points},
            rule = {strokeWidth = 3}})
    return p
end

function _corners(table)
    min´ = max´ = (first(table).x, first(table).y)
    for row in table
        min´ = min.(min´, (row.x, row.y))
        max´ = max.(max´, (row.x, row.y))
    end
    return min´, max´
end

function domain_size(corners, size)
    sizex, sizey = make_it_two(size)
    domainx = (corners[1][1], corners[2][1])
    domainy = (corners[1][2], corners[2][2])
    dx = domainx[2]-domainx[1]
    dy = domainy[2]-domainy[1]
    if dx > dy
        sizex = size
        sizey = size * dy/dx
    else
        sizex = size * dx/dy
        sizey = size
    end
    return (domainx, domainy), (sizex, sizey)
end

make_it_two(x::Number) = (x, x)
make_it_two(x::Tuple{Number,Number}) = x

ext: jl


text:
# ENV["CUDA_VISIBLE_DEVICES"] = "0,1,2,3,4,5,6,7"
# using Revise
using ADSeismic
using ADCME
using MAT
using PyPlot
using Random
using DelimitedFiles
using Optim
using Dates
matplotlib.use("Agg")
close("all")

gpu = has_gpu() ? true : false

data_dir = "data/acoustic"
method = "NNFWI/marmousi"

figure_dir = string("figure/",method)
result_dir = string("result/",method)
model_dir = string("nn_model/",method)
loss_file = joinpath(result_dir, "loss_$(Dates.now()).txt")

check_path(dir) = !ispath(dir) ? mkpath(dir) : nothing
check_path(figure_dir)
check_path(result_dir)
check_path(model_dir)

################### Inversion using Automatic Differentiation #####################
reset_default_graph()
model_name = "models/marmousi2-model-smooth.mat"
# model_name = "models/marmousi2-model-smooth-large.mat"
# model_name = "models/BP-model-smooth.mat"

## load model setting
params = load_params(model_name, vp_ref=1e3)
src = load_acoustic_source(model_name)
rcv = load_acoustic_receiver(model_name)
vp0 = matread(model_name)["vp"]

## original fwi
# vp = Variable(vp0)

## fwi with fc
# nx, ny = params.NX, params.NY
# dx, dy = params.DELTAX, params.DELTAY
# z = zeros((nx+2)*(ny+2),2)
# for i = 1:nx+2
#  for j = 1:ny+2
#     z[(i-1)*(ny+2)+j, :] = [(i-1)*dx (j-1)*dy]
#   end
# end
# init_guess = fc_init([2, 20, 20, 20, 1])
# θ = Variable(init_guess)
# c = fc(z, [20, 20, 20, 1], θ) * 100.0
# c = reshape(c, (nx+2, ny+2))
# vp = vp0 + c

## fwi with cnn
Random.seed!(123)
# tf.set_random_seed(123)
z = constant(rand(Float32, 1, 8))
# x = Generator(z, ratio=size(vp0)[1]/size(vp0)[2], base=8)
num_layer = 4
Δvp = Generator(z, w0=ceil(Int, size(vp0)[1]/(2^num_layer)), h0=ceil(Int, size(vp0)[2]/(2^num_layer)), num_layer=num_layer, vmin=-1.5, vmax=1.5)
Δvp = tf.cast(Δvp, tf.float64)*1000.0
# Δvp = Variable(zeros(size(vp0)))
vp = add_initial_model(Δvp, constant(vp0))
if exists(matopen(model_name), "mask")
  mask = matread(model_name)["mask"]
  vp = mask .* vp + (1.0.-mask) .* vp0
end

## assemble acoustic propagator model
model = x->AcousticPropagatorSolver(params, x, vp)
vars = get_collection()

## load data
std_noise = 0
Random.seed!(1234);
Rs = Array{Array{Float64,2}}(undef, length(src))
for i = 1:length(src)
  Rs[i] = readdlm(joinpath(data_dir, "marmousi-r$i.txt"))
    # Rs[i] = readdlm(joinpath(data_dir, "BP-r$i.txt"))
  Rs[i] .+= randn(size(Rs[i])) .* std(Rs[i]) .* std_noise
end

## calculate loss and gradient
if gpu
  losses, grads = compute_loss_and_grads_GPU(model, src, rcv, Rs, vars)
  grad = sum(grads)
  loss = sum(losses)
else
  [SimulatedObservation!(model(src[i]), rcv[i]) for i = 1:length(src)]
  loss = sum([sum((rcv[i].rcvv-Rs[i])^2) for i = 1:length(rcv)])
  grad = gradients(loss, vars)
end

## optimization using Adam
# global_step = tf.Variable(0, trainable=false)
max_iter = 10000
# lr_decayed = tf.train.cosine_decay(0.001, global_step, max_iter)
lr_decayed = placeholder(0.0)
# opt = AdamOptimizer(learning_rate=lr_decayed).minimize(loss, global_step=global_step, colocate_gradients_with_ops=true)
opt = AdamOptimizer(learning_rate=lr_decayed).minimize(loss, colocate_gradients_with_ops=true)

## run inversion
sess = Session(); init(sess)
loss0 = run(sess, loss)
@info "Initial loss: ", loss0

fp = open(loss_file, "w")
write(fp, "0,$loss0\n")
iter0 = 0
function callback(_, iter, loss)
  iter += iter0
  if iter%10==0
    x = run(sess, vp)'
    clf()
    pcolormesh([0:params.NX+1;]*params.DELTAX/1e3,[0:params.NY+1;]*params.DELTAY/1e3,  x, shading="auto", cmap="jet")
    axis("scaled")
    colorbar(shrink=0.4)
    xlabel("x (km)")
    ylabel("z (km)")
    gca().invert_yaxis()
    title("Iteration = $iter")
    savefig(joinpath(figure_dir, "inv_$(lpad(iter,5,"0")).png"), bbox_inches="tight")
    writedlm(joinpath(result_dir, "inv_$(lpad(iter,5,"0")).txt"), x)
  end
  if iter%100 == 0
    ADCME.save(sess, joinpath(model_dir, "NNFWI_$(lpad(iter,5,"0")).mat"))
  end
  write(fp, "$iter,$loss\n")
  flush(fp)
end

## optimization using Adam
time = 0
for iter = 0:max_iter
  # global time += @elapsed  _, ls, lr = run(sess, [opt, loss, lr_decayed])
  # if iter < 500
  #   lr = iter/500 * 1e-3
  # else
  #   # lr = (max_iter - iter)/(max_iter - 500) * 1e-3
  #   lr = 1e-3
  # end
  lr = 1e-3
  t = @elapsed  _, ls = run(sess, [opt, loss], feed_dict=Dict(lr_decayed=>lr))
  callback(nothing, iter, ls)
  println("   $iter\t$ls\t$lr\t$t")
end

## optimization using BFGS
iter0 = max_iter+1
Optimize!(sess, loss, 1000, vars=vars, grads=grad, callback=callback)

close(fp)


text:
using Revise
using AdFem
using PyPlot
using LinearAlgebra
using Statistics
using MAT

mmesh = Mesh(joinpath(PDATA, "twoholes_large.stl"))
mmesh = Mesh(mmesh.nodes * 10, mmesh.elems, -1, 2)

function f(x, y)
    0.0001*(10/(1+x^2) + x * y + 10*y^2)
end

ν = eval_f_on_gauss_pts(f, mmesh)
K = constant(compute_fem_laplace_matrix(ν, mmesh))
B = constant(compute_interaction_matrix(mmesh))
Z = [K -B'
    -B spzero(size(B,1))]

bd1 = bcnode((x,y)->y>0.23-1e-5, mmesh)
bd2 = bcnode((x,y)->y<=0.23-1e-5, mmesh)
bd = [bd1;bd2]
bd = [bd; bd .+ mmesh.ndof; 2mmesh.ndof + 1]

rhs = zeros(2mmesh.ndof + mmesh.nelem)
bdval = zeros(length(bd))
bdval[1:length(bd1)] .= 1.0
Z, rhs = impose_Dirichlet_boundary_conditions(Z, rhs, bd, bdval)
sol = Z\rhs

sess = Session(); init(sess)
S = run(sess, sol)

matwrite("fenics/fwd2.mat", Dict("u"=>S))

close("all")
figure(figsize=(20, 5))
subplot(131)
visualize_scalar_on_fem_points(S[1:mmesh.nnode], mmesh)
title("x displacement")
subplot(132)
visualize_scalar_on_fem_points(S[1+mmesh.ndof:mmesh.nnode + mmesh.ndof], mmesh)
title("y displacement")
subplot(133)
visualize_scalar_on_fvm_points(S[2mmesh.ndof+1:end], mmesh)
title("Pressure")
savefig("fenics/fwd2.png")

close("all")
visualize_vector_on_fem_points(S[1:mmesh.nnode], S[1+mmesh.ndof:mmesh.nnode + mmesh.ndof], mmesh)
axis("scaled")
savefig("fenics/fwd2_quiver.png")

close("all")
visualize_scalar_on_gauss_points(ν, mmesh)
savefig("fenics/fw2_nu.png")


text:
CUDA_init()
basis = calculate_basis(L,LMAX,N,K, 2.5, dq(intensity))
d_basis = CUDA_store_basis(basis)
c3ref = ones(N,2*N,K,K,K)

#Cuda
println("Calculating CUDA version")
c_cuda = FullCorrelation_parallized(intensity, d_basis)

# #Normal
println("Calculating CPU version")
c_normal = FullCorrelation_parallized(intensity, basis)

#Are they the same?
@test sum(abs, c_normal-c_cuda)/sum(abs, c_normal) < 1e-5

#For performance tests
for i=1:5
  println("Cuda:")
  @time FullCorrelation_parallized(intensity, d_basis)
  println("Normal:")
  @time FullCorrelation_parallized(intensity, basis)
  println("-----")
end

# println("CUDA energy:")
# e_cuda = energy(intensity, d_basis, c3ref, "Bayes")
# println(e_cuda)
#
# println("CPU energy:")
# e_cpu = energy(intensity, basis, c3ref, "Bayes")
# println(e_cpu)
#
# @test abs(e_cuda - e_cpu)/abs(e_cuda) < 1e-6
#
# for i=1:5
#     println("CUDA energy:")
#     @time e_cuda = energy(intensity, d_basis, c3ref, "Bayes")
#
#     println("CPU CUDA energy:")
#     @time e_cpu = energy(intensity, basis, c3ref, "Bayes")
# end


text:
#
println("Fb) Symbolic simplification of Racah expressions by means of sum rules.")
#
using SymEngine

if  true
    # Test for sum rules; the 'simple form' (without additional phases) has now been tested for all (1..47)
    # selectRacahExpression(1..45); with additional phases for selectRacahExpression(1..30, 32..47)
    # test simplification of deltas with 31, 38, 39
    rex = RacahAlgebra.selectRacahExpression(41);          println("rex-original        = $rex")
    ## rex = RacahAlgebra.equivalentForm(rex);                println("rex-equivalent      = $rex")
    rex = RacahAlgebra.evaluate(rex);
end


text:
"""
A Calibration holds two TidalFluxQuantities

- qto is the 'true' quantity that we want to calibrate to
- qfrom is the measured quantity that we want to calibrate from
"""
type Calibration{T<:Quantity, F<:Quantity}
    qto::T
    qfrom::F
end

"""Return the to quantity"""
to_quantity(c::Calibration) = c.qto

"""Return the from quantity"""
from_quantity(c::Calibration) = c.qfrom

TidalFluxQuantities.times(c::Calibration) = (times(to_quantity(c)),times(from_quantity(c)))

Base.size(c::Calibration) = (length(to_quantity(c)),length(from_quantity(c)))

function Base.vcat{T,F}(cs::Calibration{T,F}...)
    qto = vcat(unique(T[to_quantity(c) for c in cs])...)
    qfrom = vcat(unique(F[from_quantity(c) for c in cs])...)
    Calibration(qto,qfrom)
end


text:
import Pkg; Pkg.activate("../../")
using StatsPlots
using CytofDensityEstimation; const cde = CytofDensityEstimation
using CytofDensityEstimation: Util.SkewT
using CytofDensityEstimation: Util.skewfromaltskewt, Util.scalefromaltskewt
import Random
include("cdem1.jl")

Random.seed!(1234);
yC = rand(SkewT(2, .7, 7, -10), 1000)
yT = rand(SkewT(-1, .7, 7, -3), 1000)
histogram(yC, label=nothing)
histogram(yT, label=nothing)
K = 3

Random.seed!(0);
m, spl = generate_model_and_sampler(yC, yT, K, eps=0.01, L=20);
exclude = [:vC, :vT, :zetaC, :zetaT, :lambdaC, :lambdaT]
# @time chain = litesample(m, spl, 20, discard_initial=10, thinning=1,
#                          buffersize=10, exclude=exclude);
@time chain = litesample(m, spl, 2000, discard_initial=1000, thinning=1,
                         buffersize=100, exclude=exclude);

lp = vec(get(chain, :lp)[1].data);
plot(lp, label=nothing)

boxplot(group(chain, :etaC).value.data[:, :, 1], label=nothing)
boxplot(group(chain, :etaT).value.data[:, :, 1], label=nothing)
boxplot(group(chain, :mu).value.data[:, :, 1], label=nothing)
boxplot(group(chain, :omega).value.data[:, :, 1], label=nothing)
boxplot(group(chain, :nu).value.data[:, :, 1], label=nothing)
boxplot(group(chain, :psi).value.data[:, :, 1], label=nothing)

omega = group(chain, :omega).value.data[:, :, 1]
psi = group(chain, :psi).value.data[:, :, 1]
phi = skewfromaltskewt.(sqrt.(omega), psi)
sigma = scalefromaltskewt.(sqrt.(omega), psi)

plot(group(chain, :tau).value.data[:, 1], label=nothing)
plot(group(chain, :etaC).value.data[:, :, 1], label=nothing)
plot(group(chain, :etaT).value.data[:, :, 1], label=nothing)
plot(group(chain, :mu).value.data[:, :, 1], label=nothing)
plot(group(chain, :nu).value.data[:, :, 1], label=nothing)
plot(phi, label=nothing)
plot(sigma, label=nothing)

max_stars_repo_name: luiarthur/CytofDensityEstimation

max_issues_repo_name: luiarthur/CytofDensityEstimation

max_forks_repo_name: luiarthur/CytofDensityEstimation


text:
export relhs,dh0s,dh1s,taus,pas,nstates,actions, action_names

# State dimension cutpoints
const vels = vcat(linspace(-100,-60,5),linspace(-50,-35,4),linspace(-30,30,21),linspace(35,50,4),linspace(60,100,5))
const relhs   = vcat(linspace(-8000,-4000,5),linspace(-3000,-1250,8),linspace(-1000,-800,3),linspace(-700,-150,12),linspace(-100,100,9), linspace(150,700,12),linspace(800,1000,3),linspace(1250,3000,8),linspace(4000,8000,5))
const dh0s = vels
const dh1s = vels
const taus  = linspace(0,40,41)
const pas = [1,2,3,4,5,6,7,8,9]

# Number of states
const nstates = length(relhs)*length(dh0s)*length(taus)*length(dh1s)

# Actions
const actions = [1, 2, 3, 4, 5, 6, 7, 8, 9]
const action_names = ["COC","DNC","DND","DES1500","CL1500","SDES1500","SCL1500","SDES2500","SCL2500"]

max_stars_repo_name: alisamiii/VerticalCAS

max_issues_repo_name: alisamiii/VerticalCAS

max_forks_repo_name: bethelhall/CoCoCAS


text:
using BasisFunctions, LinearAlgebra, DomainSets, GridArrays, Test, StaticArrays, FrameFun
@testset begin
    B = (Fourier(11) → -1..1)^2
    Dom = disk(0.8)
    @test support(dictionary(∂x(random_expansion(extensionframe(B, Dom)))))≈Dom

    # @test SamplingStyle(ExtensionFramePlatform(FrameFun.ProductPlatform(FourierPlatform(),FourierPlatform()),(0.0..0.5)^2)) ==
    #     ProductSamplingStyle(OversamplingStyle(),OversamplingStyle())

    @test dictionary(FrameFun.approximationproblem(Fourier(100),0.0..0.5)) == extensionframe(Fourier(100),0.0..0.5)
    # Test defaults
    @test AZ_A(FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=false)≈
        AZ_A(FrameFun.approximationproblem(Fourier(100),0.0..0.5))

    A = AZ_A(FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=false)
    L = samplingparameter(OversamplingStyle(),FrameFun.approximationproblem(Fourier(100),0.0..0.5))
    a1 = evaluation(Fourier(L),interpolation_grid(Fourier(L)))
    a2 = IndexRestriction(GridBasis(interpolation_grid(Fourier(L))),1:200)
    a3 = BasisFunctions.FourierIndexExtension(Fourier(100),Fourier(L))
    @test A≈a2*a1*a3

    A = AZ_A(FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=true)
    L = samplingparameter(OversamplingStyle(),FrameFun.approximationproblem(Fourier(100),0.0..0.5))
    a1 = evaluation(Fourier(L),interpolation_grid(Fourier(L)))
    a2 = IndexRestriction(GridBasis(interpolation_grid(Fourier(L))),1:200)
    a3 = BasisFunctions.FourierIndexExtension(Fourier(100),Fourier(L))
    a4 = ScalingOperator(dest(a2),1/sqrt(L))
    @test A≈a4*a2*a1*a3

    # Test differnence normalizationoperator
    s = svdvals(AZ_A(FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=false))
    N = FrameFun.normalizationoperator(OversamplingStyle(),FrameFun.approximationproblem(Fourier(100),0.0..0.5))
    L = samplingparameter(OversamplingStyle(),FrameFun.approximationproblem(Fourier(100),0.0..0.5))
    @test N isa DictionaryOperator
    @test N[1,1] ≈ 1/sqrt(L)
    @test L == 399
    @test 47==sum(s.<.1*sqrt(L))
    @test 49==sum(s.>.9*sqrt(L))

    s = svdvals(AZ_A(FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=true))
    @test 47==sum(s.<.1)
    @test 49==sum(1+1e-10 .> s .>.9)

    # right side should be appropriately normalized
    @test normalized_discretization(exp, OversamplingStyle(),FrameFun.approximationproblem(Fourier(100),0.0..0.5);oversamplingfactor=2,normalizedsampling=true)[2]≈
        1/sqrt(399)*GridSampling(subgrid(interpolation_grid(Fourier(399)),0.0..0.5))*exp

    # left side should be appropriately normalized
    @test AZ_A(FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=true)≈
        normalized_discretization(exp, OversamplingStyle(),FrameFun.approximationproblem(Fourier(100),0.0..0.5);oversamplingfactor=2,normalizedsampling=true)[1]

    # right side should be appropriately normalized
    @test normalized_discretization(exp, OversamplingStyle(),FrameFun.approximationproblem(Fourier(100),0.0..0.5);oversamplingfactor=2,normalizedsampling=false)[2]≈
        GridSampling(subgrid(interpolation_grid(Fourier(399)),0.0..0.5))*exp

    # left side should be appropriately normalized
    @test AZ_A(FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=false)≈
        normalized_discretization(exp, OversamplingStyle(),FrameFun.approximationproblem(Fourier(100),0.0..0.5);oversamplingfactor=2,normalizedsampling=false)[1]

    F = approximate(exp,FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=true)
    @test abs(F[1](.2)-exp(.2) )< 1e-12

    F = approximate(exp,FrameFun.approximationproblem(Fourier(100),0.0..0.5);samplingstyle=OversamplingStyle(),oversamplingfactor=2,normalizedsampling=false)
    @test abs(F[1](.2)-exp(.2) )< 1e-12

    P = WeightedSumPlatform(FourierPlatform(),x->1,x->sqrt(x))
    ap = FrameFun.approximationproblem(P,(10,10))
    azdual_dict(ap)
end


text:
Dict{Int32,String}(
533 => "Aruba",
4 => "Afghanistan",
24 => "Angola",
660 => "Anguilla",
8 => "Albania",
248 => "Aland",
20 => "Andorra",
784 => "United Arab Emirates",
32 => "Argentina",
51 => "Armenia",
16 => "American Samoa",
10 => "Antarctica",
36 => "Ashmore and Cartier Is.",
260 => "Fr. S. and Antarctic Lands",
28 => "Antigua and Barb.",
36 => "Australia",
40 => "Austria",
31 => "Azerbaijan",
108 => "Burundi",
56 => "Belgium",
204 => "Benin",
854 => "Burkina Faso",
50 => "Bangladesh",
100 => "Bulgaria",
48 => "Bahrain",
44 => "Bahamas",
70 => "Bosnia and Herz.",
652 => "St. Barthelemy",
112 => "Belarus",
84 => "Belize",
60 => "Bermuda",
68 => "Bolivia",
76 => "Brazil",
52 => "Barbados",
96 => "Brunei",
64 => "Bhutan",
72 => "Botswana",
140 => "Central African Rep.",
124 => "Canada",
756 => "Switzerland",
152 => "Chile",
156 => "China",
384 => "Ivory Coast",
-99 => "Clipperton I.",
120 => "Cameroon",
180 => "Congo (Kinshasa)",
178 => "Congo (Brazzaville)",
184 => "Cook Is.",
170 => "Colombia",
174 => "Comoros",
132 => "Cape Verde",
188 => "Costa Rica",
-99 => "Coral Sea Is.",
192 => "Cuba",
531 => "Curacao",
136 => "Cayman Is.",
-99 => "N. Cyprus",
196 => "Cyprus",
203 => "Czech Rep.",
276 => "Germany",
262 => "Djibouti",
212 => "Dominica",
208 => "Denmark",
214 => "Dominican Rep.",
12 => "Algeria",
218 => "Ecuador",
818 => "Egypt",
232 => "Eritrea",
-99 => "Dhekelia",
724 => "Spain",
233 => "Estonia",
231 => "Ethiopia",
246 => "Finland",
242 => "Fiji",
238 => "Falkland Is.",
250 => "France",
234 => "Faroe Is.",
583 => "Micronesia",
266 => "Gabon",
275 => "Gaza",
826 => "United Kingdom",
268 => "Georgia",
831 => "Guernsey",
288 => "Ghana",
292 => "Gibraltar",
324 => "Guinea",
270 => "Gambia",
624 => "Guinea Bissau",
226 => "Eq. Guinea",
300 => "Greece",
308 => "Grenada",
304 => "Greenland",
320 => "Guatemala",
316 => "Guam",
328 => "Guyana",
344 => "Hong Kong",
334 => "Heard I. and McDonald Is.",
340 => "Honduras",
191 => "Croatia",
332 => "Haiti",
348 => "Hungary",
360 => "Indonesia",
833 => "Isle of Man",
356 => "India",
-99 => "Indian Ocean Ter.",
86 => "Br. Indian Ocean Ter.",
372 => "Ireland",
364 => "Iran",
368 => "Iraq",
352 => "Iceland",
376 => "Israel",
380 => "Italy",
388 => "Jamaica",
832 => "Jersey",
400 => "Jordan",
392 => "Japan",
-99 => "Baykonur",
398 => "Kazakhstan",
404 => "Kenya",
417 => "Kyrgyzstan",
116 => "Cambodia",
296 => "Kiribati",
659 => "St. Kitts and Nevis",
410 => "S. Korea",
-99 => "Kosovo",
414 => "Kuwait",
418 => "Laos",
422 => "Lebanon",
430 => "Liberia",
434 => "Libya",
662 => "Saint Lucia",
438 => "Liechtenstein",
144 => "Sri Lanka",
426 => "Lesotho",
440 => "Lithuania",
442 => "Luxembourg",
428 => "Latvia",
446 => "Macau",
663 => "St. Martin",
504 => "Morocco",
492 => "Monaco",
498 => "Moldova",
450 => "Madagascar",
462 => "Maldives",
484 => "Mexico",
584 => "Marshall Is.",
807 => "Macedonia",
466 => "Mali",
470 => "Malta",
104 => "Myanmar",
499 => "Montenegro",
496 => "Mongolia",
580 => "N. Mariana Is.",
508 => "Mozambique",
478 => "Mauritania",
500 => "Montserrat",
480 => "Mauritius",
454 => "Malawi",
458 => "Malaysia",
516 => "Namibia",
540 => "New Caledonia",
562 => "Niger",
574 => "Norfolk Island",
566 => "Nigeria",
558 => "Nicaragua",
570 => "Niue",
528 => "Netherlands",
578 => "Norway",
524 => "Nepal",
520 => "Nauru",
554 => "New Zealand",
512 => "Oman",
586 => "Pakistan",
591 => "Panama",
612 => "Pitcairn Is.",
604 => "Peru",
608 => "Philippines",
585 => "Palau",
598 => "Papua New Guinea",
616 => "Poland",
630 => "Puerto Rico",
408 => "N. Korea",
620 => "Portugal",
600 => "Paraguay",
258 => "Fr. Polynesia",
634 => "Qatar",
642 => "Romania",
643 => "Russia",
646 => "Rwanda",
-99 => "W. Sahara",
682 => "Saudi Arabia",
729 => "Sudan",
728 => "S. Sudan",
686 => "Senegal",
702 => "Singapore",
239 => "S. Geo. and S. Sandw. Is.",
654 => "Saint Helena",
90 => "Solomon Is.",
694 => "Sierra Leone",
222 => "El Salvador",
674 => "San Marino",
-99 => "Somaliland",
706 => "Somalia",
666 => "St. Pierre and Miquelon",
688 => "Serbia",
678 => "Sao Tome and Principe",
740 => "Suriname",
703 => "Slovakia",
705 => "Slovenia",
752 => "Sweden",
748 => "Swaziland",
534 => "Sint Maarten",
690 => "Seychelles",
760 => "Syria",
796 => "Turks and Caicos Is.",
148 => "Chad",
768 => "Togo",
764 => "Thailand",
762 => "Tajikistan",
795 => "Turkmenistan",
626 => "East Timor",
776 => "Tonga",
780 => "Trinidad and Tobago",
788 => "Tunisia",
792 => "Turkey",
798 => "Tuvalu",
158 => "Taiwan",
834 => "Tanzania",
800 => "Uganda",
804 => "Ukraine",
581 => "U.S. Minor Outlying Is.",
858 => "Uruguay",
840 => "United States",
-99 => "Guantanamo Bay USNB",
860 => "Uzbekistan",
336 => "Vatican",
670 => "St. Vin. and Gren.",
862 => "Venezuela",
92 => "British Virgin Is.",
850 => "U.S. Virgin Is.",
704 => "Vietnam",
548 => "Vanuatu",
275 => "West Bank",
876 => "Wallis and Futuna",
-99 => "Akrotiri",
882 => "Samoa",
887 => "Yemen",
710 => "South Africa",
894 => "Zambia",
716 => "Zimbabwe",
typemax(Int32) => "MISSING"
)


text:
using Pkg; Pkg.activate(".")
Pkg.develop(url="../PeriDyn")
Pkg.develop(url="../PDMesh")

using PDBenchmark

Es = 100
nu = 0.2
K = Es/3/(1-2nu)
G = Es/2/(1+nu)
rho = 1000.0
cs = 0.15
reso = 0.1
horizon = 3*reso

C = 18K/(pi*horizon^4)

gen_mat = PDBenchmark.NameParam(:GeneralMaterial, (horizon), Dict(:max_neigh=>200))

spc_mat = PDBenchmark.NameParam(:OrdinaryStateBasedSpecific, ([K], [G], [cs], [rho], ), Dict())

test = PDBenchmark._3PointBending(;gen_mat=gen_mat, spc_mat=spc_mat, resolution=reso, solver_=:vv, file_prefix="Flexure3PointOSB_vv")

env = PDBenchmark.run!(test)

y = env.Out["Force"][1, :]
x = vec(env.Out["Displacement"])

using Plots

plot(x, y, marker=4, linewidth=1, label=raw"F_x")
xlabel!("Displacement")
ylabel!("Force")
savefig("./output/osb_vv.png")

max_stars_repo_name: ravinderbhattoo/PDBenchmark

max_issues_repo_name: ravinderbhattoo/PDBenchmark

max_forks_repo_name: ravinderbhattoo/PDBenchmark


text:
using Test

import Neptune.ExpressionExplorer: SymbolsState, compute_symbolreferences, FunctionNameSignaturePair

@testset "Method signatures" begin

disjoint(x,y) = isempty(x ∩ y)

function mutually_disjoint(x, xs...)
    all(xs) do y
        disjoint(x,y)
    end && mutually_disjoint(xs...)
end
mutually_disjoint(x) = true

function methods_can_coexist(defs::Expr...)
    symstates = compute_symbolreferences.(defs)
    funcnamesigs = [keys(syms.funcdefs) for syms in symstates]
    mutually_disjoint(funcnamesigs...)
end

@testset "Different method signatures across cells" begin
    @test methods_can_coexist(
        :(f(x, y) = 1),
        :(f(x) = 2),
    )
    @test methods_can_coexist(
        :(f(x::A) = 1),
        :(f(x::B) = 2),
    )
    @test methods_can_coexist(
        :(f(x, y=1) = 1),
        :(f(x, y) = 2),
    )
    @test methods_can_coexist(
        :(f(x::e(f{g})=3) = 1),
        :(f(x::h where i) = 2),
    )
    @test methods_can_coexist(
        :(f(x::Tuple{X,T} where T) = 1),
        :(f(x::Tuple{X,T}) = 2),
    )
    @test methods_can_coexist(
        :(f(x::A) where A = 1),
        :(f(x::A) = 2),
    )
    @test methods_can_coexist(
        :(f(x::String, y) = 1),
        :(f(x, y::String) = 2),
    )
    @test methods_can_coexist(
        :(f(x::A) = 1),
        :(f(x::B) = 2),
    )
    @test methods_can_coexist(
        :(f(x, y...) = 1),
        :(f(x) = 2),
    )
    @test methods_can_coexist(
        :(f(x, y::Z...) = 1),
        :(f(x, y::X...) = 2),
    )

    # what is this called again?
    @test methods_can_coexist(
        :(f(x::T) where T = 1),
        :(f(x) = 2),
    )
end

@testset "Identical method signatures across cells" begin
    @test !methods_can_coexist(
        :(f(x) = 3),
        :(f(y) = 3),
    )
    @test !methods_can_coexist(
        :(f(x) = 3),
        :(f(y; z) = 3),
    )
    @test !methods_can_coexist(
        :(f(x) = 3),
        :(f(y::Any) = 3),
    )
    # function using built in type synonyms
    # like Int and Int64
    @assert string(Int) == "Int64" || string(Int) == "Int32"
    @test_broken !methods_can_coexist(
        :(f(x::Int) = 3),
        Meta.parse("f(x::$(string(Int))) = 4"),
    )

    # multiple methods per cell
    @test !methods_can_coexist(
        :(f(x::Int) = 1; f(x::String) = 2),
        :(f(x::String) = 3; f(x::Vector) = 4),
    )

    # methods only differing in key word arguments
    @test !methods_can_coexist(
        :(f() = 1),
        :(f(; x) = 3),
    )
end
end


text:
using NativeHTML

frag = fragment() do
    div() do
        span("Hello", style="color:red;")
        text(", ")
        b("World!")
    end
end

display(frag)

page = html() do
    head() do
        title("Hello, World!")
    end
    body() do
        div() do
            span("Hello", style="color:red;")
            text(", ")
            b("World!")
        end
    end
end

display(page)


text:
module Sample
using FastGaussQuadrature
using ..Spectral
"""
    SemiCircle(Euv, β, isFermi::Bool, symmetry::Symbol, Grid, type::Symbol, rtol = nothing, degree = 24, regularized::Bool = true)

Generate Green's function from a semicircle spectral density.
Return the function on Grid and the systematic error.

#Arguments
- `Euv` : ultraviolet energy cutoff
- `β` : inverse temperature
- `isFermi`: is fermionic or bosonic
- `symmetry`: particle-hole symmetric :ph, particle-hole antisymmetric :pha, or :none
- `Grid`: grid to evalute on
- `type`: imaginary-time with :τ, or Matsubara-frequency with :ωn
- `rtol`: accuracy to achieve
- `degree`: polynomial degree for integral
- `regularized`: use regularized bosonic kernel if symmetry = :none
"""
function SemiCircle(Euv, β, isFermi::Bool, symmetry::Symbol, Grid, type::Symbol, rtol = nothing, degree = 24, regularized::Bool = true)
    # calculate Green's function defined by the spectral density
    # S(ω) = sqrt(1 - (ω / Euv)^2) / Euv # semicircle -1<ω<1
    if type == :τ
        IsMatFreq = false
    elseif type == :ωn
        IsMatFreq = true
    else
        error("not implemented!")
    end

    ##### Panels endpoints for composite quadrature rule ###
    npo = Int(ceil(log(β * Euv) / log(2.0)))
    pbp = zeros(Float64, 2npo + 1)
    pbp[npo+1] = 0.0
    for i = 1:npo
        pbp[npo+i+1] = 1.0 / 2^(npo - i)
    end
    pbp[1:npo] = -pbp[2npo+1:-1:npo+2]

    function Green(n, IsMatFreq)
        #n: polynomial order
        xl, wl = gausslegendre(n)
        xj, wj = gaussjacobi(n, 1 / 2, 0.0)

        G = IsMatFreq ? zeros(ComplexF64, length(Grid)) : zeros(Float64, length(Grid))
        err = zeros(Float64, length(Grid))
        for (τi, τ) in enumerate(Grid)
            for ii = 2:2npo-1
                a, b = pbp[ii], pbp[ii+1]
                for jj = 1:n
                    x = (a + b) / 2 + (b - a) / 2 * xl[jj]
                    if (symmetry == :ph || symmetry == :pha) && x < 0.0
                        #spectral density is defined for positivie frequency only for correlation functions
                        continue
                    end
                    ker = IsMatFreq ? Spectral.kernelΩ(isFermi, symmetry, τ, Euv * x, β, regularized) : Spectral.kernelT(isFermi, symmetry, τ, Euv * x, β, regularized)
                    G[τi] += (b - a) / 2 * wl[jj] * ker * sqrt(1 - x^2)
                end
            end

            a, b = 1.0 / 2, 1.0
            for jj = 1:n
                x = (a + b) / 2 + (b - a) / 2 * xj[jj]
                ker = IsMatFreq ? Spectral.kernelΩ(isFermi, symmetry, τ, Euv * x, β, regularized) : Spectral.kernelT(isFermi, symmetry, τ, Euv * x, β, regularized)
                G[τi] += ((b - a) / 2)^1.5 * wj[jj] * ker * sqrt(1 + x)
            end

            if symmetry != :ph && symmetry != :pha
                #spectral density is defined for positivie frequency only for correlation functions
                a, b = -1.0, -1.0 / 2
                for jj = 1:n
                    x = (a + b) / 2 + (b - a) / 2 * (-xj[n-jj+1])
                    ker = IsMatFreq ? Spectral.kernelΩ(isFermi, symmetry, τ, Euv * x, β, regularized) : Spectral.kernelT(isFermi, symmetry, τ, Euv * x, β, regularized)
                    G[τi] += ((b - a) / 2)^1.5 * wj[n-jj+1] * ker * sqrt(1 - x)
                end
            end
        end
        return G
    end

    g1 = Green(degree, IsMatFreq)
    if isnothing(rtol) == false
        g2 = Green(degree * 2, IsMatFreq)
        err = abs.(g1 - g2)
        @assert maximum(err) < rtol "Systematic error $(maximum(err)) is larger than $rtol, increase degree for the integral!"
    end
    return g1
end

"""
    MultiPole(β, isFermi::Bool, symmetry::Symbol, Grid, type::Symbol, poles, regularized::Bool = true)

Generate Green's function from a spectral density with delta peaks specified by the argument ``poles``.
Return the function on Grid and the systematic error.

#Arguments
- `β` : inverse temperature
- `isFermi`: is fermionic or bosonic
- `symmetry`: particle-hole symmetric :ph, particle-hole antisymmetric :pha, or :none
- `Grid`: grid to evalute on
- `type`: imaginary-time with :τ, or Matsubara-frequency with :ωn
- `poles`: a list of frequencies for the delta functions
- `regularized`: use regularized bosonic kernel if symmetry = :none
"""
function MultiPole(β, isFermi::Bool, symmetry::Symbol, Grid, type::Symbol, poles, regularized::Bool = true)
    # poles = [-Euv, -0.2 * Euv, 0.0, 0.8 * Euv, Euv]
    # poles=[0.8Euv, 1.0Euv]
    # poles = [0.0]
    if type == :τ
        IsMatFreq = false
    elseif type == :ωn
        IsMatFreq = true
    else
        error("not implemented!")
    end

    g = IsMatFreq ? zeros(ComplexF64, length(Grid)) : zeros(Float64, length(Grid))
    for (τi, τ) in enumerate(Grid)
        for ω in poles

            if (symmetry == :ph || symmetry == :pha) && ω < 0.0
                #spectral density is not defined for negative frequency
                continue
            end

            if IsMatFreq == false
                g[τi] += Spectral.kernelT(isFermi, symmetry, τ, ω, β, regularized)
            else
                g[τi] += Spectral.kernelΩ(isFermi, symmetry, τ, ω, β, regularized)
            end
        end
    end
    return g
end

end


text:
export TopologyError

type TopologyError <: Exception
  desc :: AbstractString
end
Base.showerror(io::IO, e::TopologyError) = print(io, "Illegal Network Topology: ", e.desc)


text:
using Revise
using MiniPascal
using Test

const m = MiniPascal

const progs = ["""
program foo;

begin
  writeln(5 + 2);
end.
""",

"""
program prog2;

begin
  var a, b : int;
  a := 23;
  b := 42;
  writeln(a + b);
end.
""",

"""
program prog3;

function doubleit(x:int): int;
  begin
    return 2*x;
  end;

begin
  var a, b : int;
  a := 23;
  b := doubleit(a);
  writeln(b);
end.
""",

"""
program prog4;

begin
  writeln(101 % 3);
end.
""",

"""
program prog5;

begin
  writeln(true and false);
end.
""",

"""
program prog6;

begin
  writeln(not true or not false);
end.
""",

"""
program prog7;

begin
  var a, b : int;
  a := 7;
  b := 42;
  writeln(a + b);
end.
""",

"""
program prog8;

function doubleit(x:int): int;
  begin
    return 2*x;
  end;

begin
  var a, b : int;
  a := 23;
  b := doubleit(a);
  writeln(b);
end.
""",

"""
program prog9;

function double_and_return_orig(var x:int): int;
  begin
    var tmp: int;
    tmp := x;
    x := 2*x;
    return tmp;
  end;

begin
  var a, b: int;
  a := 23;
  b := double_and_return_orig(a);
  writeln(a);
  writeln(b);
end.
""",

"""
program prog10;

begin
  var x: int;
  x := 23;
  if x > 0
  then writeln(2*x)
  else writeln(x);
end.
""",

"""
program prog11;

begin
  var x, y : int;
  var s : string;
  y := 5;
  x := 0;
  while x < 10
  do begin
    if x <= y
      then s := " is less than or equal to "
      else s := " is greater than ";
    writeln(x, s, y);
    x := x+1;
  end;
end.
""",

"""
program prog12;

procedure printx();
begin
  writeln(x);
end;

procedure increment(var z:int);
begin
  z := z+1;
end;

begin
  var x: int;
  x := 42;
  printx();
  begin
    var x:int;
    x := 22;
    increment(x);
    printx();
  end;
  printx();
end.
""",

"""
program prog13;

begin
  var x: real;
  x := 23.0;
  if (x > 0.0) and true
  then writeln(2.0*x)
  else writeln(x);
end.
""",

"""
program prog14;

begin
  var s,x,y,z: string;
  x := "Hello";
  y := "hello";
  z := ", world!";
  if x < y
  then s:=x+z
  else s:=y+z;
  writeln(s)
end.
""",

"""
program prog15;

function fact(x:int):int;
begin
  if (x = 0) or (x = 1)
    then return 1;
  return x * fact(x-1);
end;

begin
  var x: int;
  x := 5
  writeln(fact(x));
end.
""",

"""
program prog16;

begin
  writeln(-2 + 44);
end.
""",

"""
program prog17;
function myadd(x:int, y:int):int;
  begin
    return x+y;
  end;

begin
  var a,b:int
  var c:boolean
  writeln(myadd(22,20));
end.
""",

"""
program prog18;
function myadddoubleds(x:int, y:int):int;
  begin
    return mydouble(x)+mydouble(y);
  end;

{*function mydouble(a:real):real;
  begin
    return 42.0 {* My favourite double *};
  end;*}

function mydouble(a:int):int;
  begin
    return a*2;
  end;

begin
  var a,b:int
  var c:boolean
  writeln(myadddoubleds(22,20));
end.
""",

"""
program prog19;

begin
  var a: array[38+4] of int;
  writeln(a.size);
end.
""",

"""
program prog20;

begin
  var a: array[3] of boolean;
  a[0] := true;
  a[1] := not false;
  a[2] := true and false;
  writeln(a[0]);
  writeln(a[1]);
  writeln(a[2]);
end.
""",

"""
program prog21;

begin
  var a: array[3] of int;
  var i: int;
  i := 0;
  while i < 3 do
    begin
      a[i] := i*10;
      i := i+1;
    end;
  writeln(a[0]);
  writeln(a[1]);
  writeln(a[2]);
end.
""",

]

# Write your own tests here.
function run_prog(i::Int)
  io = IOBuffer()
  m.generate(progs[i], io)
  code = String(take!(io))
  filename = "out.ll"
  file = open(filename, "w")
  println(file, code)
  close(file)
  run(`lli $(filename)`)
end

# @testset "MiniPascal.jl" begin
  run_prog(1)
# end

max_stars_repo_name: juhamyllari/minipascal-julia

max_issues_repo_name: juhamyllari/minipascal-julia

max_forks_repo_name: juhamyllari/minipascal-julia


text:
println("Test de print")
global x=12*100
println(x)

s1="I am a string."
s2="""Another string"""
"$s1$s2"

contacte=Dict("Luca"=>111,"Filip"=>"222");
contacte["Luca"]=112;
contacte["Luca"]
pop!(contacte,"Filip")

xTuple=("ter","mer","ser")
xTuple[2]

fibonacci=[1,1,2,3,5,8,13]
fibonacci[3]=0
push!(fibonacci,21)
pop!(fibonacci)

#Multidimensional
numbers=[[1,1,1],[2,2,2],[3,3,3]]
rand(4,3,2)

#Loops
#a = 0
while x > 1100
    global x
    x = x-1
    println(x)
end

for n = 1:10
    println(n)
end

myfriends = ["Ted","Robyn","Barney","Lily"]
for friend in myfriends
    println("Hi $friend")
end

#Un loop mai interesant
p,q=5,5
A=zeros(p,q)

for i in 1:p
    for j in 1:q
        A[i,j]=i+j
    end
end
A

#echivalent>
B=zeros(p,q)
for i in 1:p, j in 1:q
    B[i,j]=i+j
end
B

#Comprehension:
C = [i+j for i in 1:p, j in 1:q]

for n in 1:10
    D = [i+j for i in 1:n, j in 1:n]
    display(D)
end

#Conditionals
α=3
β=90

if α>β
    println("$α is larger than $β")
elseif α<β
    println("$β is larger than $α")
else
    println("$β and $α are equal")
end

#Nifty>
(α>β) ? α : β
(α<β) && println("Nice")

max_stars_repo_name: luca-mm/Bachelor-Thesis

max_issues_repo_name: luca-mm/Bachelor-Thesis

max_forks_repo_name: luca-mm/Bachelor-Thesis


text:
using KernelAbstractions
using KernelAbstractions.Extras
using StaticArrays

@kernel function kernel_unroll!(a)
  @unroll for i in 1:5
    @inbounds a[i] = i
  end
end

@kernel function kernel_unroll!(a, ::Val{N}) where N
  let M = N+5
    @unroll for i in 6:M
      @inbounds a[i-5] = i
    end
    @synchronize
  end
end

# Check that nested `@unroll` doesn't throw a syntax error
@kernel function kernel_unroll2!(A)
  @uniform begin
    a = MVector{3, Float64}(1, 2, 3)
    b = MVector{3, Float64}(3, 2, 1)
    c = MMatrix{3, 3, Float64}(undef)
  end
  I = @index(Global)
  @inbounds for m in 1:3
    @unroll for j = 1:3
      @unroll for i = 1:3
        c[1, j] = m * a[1] * b[j]
      end
    end
    A[I] = c[1, 1]
    @synchronize(m % 2 == 0)
  end
end

let
  a = zeros(5)
  kernel! = kernel_unroll!(CPU(), 1, 1)
  wait(kernel!(a))
  wait(kernel!(a, Val(5)))
  kernel2! = kernel_unroll2!(CPU(), 1, 1)
  wait(kernel2!(a))
end


text:
module OpenTelemetrySDK

using Reexport

@reexport using OpenTelemetryAPI
@reexport using GarishPrint

include("exporter.jl")
include("trace/trace.jl")
include("metric/metric.jl")

end # module