text:
@testset "1.2.3.3 (d+e x^n)^q (a+b x^n+c x^(2 n))^p" begin
    (a, b, c, d, e, f, n, p, q, x, ) = @variables a b c d e f n p q x

    #= ::Package:: =#

    #= ::Title::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^3)^q*(a+b*x^3+c*x^6)^p=#

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^3)^q*(a+b*x^3+c*x^6)^p*with*b=0=#

    @test_int [(d + e*x^3)/(a + c*x^6), x, 12, (d*atan((c^(1/6)*x)/a^(1/6)))/(3*a^(5/6)*c^(1/6)) - ((sqrt(c)*d + sqrt(3)*sqrt(a)*e)*atan(sqrt(3) - (2*c^(1/6)*x)/a^(1/6)))/(6*a^(5/6)*c^(2/3)) + ((sqrt(c)*d - sqrt(3)*sqrt(a)*e)*atan(sqrt(3) + (2*c^(1/6)*x)/a^(1/6)))/(6*a^(5/6)*c^(2/3)) - (e*log(a^(1/3) + c^(1/3)*x^2))/(6*a^(1/3)*c^(2/3)) - ((sqrt(3)*sqrt(c)*d - sqrt(a)*e)*log(a^(1/3) - sqrt(3)*a^(1/6)*c^(1/6)*x + c^(1/3)*x^2))/(12*a^(5/6)*c^(2/3)) + ((sqrt(3)*sqrt(c)*d + sqrt(a)*e)*log(a^(1/3) + sqrt(3)*a^(1/6)*c^(1/6)*x + c^(1/3)*x^2))/(12*a^(5/6)*c^(2/3))]
    @test_int [(d + e*x^3)/(a - c*x^6), x, 13, -(((d - (sqrt(a)*e)/sqrt(c))*atan((a^(1/6) - 2*c^(1/6)*x)/(sqrt(3)*a^(1/6))))/(2*sqrt(3)*a^(5/6)*c^(1/6))) + ((sqrt(c)*d + sqrt(a)*e)*atan((a^(1/6) + 2*c^(1/6)*x)/(sqrt(3)*a^(1/6))))/(2*sqrt(3)*a^(5/6)*c^(2/3)) - ((sqrt(c)*d + sqrt(a)*e)*log(a^(1/6) - c^(1/6)*x))/(6*a^(5/6)*c^(2/3)) + ((d - (sqrt(a)*e)/sqrt(c))*log(a^(1/6) + c^(1/6)*x))/(6*a^(5/6)*c^(1/6)) - ((d - (sqrt(a)*e)/sqrt(c))*log(a^(1/3) - a^(1/6)*c^(1/6)*x + c^(1/3)*x^2))/(12*a^(5/6)*c^(1/6)) + ((sqrt(c)*d + sqrt(a)*e)*log(a^(1/3) + a^(1/6)*c^(1/6)*x + c^(1/3)*x^2))/(12*a^(5/6)*c^(2/3))]

    #= ::Title::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^4)^q*(a+b*x^4+c*x^8)^p=#

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^4)^q*(a+b*x^4+c*x^8)^p*with*b=0=#

    @test_int [(d + e*x^4)/(a + c*x^8), x, 19, If(13>=8, -((sqrt(2 - sqrt(2))*((1 + sqrt(2))*sqrt(c)*d - sqrt(a)*e)*atan((sqrt(2 - sqrt(2))*a^(1/8) - 2*c^(1/8)*x)/(sqrt(2 + sqrt(2))*a^(1/8))))/(8*a^(7/8)*c^(5/8))) + (sqrt(2 + sqrt(2))*((1 - sqrt(2))*sqrt(c)*d - sqrt(a)*e)*atan((sqrt(2 + sqrt(2))*a^(1/8) - 2*c^(1/8)*x)/(sqrt(2 - sqrt(2))*a^(1/8))))/(8*a^(7/8)*c^(5/8)) + (sqrt(2 - sqrt(2))*((1 + sqrt(2))*sqrt(c)*d - sqrt(a)*e)*atan((sqrt(2 - sqrt(2))*a^(1/8) + 2*c^(1/8)*x)/(sqrt(2 + sqrt(2))*a^(1/8))))/(8*a^(7/8)*c^(5/8)) - (sqrt(2 + sqrt(2))*((1 - sqrt(2))*sqrt(c)*d - sqrt(a)*e)*atan((sqrt(2 + sqrt(2))*a^(1/8) + 2*c^(1/8)*x)/(sqrt(2 - sqrt(2))*a^(1/8))))/(8*a^(7/8)*c^(5/8)) + (((1 - sqrt(2))*sqrt(c)*d - sqrt(a)*e)*log(a^(1/4) - sqrt(2 - sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 - sqrt(2)))*a^(7/8)*c^(5/8)) - (((1 - sqrt(2))*sqrt(c)*d - sqrt(a)*e)*log(a^(1/4) + sqrt(2 - sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 - sqrt(2)))*a^(7/8)*c^(5/8)) - (((1 + sqrt(2))*sqrt(c)*d - sqrt(a)*e)*log(a^(1/4) - sqrt(2 + sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 + sqrt(2)))*a^(7/8)*c^(5/8)) + ((d + sqrt(2)*d - (sqrt(a)*e)/sqrt(c))*log(a^(1/4) + sqrt(2 + sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 + sqrt(2)))*a^(7/8)*c^(1/8)), -((sqrt(2 - sqrt(2))*((1 + sqrt(2))*sqrt(c)*d - sqrt(a)*e)*atan((sqrt(2 - sqrt(2))*a^(1/8) - 2*c^(1/8)*x)/(sqrt(2 + sqrt(2))*a^(1/8))))/(8*a^(7/8)*c^(5/8))) + (((1 - sqrt(2))*sqrt(c)*d - sqrt(a)*e)*atan((sqrt(2 + sqrt(2))*a^(1/8) - 2*c^(1/8)*x)/(sqrt(2 - sqrt(2))*a^(1/8))))/(4*sqrt(2*(2 - sqrt(2)))*a^(7/8)*c^(5/8)) + (sqrt(2 - sqrt(2))*((1 + sqrt(2))*sqrt(c)*d - sqrt(a)*e)*atan((sqrt(2 - sqrt(2))*a^(1/8) + 2*c^(1/8)*x)/(sqrt(2 + sqrt(2))*a^(1/8))))/(8*a^(7/8)*c^(5/8)) - (((1 - sqrt(2))*sqrt(c)*d - sqrt(a)*e)*atan((sqrt(2 + sqrt(2))*a^(1/8) + 2*c^(1/8)*x)/(sqrt(2 - sqrt(2))*a^(1/8))))/(4*sqrt(2*(2 - sqrt(2)))*a^(7/8)*c^(5/8)) + (((1 - sqrt(2))*sqrt(c)*d - sqrt(a)*e)*log(a^(1/4) - sqrt(2 - sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 - sqrt(2)))*a^(7/8)*c^(5/8)) - (((1 - sqrt(2))*sqrt(c)*d - sqrt(a)*e)*log(a^(1/4) + sqrt(2 - sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 - sqrt(2)))*a^(7/8)*c^(5/8)) - (((1 + sqrt(2))*sqrt(c)*d - sqrt(a)*e)*log(a^(1/4) - sqrt(2 + sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 + sqrt(2)))*a^(7/8)*c^(5/8)) + ((d + sqrt(2)*d - (sqrt(a)*e)/sqrt(c))*log(a^(1/4) + sqrt(2 + sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 + sqrt(2)))*a^(7/8)*c^(1/8)))]
    @test_int [(d + e*x^4)/(a - c*x^8), x, 13, ((sqrt(c)*d + sqrt(a)*e)*atan((c^(1/8)*x)/a^(1/8)))/(4*a^(7/8)*c^(5/8)) - ((d - (sqrt(a)*e)/sqrt(c))*atan(1 - (sqrt(2)*c^(1/8)*x)/a^(1/8)))/(4*sqrt(2)*a^(7/8)*c^(1/8)) + ((d - (sqrt(a)*e)/sqrt(c))*atan(1 + (sqrt(2)*c^(1/8)*x)/a^(1/8)))/(4*sqrt(2)*a^(7/8)*c^(1/8)) + ((sqrt(c)*d + sqrt(a)*e)*atanh((c^(1/8)*x)/a^(1/8)))/(4*a^(7/8)*c^(5/8)) - ((d - (sqrt(a)*e)/sqrt(c))*log(a^(1/4) - sqrt(2)*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2)*a^(7/8)*c^(1/8)) + ((d - (sqrt(a)*e)/sqrt(c))*log(a^(1/4) + sqrt(2)*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2)*a^(7/8)*c^(1/8))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^4)^q*(a+b*x^4+c*x^8)^p*with*c*d^2-a*e^2=0=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^4)^q*(a+b*x^4+c*x^8)^p*with*c*d^2-a*e^2=0=#

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

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

    @test_int [(d + e*x^4)/(d^2 + b*x^4 + e^2*x^8), x, 19, -(atan((sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e)) - 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e)))) - atan((sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e)) - 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e))) + atan((sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e)) + 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e))) + atan((sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e)) + 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e))) - log(sqrt(d) - sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e))) + log(sqrt(d) + sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(-b + 2*d*e))) - log(sqrt(d) - sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e))) + log(sqrt(d) + sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(-b + 2*d*e)))]
    @test_int [(d + e*x^4)/(d^2 + f*x^4 + e^2*x^8), x, 19, -(atan((sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f)) - 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f)))) - atan((sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f)) - 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f))) + atan((sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f)) + 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f))) + atan((sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f)) + 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f))) - log(sqrt(d) - sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f))) + log(sqrt(d) + sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e - f))) - log(sqrt(d) - sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f))) + log(sqrt(d) + sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e - f)))]

    @test_int [(d + e*x^4)/(d^2 - b*x^4 + e^2*x^8), x, 7, -((sqrt(e)*atan((sqrt(2)*sqrt(e)*x)/sqrt(sqrt(b - 2*d*e) - sqrt(b + 2*d*e))))/(sqrt(2)*sqrt(b - 2*d*e)*sqrt(sqrt(b - 2*d*e) - sqrt(b + 2*d*e)))) - (sqrt(e)*atan((sqrt(2)*sqrt(e)*x)/sqrt(sqrt(b - 2*d*e) + sqrt(b + 2*d*e))))/(sqrt(2)*sqrt(b - 2*d*e)*sqrt(sqrt(b - 2*d*e) + sqrt(b + 2*d*e))) - (sqrt(e)*atanh((sqrt(2)*sqrt(e)*x)/sqrt(sqrt(b - 2*d*e) - sqrt(b + 2*d*e))))/(sqrt(2)*sqrt(b - 2*d*e)*sqrt(sqrt(b - 2*d*e) - sqrt(b + 2*d*e))) - (sqrt(e)*atanh((sqrt(2)*sqrt(e)*x)/sqrt(sqrt(b - 2*d*e) + sqrt(b + 2*d*e))))/(sqrt(2)*sqrt(b - 2*d*e)*sqrt(sqrt(b - 2*d*e) + sqrt(b + 2*d*e)))]
    @test_int [(d + e*x^4)/(d^2 - f*x^4 + e^2*x^8), x, 19, -(atan((sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f)) - 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f)))) - atan((sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f)) - 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f))) + atan((sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f)) + 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f))) + atan((sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f)) + 2*sqrt(e)*x)/sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f)))/(4*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f))) - log(sqrt(d) - sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f))) + log(sqrt(d) + sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) - sqrt(2*d*e + f))) - log(sqrt(d) - sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f))) + log(sqrt(d) + sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f))*x + sqrt(e)*x^2)/(8*sqrt(d)*sqrt(2*sqrt(d)*sqrt(e) + sqrt(2*d*e + f)))]

    @test_int [(1 + x^4)/(1 + b*x^4 + x^8), x, 19, -(atan((sqrt(2 - sqrt(2 - b)) - 2*x)/sqrt(2 + sqrt(2 - b)))/(4*sqrt(2 + sqrt(2 - b)))) - atan((sqrt(2 + sqrt(2 - b)) - 2*x)/sqrt(2 - sqrt(2 - b)))/(4*sqrt(2 - sqrt(2 - b))) + atan((sqrt(2 - sqrt(2 - b)) + 2*x)/sqrt(2 + sqrt(2 - b)))/(4*sqrt(2 + sqrt(2 - b))) + atan((sqrt(2 + sqrt(2 - b)) + 2*x)/sqrt(2 - sqrt(2 - b)))/(4*sqrt(2 - sqrt(2 - b))) - log(1 - sqrt(2 - sqrt(2 - b))*x + x^2)/(8*sqrt(2 - sqrt(2 - b))) + log(1 + sqrt(2 - sqrt(2 - b))*x + x^2)/(8*sqrt(2 - sqrt(2 - b))) - log(1 - sqrt(2 + sqrt(2 - b))*x + x^2)/(8*sqrt(2 + sqrt(2 - b))) + log(1 + sqrt(2 + sqrt(2 - b))*x + x^2)/(8*sqrt(2 + sqrt(2 - b)))]

    @test_int [(1 + x^4)/(1 + 3*x^4 + x^8), x, 19, -(((3 + sqrt(5))^(1/4)*atan(1 - (2^(3/4)*x)/(3 - sqrt(5))^(1/4)))/(2*2^(3/4)*sqrt(5))) + ((3 + sqrt(5))^(1/4)*atan(1 + (2^(3/4)*x)/(3 - sqrt(5))^(1/4)))/(2*2^(3/4)*sqrt(5)) - ((3 - sqrt(5))^(1/4)*atan(1 - (2^(3/4)*x)/(3 + sqrt(5))^(1/4)))/(2*2^(3/4)*sqrt(5)) + ((3 - sqrt(5))^(1/4)*atan(1 + (2^(3/4)*x)/(3 + sqrt(5))^(1/4)))/(2*2^(3/4)*sqrt(5)) - ((3 + sqrt(5))^(1/4)*log(sqrt(2*(3 - sqrt(5))) - 2*(2*(3 - sqrt(5)))^(1/4)*x + 2*x^2))/(4*2^(3/4)*sqrt(5)) + ((3 + sqrt(5))^(1/4)*log(sqrt(2*(3 - sqrt(5))) + 2*(2*(3 - sqrt(5)))^(1/4)*x + 2*x^2))/(4*2^(3/4)*sqrt(5)) - ((3 - sqrt(5))^(1/4)*log(sqrt(2*(3 + sqrt(5))) - 2*(2*(3 + sqrt(5)))^(1/4)*x + 2*x^2))/(4*2^(3/4)*sqrt(5)) + ((3 - sqrt(5))^(1/4)*log(sqrt(2*(3 + sqrt(5))) + 2*(2*(3 + sqrt(5)))^(1/4)*x + 2*x^2))/(4*2^(3/4)*sqrt(5))]
    @test_int [(1 + x^4)/(1 + 2*x^4 + x^8), x, 10, -(atan(1 - sqrt(2)*x)/(2*sqrt(2))) + atan(1 + sqrt(2)*x)/(2*sqrt(2)) - log(1 - sqrt(2)*x + x^2)/(4*sqrt(2)) + log(1 + sqrt(2)*x + x^2)/(4*sqrt(2))]
    @test_int [(1 + x^4)/(1 + 1*x^4 + x^8), x, 19, -(atan((1 - 2*x)/sqrt(3))/(4*sqrt(3))) - (1/4)*atan(sqrt(3) - 2*x) + atan((1 + 2*x)/sqrt(3))/(4*sqrt(3)) + (1/4)*atan(sqrt(3) + 2*x) - (1/8)*log(1 - x + x^2) + (1/8)*log(1 + x + x^2) - log(1 - sqrt(3)*x + x^2)/(8*sqrt(3)) + log(1 + sqrt(3)*x + x^2)/(8*sqrt(3))]
    @test_int [(1 + x^4)/(1 + 0*x^4 + x^8), x, 19, (-(1/4))*sqrt((1/2)*(2 - sqrt(2)))*atan((sqrt(2 - sqrt(2)) - 2*x)/sqrt(2 + sqrt(2))) - (1/4)*sqrt((1/2)*(2 + sqrt(2)))*atan((sqrt(2 + sqrt(2)) - 2*x)/sqrt(2 - sqrt(2))) + (1/4)*sqrt((1/2)*(2 - sqrt(2)))*atan((sqrt(2 - sqrt(2)) + 2*x)/sqrt(2 + sqrt(2))) + (1/4)*sqrt((1/2)*(2 + sqrt(2)))*atan((sqrt(2 + sqrt(2)) + 2*x)/sqrt(2 - sqrt(2))) - log(1 - sqrt(2 - sqrt(2))*x + x^2)/(8*sqrt(2 - sqrt(2))) + log(1 + sqrt(2 - sqrt(2))*x + x^2)/(8*sqrt(2 - sqrt(2))) - log(1 - sqrt(2 + sqrt(2))*x + x^2)/(8*sqrt(2 + sqrt(2))) + log(1 + sqrt(2 + sqrt(2))*x + x^2)/(8*sqrt(2 + sqrt(2)))]
    @test_int [(1 + x^4)/(1 - 1*x^4 + x^8), x, 19, (-(1/4))*sqrt(2 - sqrt(3))*atan((sqrt(2 - sqrt(3)) - 2*x)/sqrt(2 + sqrt(3))) - (1/4)*sqrt(2 + sqrt(3))*atan((sqrt(2 + sqrt(3)) - 2*x)/sqrt(2 - sqrt(3))) + (1/4)*sqrt(2 - sqrt(3))*atan((sqrt(2 - sqrt(3)) + 2*x)/sqrt(2 + sqrt(3))) + (1/4)*sqrt(2 + sqrt(3))*atan((sqrt(2 + sqrt(3)) + 2*x)/sqrt(2 - sqrt(3))) - log(1 - sqrt(2 - sqrt(3))*x + x^2)/(8*sqrt(2 - sqrt(3))) + log(1 + sqrt(2 - sqrt(3))*x + x^2)/(8*sqrt(2 - sqrt(3))) - log(1 - sqrt(2 + sqrt(3))*x + x^2)/(8*sqrt(2 + sqrt(3))) + log(1 + sqrt(2 + sqrt(3))*x + x^2)/(8*sqrt(2 + sqrt(3)))]
    @test_int [(1 + x^4)/(1 - 2*x^4 + x^8), x, 5, x/(2*(1 - x^4)) + atan(x)/4 + atanh(x)/4]
    @test_int [(1 + x^4)/(1 - 3*x^4 + x^8), x, 7, atan(sqrt(2/(-1 + sqrt(5)))*x)/sqrt(2*(-1 + sqrt(5))) - atan(sqrt(2/(1 + sqrt(5)))*x)/sqrt(2*(1 + sqrt(5))) + atanh(sqrt(2/(-1 + sqrt(5)))*x)/sqrt(2*(-1 + sqrt(5))) - atanh(sqrt(2/(1 + sqrt(5)))*x)/sqrt(2*(1 + sqrt(5)))]
    @test_int [(1 + x^4)/(1 - 4*x^4 + x^8), x, 7, atan((2^(1/4)*x)/sqrt(-1 + sqrt(3)))/(2*2^(1/4)*sqrt(-1 + sqrt(3))) - atan((2^(1/4)*x)/sqrt(1 + sqrt(3)))/(2*2^(1/4)*sqrt(1 + sqrt(3))) + atanh((2^(1/4)*x)/sqrt(-1 + sqrt(3)))/(2*2^(1/4)*sqrt(-1 + sqrt(3))) - atanh((2^(1/4)*x)/sqrt(1 + sqrt(3)))/(2*2^(1/4)*sqrt(1 + sqrt(3)))]
    @test_int [(1 + x^4)/(1 - 5*x^4 + x^8), x, 7, atan(sqrt(2/(-sqrt(3) + sqrt(7)))*x)/sqrt(6*(-sqrt(3) + sqrt(7))) - atan(sqrt(2/(sqrt(3) + sqrt(7)))*x)/sqrt(6*(sqrt(3) + sqrt(7))) + atanh(sqrt(2/(-sqrt(3) + sqrt(7)))*x)/sqrt(6*(-sqrt(3) + sqrt(7))) - atanh(sqrt(2/(sqrt(3) + sqrt(7)))*x)/sqrt(6*(sqrt(3) + sqrt(7)))]
    @test_int [(1 + x^4)/(1 - 6*x^4 + x^8), x, 7, atan(x/sqrt(-1 + sqrt(2)))/(4*sqrt(-1 + sqrt(2))) - atan(x/sqrt(1 + sqrt(2)))/(4*sqrt(1 + sqrt(2))) + atanh(x/sqrt(-1 + sqrt(2)))/(4*sqrt(-1 + sqrt(2))) - atanh(x/sqrt(1 + sqrt(2)))/(4*sqrt(1 + sqrt(2)))]

    @test_int [(1 - x^4)/(1 + b*x^4 + x^8), x, 19, -((sqrt(2 + b)*atan((sqrt(2 - sqrt(2 - b)) - 2*x)/sqrt(2 + sqrt(2 - b))))/(4*sqrt(2 - sqrt(2 - b))*sqrt(2 - b))) + (sqrt(2 + b)*atan((sqrt(2 + sqrt(2 - b)) - 2*x)/sqrt(2 - sqrt(2 - b))))/(4*sqrt(2 + sqrt(2 - b))*sqrt(2 - b)) + (sqrt(2 + b)*atan((sqrt(2 - sqrt(2 - b)) + 2*x)/sqrt(2 + sqrt(2 - b))))/(4*sqrt(2 - sqrt(2 - b))*sqrt(2 - b)) - (sqrt(2 + b)*atan((sqrt(2 + sqrt(2 - b)) + 2*x)/sqrt(2 - sqrt(2 - b))))/(4*sqrt(2 + sqrt(2 - b))*sqrt(2 - b)) + (sqrt(2 - sqrt(2 - b))*log(1 - sqrt(2 - sqrt(2 - b))*x + x^2))/(8*sqrt(2 - b)) - (sqrt(2 - sqrt(2 - b))*log(1 + sqrt(2 - sqrt(2 - b))*x + x^2))/(8*sqrt(2 - b)) - (sqrt(2 + sqrt(2 - b))*log(1 - sqrt(2 + sqrt(2 - b))*x + x^2))/(8*sqrt(2 - b)) + (sqrt(2 + sqrt(2 - b))*log(1 + sqrt(2 + sqrt(2 - b))*x + x^2))/(8*sqrt(2 - b))]

    @test_int [(1 - x^4)/(1 + 3*x^4 + x^8), x, 19, -(((3 + sqrt(5))^(1/4)*atan(1 - (2^(3/4)*x)/(3 - sqrt(5))^(1/4)))/(2*2^(3/4))) + ((3 + sqrt(5))^(1/4)*atan(1 + (2^(3/4)*x)/(3 - sqrt(5))^(1/4)))/(2*2^(3/4)) + ((3 - sqrt(5))^(1/4)*atan(1 - (2^(3/4)*x)/(3 + sqrt(5))^(1/4)))/(2*2^(3/4)) - ((3 - sqrt(5))^(1/4)*atan(1 + (2^(3/4)*x)/(3 + sqrt(5))^(1/4)))/(2*2^(3/4)) - ((3 + sqrt(5))^(1/4)*log(sqrt(2*(3 - sqrt(5))) - 2*(2*(3 - sqrt(5)))^(1/4)*x + 2*x^2))/(4*2^(3/4)) + ((3 + sqrt(5))^(1/4)*log(sqrt(2*(3 - sqrt(5))) + 2*(2*(3 - sqrt(5)))^(1/4)*x + 2*x^2))/(4*2^(3/4)) + ((3 - sqrt(5))^(1/4)*log(sqrt(2*(3 + sqrt(5))) - 2*(2*(3 + sqrt(5)))^(1/4)*x + 2*x^2))/(4*2^(3/4)) - ((3 - sqrt(5))^(1/4)*log(sqrt(2*(3 + sqrt(5))) + 2*(2*(3 + sqrt(5)))^(1/4)*x + 2*x^2))/(4*2^(3/4))]
    @test_int [(1 - x^4)/(1 + 2*x^4 + x^8), x, 11, x/(2*(1 + x^4)) - atan(1 - sqrt(2)*x)/(4*sqrt(2)) + atan(1 + sqrt(2)*x)/(4*sqrt(2)) - log(1 - sqrt(2)*x + x^2)/(8*sqrt(2)) + log(1 + sqrt(2)*x + x^2)/(8*sqrt(2))]
    @test_int [(1 - x^4)/(1 + 1*x^4 + x^8), x, 19, (-(1/4))*sqrt(3)*atan((1 - 2*x)/sqrt(3)) + (1/4)*atan(sqrt(3) - 2*x) + (1/4)*sqrt(3)*atan((1 + 2*x)/sqrt(3)) - (1/4)*atan(sqrt(3) + 2*x) + (1/8)*log(1 - x + x^2) - (1/8)*log(1 + x + x^2) - (1/8)*sqrt(3)*log(1 - sqrt(3)*x + x^2) + (1/8)*sqrt(3)*log(1 + sqrt(3)*x + x^2)]
    @test_int [(1 - x^4)/(1 + 0*x^4 + x^8), x, 19, -(atan((sqrt(2 - sqrt(2)) - 2*x)/sqrt(2 + sqrt(2)))/(4*sqrt(2 - sqrt(2)))) + atan((sqrt(2 + sqrt(2)) - 2*x)/sqrt(2 - sqrt(2)))/(4*sqrt(2 + sqrt(2))) + atan((sqrt(2 - sqrt(2)) + 2*x)/sqrt(2 + sqrt(2)))/(4*sqrt(2 - sqrt(2))) - atan((sqrt(2 + sqrt(2)) + 2*x)/sqrt(2 - sqrt(2)))/(4*sqrt(2 + sqrt(2))) + (1/8)*sqrt((1/2)*(2 - sqrt(2)))*log(1 - sqrt(2 - sqrt(2))*x + x^2) - (1/8)*sqrt((1/2)*(2 - sqrt(2)))*log(1 + sqrt(2 - sqrt(2))*x + x^2) - (1/8)*sqrt((1/2)*(2 + sqrt(2)))*log(1 - sqrt(2 + sqrt(2))*x + x^2) + (1/8)*sqrt((1/2)*(2 + sqrt(2)))*log(1 + sqrt(2 + sqrt(2))*x + x^2)]
    @test_int [(1 - x^4)/(1 - 1*x^4 + x^8), x, 19, -(atan((sqrt(2 - sqrt(3)) - 2*x)/sqrt(2 + sqrt(3)))/(4*sqrt(3*(2 - sqrt(3))))) + atan((sqrt(2 + sqrt(3)) - 2*x)/sqrt(2 - sqrt(3)))/(4*sqrt(3*(2 + sqrt(3)))) + atan((sqrt(2 - sqrt(3)) + 2*x)/sqrt(2 + sqrt(3)))/(4*sqrt(3*(2 - sqrt(3)))) - atan((sqrt(2 + sqrt(3)) + 2*x)/sqrt(2 - sqrt(3)))/(4*sqrt(3*(2 + sqrt(3)))) + (1/8)*sqrt((1/3)*(2 - sqrt(3)))*log(1 - sqrt(2 - sqrt(3))*x + x^2) - (1/8)*sqrt((1/3)*(2 - sqrt(3)))*log(1 + sqrt(2 - sqrt(3))*x + x^2) - (1/8)*sqrt((1/3)*(2 + sqrt(3)))*log(1 - sqrt(2 + sqrt(3))*x + x^2) + (1/8)*sqrt((1/3)*(2 + sqrt(3)))*log(1 + sqrt(2 + sqrt(3))*x + x^2)]
    @test_int [(1 - x^4)/(1 - 2*x^4 + x^8), x, 5, atan(x)/2 + atanh(x)/2]
    @test_int [(1 - x^4)/(1 - 3*x^4 + x^8), x, 7, atan(sqrt(2/(-1 + sqrt(5)))*x)/sqrt(10*(-1 + sqrt(5))) + atan(sqrt(2/(1 + sqrt(5)))*x)/sqrt(10*(1 + sqrt(5))) + atanh(sqrt(2/(-1 + sqrt(5)))*x)/sqrt(10*(-1 + sqrt(5))) + atanh(sqrt(2/(1 + sqrt(5)))*x)/sqrt(10*(1 + sqrt(5)))]
    @test_int [(1 - x^4)/(1 - 4*x^4 + x^8), x, 7, atan((2^(1/4)*x)/sqrt(-1 + sqrt(3)))/(2*2^(1/4)*sqrt(3*(-1 + sqrt(3)))) + atan((2^(1/4)*x)/sqrt(1 + sqrt(3)))/(2*2^(1/4)*sqrt(3*(1 + sqrt(3)))) + atanh((2^(1/4)*x)/sqrt(-1 + sqrt(3)))/(2*2^(1/4)*sqrt(3*(-1 + sqrt(3)))) + atanh((2^(1/4)*x)/sqrt(1 + sqrt(3)))/(2*2^(1/4)*sqrt(3*(1 + sqrt(3))))]
    @test_int [(1 - x^4)/(1 - 5*x^4 + x^8), x, 7, atan(sqrt(2/(-sqrt(3) + sqrt(7)))*x)/sqrt(14*(-sqrt(3) + sqrt(7))) + atan(sqrt(2/(sqrt(3) + sqrt(7)))*x)/sqrt(14*(sqrt(3) + sqrt(7))) + atanh(sqrt(2/(-sqrt(3) + sqrt(7)))*x)/sqrt(14*(-sqrt(3) + sqrt(7))) + atanh(sqrt(2/(sqrt(3) + sqrt(7)))*x)/sqrt(14*(sqrt(3) + sqrt(7)))]
    @test_int [(1 - x^4)/(1 - 6*x^4 + x^8), x, 7, atan(x/sqrt(-1 + sqrt(2)))/(4*sqrt(2*(-1 + sqrt(2)))) + atan(x/sqrt(1 + sqrt(2)))/(4*sqrt(2*(1 + sqrt(2)))) + atanh(x/sqrt(-1 + sqrt(2)))/(4*sqrt(2*(-1 + sqrt(2)))) + atanh(x/sqrt(1 + sqrt(2)))/(4*sqrt(2*(1 + sqrt(2))))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^4)^q*(a+b*x^4+c*x^8)^p=#

    @test_int [(-1 + sqrt(3) + 2*x^4)/(1 - x^4 + x^8), x, 9, -(atan((sqrt(2 + sqrt(3)) - 2*x)/sqrt(2 - sqrt(3)))/sqrt(2)) + atan((sqrt(2 + sqrt(3)) + 2*x)/sqrt(2 - sqrt(3)))/sqrt(2) - log(1 - sqrt(2 - sqrt(3))*x + x^2)/(2*sqrt(2)) + log(1 + sqrt(2 - sqrt(3))*x + x^2)/(2*sqrt(2))]
    @test_int [(1 + (1 + sqrt(3))*x^4)/(1 - x^4 + x^8), x, 9, (-(1/2))*sqrt(2 + sqrt(3))*atan((sqrt(2 + sqrt(3)) - 2*x)/sqrt(2 - sqrt(3))) + (1/2)*sqrt(2 + sqrt(3))*atan((sqrt(2 + sqrt(3)) + 2*x)/sqrt(2 - sqrt(3))) - (1/4)*sqrt(2 + sqrt(3))*log(1 - sqrt(2 - sqrt(3))*x + x^2) + (1/4)*sqrt(2 + sqrt(3))*log(1 + sqrt(2 - sqrt(3))*x + x^2)]
    @test_int [(3 - 2*sqrt(3) + (-3 + sqrt(3))*x^4)/(1 - x^4 + x^8), x, 9, (1/2)*sqrt(3*(2 - sqrt(3)))*atan((sqrt(2 + sqrt(3)) - 2*x)/sqrt(2 - sqrt(3))) - (1/2)*sqrt(3*(2 - sqrt(3)))*atan((sqrt(2 + sqrt(3)) + 2*x)/sqrt(2 - sqrt(3))) + (1/4)*sqrt(3*(2 - sqrt(3)))*log(1 - sqrt(2 - sqrt(3))*x + x^2) - (1/4)*sqrt(3*(2 - sqrt(3)))*log(1 + sqrt(2 - sqrt(3))*x + x^2)]

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

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^n)^q*(a+b*x^n+c*x^(2*n))^p*with*n<0=#

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

    @test_int [(d + e/x)/(a/x^2 + c), x, 5, (d*x)/c - (sqrt(a)*d*atan((sqrt(c)*x)/sqrt(a)))/c^(3/2) + (e*log(a + c*x^2))/(2*c)]

    @test_int [(d + e/x)/(a/x^2 + b/x + c), x, 6, (d*x)/c - ((b^2*d - 2*a*c*d - b*c*e)*atanh((b + 2*c*x)/sqrt(b^2 - 4*a*c)))/(c^2*sqrt(b^2 - 4*a*c)) - ((b*d - c*e)*log(a + b*x + c*x^2))/(2*c^2)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e/x^2)*(a/x^4+b/x^2+c)^p=#

    @test_int [(d + e/x^2)/(a/x^4 + c), x, 11, (d*x)/c + ((sqrt(a)*d - sqrt(c)*e)*atan(1 - (sqrt(2)*c^(1/4)*x)/a^(1/4)))/(2*sqrt(2)*a^(1/4)*c^(5/4)) - ((sqrt(a)*d - sqrt(c)*e)*atan(1 + (sqrt(2)*c^(1/4)*x)/a^(1/4)))/(2*sqrt(2)*a^(1/4)*c^(5/4)) + ((sqrt(a)*d + sqrt(c)*e)*log(sqrt(a) - sqrt(2)*a^(1/4)*c^(1/4)*x + sqrt(c)*x^2))/(4*sqrt(2)*a^(1/4)*c^(5/4)) - ((sqrt(a)*d + sqrt(c)*e)*log(sqrt(a) + sqrt(2)*a^(1/4)*c^(1/4)*x + sqrt(c)*x^2))/(4*sqrt(2)*a^(1/4)*c^(5/4))]

    @test_int [(d + e/x^2)/(a/x^4 + b/x^2 + c), x, 5, (d*x)/c - ((b*d - c*e - (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*atan((sqrt(2)*sqrt(c)*x)/sqrt(b - sqrt(b^2 - 4*a*c))))/(sqrt(2)*c^(3/2)*sqrt(b - sqrt(b^2 - 4*a*c))) - ((b*d - c*e + (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*atan((sqrt(2)*sqrt(c)*x)/sqrt(b + sqrt(b^2 - 4*a*c))))/(sqrt(2)*c^(3/2)*sqrt(b + sqrt(b^2 - 4*a*c)))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e/x^3)*(a/x^6+b/x^3+c)^p=#

    @test_int [(d + e/x^3)/(a/x^6 + c), x, 14, (d*x)/c - (a^(1/6)*d*atan((c^(1/6)*x)/a^(1/6)))/(3*c^(7/6)) + ((sqrt(a)*d - sqrt(3)*sqrt(c)*e)*atan(sqrt(3) - (2*c^(1/6)*x)/a^(1/6)))/(6*a^(1/3)*c^(7/6)) - ((sqrt(a)*d + sqrt(3)*sqrt(c)*e)*atan(sqrt(3) + (2*c^(1/6)*x)/a^(1/6)))/(6*a^(1/3)*c^(7/6)) - (e*log(a^(1/3) + c^(1/3)*x^2))/(6*a^(1/3)*c^(2/3)) + ((sqrt(3)*sqrt(a)*d + sqrt(c)*e)*log(a^(1/3) - sqrt(3)*a^(1/6)*c^(1/6)*x + c^(1/3)*x^2))/(12*a^(1/3)*c^(7/6)) - ((sqrt(3)*sqrt(a)*d - sqrt(c)*e)*log(a^(1/3) + sqrt(3)*a^(1/6)*c^(1/6)*x + c^(1/3)*x^2))/(12*a^(1/3)*c^(7/6))]

    @test_int [(d + e/x^3)/(a/x^6 + b/x^3 + c), x, 15, (d*x)/c + ((b*d - c*e - (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*atan((1 - (2*2^(1/3)*c^(1/3)*x)/(b - sqrt(b^2 - 4*a*c))^(1/3))/sqrt(3)))/(2^(1/3)*sqrt(3)*c^(4/3)*(b - sqrt(b^2 - 4*a*c))^(2/3)) + ((b*d - c*e + (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*atan((1 - (2*2^(1/3)*c^(1/3)*x)/(b + sqrt(b^2 - 4*a*c))^(1/3))/sqrt(3)))/(2^(1/3)*sqrt(3)*c^(4/3)*(b + sqrt(b^2 - 4*a*c))^(2/3)) - ((b*d - c*e - (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*log((b - sqrt(b^2 - 4*a*c))^(1/3) + 2^(1/3)*c^(1/3)*x))/(3*2^(1/3)*c^(4/3)*(b - sqrt(b^2 - 4*a*c))^(2/3)) - ((b*d - c*e + (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*log((b + sqrt(b^2 - 4*a*c))^(1/3) + 2^(1/3)*c^(1/3)*x))/(3*2^(1/3)*c^(4/3)*(b + sqrt(b^2 - 4*a*c))^(2/3)) + ((b*d - c*e - (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*log((b - sqrt(b^2 - 4*a*c))^(2/3) - 2^(1/3)*c^(1/3)*(b - sqrt(b^2 - 4*a*c))^(1/3)*x + 2^(2/3)*c^(2/3)*x^2))/(6*2^(1/3)*c^(4/3)*(b - sqrt(b^2 - 4*a*c))^(2/3)) + ((b*d - c*e + (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*log((b + sqrt(b^2 - 4*a*c))^(2/3) - 2^(1/3)*c^(1/3)*(b + sqrt(b^2 - 4*a*c))^(1/3)*x + 2^(2/3)*c^(2/3)*x^2))/(6*2^(1/3)*c^(4/3)*(b + sqrt(b^2 - 4*a*c))^(2/3))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e/x^4)*(a/x^8+b/x^4+c)^p=#

    @test_int [(d + e/x^4)/(a/x^8 + c), x, 21, (d*x)/c + (sqrt(2 - sqrt(2))*((1 + sqrt(2))*sqrt(a)*d + sqrt(c)*e)*atan((sqrt(2 - sqrt(2))*a^(1/8) - 2*c^(1/8)*x)/(sqrt(2 + sqrt(2))*a^(1/8))))/(8*a^(3/8)*c^(9/8)) - (sqrt(2 + sqrt(2))*(sqrt(a)*(d - sqrt(2)*d) + sqrt(c)*e)*atan((sqrt(2 + sqrt(2))*a^(1/8) - 2*c^(1/8)*x)/(sqrt(2 - sqrt(2))*a^(1/8))))/(8*a^(3/8)*c^(9/8)) - (sqrt(2 - sqrt(2))*((1 + sqrt(2))*sqrt(a)*d + sqrt(c)*e)*atan((sqrt(2 - sqrt(2))*a^(1/8) + 2*c^(1/8)*x)/(sqrt(2 + sqrt(2))*a^(1/8))))/(8*a^(3/8)*c^(9/8)) + (sqrt(2 + sqrt(2))*(sqrt(a)*(d - sqrt(2)*d) + sqrt(c)*e)*atan((sqrt(2 + sqrt(2))*a^(1/8) + 2*c^(1/8)*x)/(sqrt(2 - sqrt(2))*a^(1/8))))/(8*a^(3/8)*c^(9/8)) - ((sqrt(a)*(d - sqrt(2)*d) + sqrt(c)*e)*log(a^(1/4) - sqrt(2 - sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 - sqrt(2)))*a^(3/8)*c^(9/8)) + ((sqrt(a)*(d - sqrt(2)*d) + sqrt(c)*e)*log(a^(1/4) + sqrt(2 - sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 - sqrt(2)))*a^(3/8)*c^(9/8)) + (((1 + sqrt(2))*sqrt(a)*d + sqrt(c)*e)*log(a^(1/4) - sqrt(2 + sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 + sqrt(2)))*a^(3/8)*c^(9/8)) - (((1 + sqrt(2))*sqrt(a)*d + sqrt(c)*e)*log(a^(1/4) + sqrt(2 + sqrt(2))*a^(1/8)*c^(1/8)*x + c^(1/4)*x^2))/(8*sqrt(2*(2 + sqrt(2)))*a^(3/8)*c^(9/8))]

    @test_int [(d + e/x^4)/(a/x^8 + b/x^4 + c), x, 9, (d*x)/c + ((b*d - c*e + (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*atan((2^(1/4)*c^(1/4)*x)/(-b - sqrt(b^2 - 4*a*c))^(1/4)))/(2*2^(1/4)*c^(5/4)*(-b - sqrt(b^2 - 4*a*c))^(3/4)) + ((b*d - c*e - (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*atan((2^(1/4)*c^(1/4)*x)/(-b + sqrt(b^2 - 4*a*c))^(1/4)))/(2*2^(1/4)*c^(5/4)*(-b + sqrt(b^2 - 4*a*c))^(3/4)) + ((b*d - c*e + (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*atanh((2^(1/4)*c^(1/4)*x)/(-b - sqrt(b^2 - 4*a*c))^(1/4)))/(2*2^(1/4)*c^(5/4)*(-b - sqrt(b^2 - 4*a*c))^(3/4)) + ((b*d - c*e - (b^2*d - 2*a*c*d - b*c*e)/sqrt(b^2 - 4*a*c))*atanh((2^(1/4)*c^(1/4)*x)/(-b + sqrt(b^2 - 4*a*c))^(1/4)))/(2*2^(1/4)*c^(5/4)*(-b + sqrt(b^2 - 4*a*c))^(3/4))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^n)^q*(a+b*x^n+c*x^(2*n))^p*with*b=0=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^n)^q*(a+c*x^(2*n))^p=#

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

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

    @test_int [(d + e*x^n)^3/(a + c*x^(2*n)), x, 5, (3*d*e^2*x)/c + (e^3*x^(1 + n))/(c*(1 + n)) + (d*(c*d^2 - 3*a*e^2)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*c) + (e*(3*c*d^2 - a*e^2)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*c*(1 + n))]
    @test_int [(d + e*x^n)^2/(a + c*x^(2*n)), x, 5, (e^2*x)/c + ((c*d^2 - a*e^2)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*c) + (2*d*e*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*(1 + n))]
    @test_int [(d + e*x^n)^1/(a + c*x^(2*n)), x, 3, (d*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/a + (e*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*(1 + n))]
    @test_int [1/((d + e*x^n)^1*(a + c*x^(2*n))), x, 6, (c*d*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)) + (e^2*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 + a*e^2)) - (c*e*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)*(1 + n))]
    @test_int [1/((d + e*x^n)^2*(a + c*x^(2*n))), x, 7, (c*(c*d^2 - a*e^2)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^2) + (2*c*e^2*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(c*d^2 + a*e^2)^2 - (2*c^2*d*e*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^2*(1 + n)) + (e^2*x*HypergeometricFunctions._₂F₁(2, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d^2*(c*d^2 + a*e^2))]

    @test_int [(d + e*x^n)^1/(a - c*x^(2*n)), x, 3, (d*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), (c*x^(2*n))/a))/a + (e*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), (c*x^(2*n))/a))/(a*(1 + n))]

    @test_int [(d + e*x^n)^3/(a + c*x^(2*n))^2, x, 9, (x*(d*(c*d^2 - 3*a*e^2) + e*(3*c*d^2 - a*e^2)*x^n))/(2*a*c*n*(a + c*x^(2*n))) + (3*d*e^2*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*c) - (d*(c*d^2 - 3*a*e^2)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*c*n) + (e^3*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*c*(1 + n)) - (e*(3*c*d^2 - a*e^2)*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*c*n*(1 + n))]
    @test_int [(d + e*x^n)^2/(a + c*x^(2*n))^2, x, 7, (x*(c*d^2 - a*e^2 + 2*c*d*e*x^n))/(2*a*c*n*(a + c*x^(2*n))) + (e^2*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*c) - ((c*d^2 - a*e^2)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*c*n) - (d*e*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a^2*n*(1 + n))]
    @test_int [(d + e*x^n)^1/(a + c*x^(2*n))^2, x, 4, (x*(d + e*x^n))/(2*a*n*(a + c*x^(2*n))) - (d*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*n) - (e*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*n*(1 + n))]
    @test_int [1/((d + e*x^n)^1*(a + c*x^(2*n))^2), x, 10, (c*x*(d - e*x^n))/(2*a*(c*d^2 + a*e^2)*n*(a + c*x^(2*n))) + (c*d*e^2*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^2) - (c*d*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*(c*d^2 + a*e^2)*n) + (e^4*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 + a*e^2)^2) - (c*e^3*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^2*(1 + n)) + (c*e*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*(c*d^2 + a*e^2)*n*(1 + n))]
    @test_int [1/((d + e*x^n)^2*(a + c*x^(2*n))^2), x, 11, (c*x*(c*d^2 - a*e^2 - 2*c*d*e*x^n))/(2*a*(c*d^2 + a*e^2)^2*n*(a + c*x^(2*n))) + (c*e^2*(3*c*d^2 - a*e^2)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^3) - (c*(c*d^2 - a*e^2)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*(c*d^2 + a*e^2)^2*n) + (4*c*e^4*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(c*d^2 + a*e^2)^3 - (4*c^2*d*e^3*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^3*(1 + n)) + (c^2*d*e*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a^2*(c*d^2 + a*e^2)^2*n*(1 + n)) + (e^4*x*HypergeometricFunctions._₂F₁(2, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d^2*(c*d^2 + a*e^2)^2)]

    @test_int [(d + e*x^n)^3/(a + c*x^(2*n))^3, x, 11, (x*(d*(c*d^2 - 3*a*e^2) + e*(3*c*d^2 - a*e^2)*x^n))/(4*a*c*n*(a + c*x^(2*n))^2) + (e^2*x*(3*d + e*x^n))/(2*a*c*n*(a + c*x^(2*n))) - (x*(d*(c*d^2 - 3*a*e^2)*(1 - 4*n) + e*(3*c*d^2 - a*e^2)*(1 - 3*n)*x^n))/(8*a^2*c*n^2*(a + c*x^(2*n))) + (d*(c*d^2 - 3*a*e^2)*(1 - 4*n)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(8*a^3*c*n^2) - (3*d*e^2*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*c*n) + (e*(3*c*d^2 - a*e^2)*(1 - 3*n)*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(8*a^3*c*n^2*(1 + n)) - (e^3*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*c*n*(1 + n))]
    @test_int [(d + e*x^n)^2/(a + c*x^(2*n))^3, x, 8, (x*(c*d^2 - a*e^2 + 2*c*d*e*x^n))/(4*a*c*n*(a + c*x^(2*n))^2) - (x*((c*d^2 - a*e^2)*(1 - 4*n) + 2*c*d*e*(1 - 3*n)*x^n))/(8*a^2*c*n^2*(a + c*x^(2*n))) + ((c*d^2 - a*e^2)*(1 - 4*n)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(8*a^3*c*n^2) + (d*e*(1 - 3*n)*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(4*a^3*n^2*(1 + n)) + (e^2*x*HypergeometricFunctions._₂F₁(2, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a^2*c)]
    @test_int [(d + e*x^n)^1/(a + c*x^(2*n))^3, x, 5, (x*(d + e*x^n))/(4*a*n*(a + c*x^(2*n))^2) - (x*(d*(1 - 4*n) + e*(1 - 3*n)*x^n))/(8*a^2*n^2*(a + c*x^(2*n))) + (d*(1 - 4*n)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(8*a^3*n^2) + (e*(1 - 3*n)*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(8*a^3*n^2*(1 + n))]
    @test_int [1/((d + e*x^n)^1*(a + c*x^(2*n))^3), x, 15, (c*x*(d - e*x^n))/(4*a*(c*d^2 + a*e^2)*n*(a + c*x^(2*n))^2) + (c*e^2*x*(d - e*x^n))/(2*a*(c*d^2 + a*e^2)^2*n*(a + c*x^(2*n))) - (c*x*(d*(1 - 4*n) - e*(1 - 3*n)*x^n))/(8*a^2*(c*d^2 + a*e^2)*n^2*(a + c*x^(2*n))) + (c*d*e^4*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^3) + (c*d*(1 - 4*n)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(8*a^3*(c*d^2 + a*e^2)*n^2) - (c*d*e^2*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*(c*d^2 + a*e^2)^2*n) + (e^6*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 + a*e^2)^3) - (c*e^5*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^3*(1 + n)) - (c*e*(1 - 3*n)*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(8*a^3*(c*d^2 + a*e^2)*n^2*(1 + n)) + (c*e^3*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*(c*d^2 + a*e^2)^2*n*(1 + n))]
    @test_int [1/((d + e*x^n)^2*(a + c*x^(2*n))^3), x, 16, (c*x*(c*d^2 - a*e^2 - 2*c*d*e*x^n))/(4*a*(c*d^2 + a*e^2)^2*n*(a + c*x^(2*n))^2) + (c*e^2*x*(3*c*d^2 - a*e^2 - 4*c*d*e*x^n))/(2*a*(c*d^2 + a*e^2)^3*n*(a + c*x^(2*n))) - (c*x*((c*d^2 - a*e^2)*(1 - 4*n) - 2*c*d*e*(1 - 3*n)*x^n))/(8*a^2*(c*d^2 + a*e^2)^2*n^2*(a + c*x^(2*n))) + (c*e^4*(5*c*d^2 - a*e^2)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^4) + (c*(c*d^2 - a*e^2)*(1 - 4*n)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(8*a^3*(c*d^2 + a*e^2)^2*n^2) - (c*e^2*(3*c*d^2 - a*e^2)*(1 - 2*n)*x*HypergeometricFunctions._₂F₁(1, 1/(2*n), (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(2*a^2*(c*d^2 + a*e^2)^3*n) + (6*c*e^6*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(c*d^2 + a*e^2)^4 - (6*c^2*d*e^5*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a*(c*d^2 + a*e^2)^4*(1 + n)) - (c^2*d*e*(1 - 3*n)*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(4*a^3*(c*d^2 + a*e^2)^2*n^2*(1 + n)) + (2*c^2*d*e^3*(1 - n)*x^(1 + n)*HypergeometricFunctions._₂F₁(1, (1 + n)/(2*n), (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/(a^2*(c*d^2 + a*e^2)^3*n*(1 + n)) + (e^6*x*HypergeometricFunctions._₂F₁(2, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d^2*(c*d^2 + a*e^2)^3)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^n)^q*(a+c*x^(2*n))^(p/2)=#

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

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

    @test_int [1/((d + e*x^n)*sqrt(a + c*x^(2*n))), x, 6, (x*sqrt(1 + (c*x^(2*n))/a)*AppellF1(1/(2*n), 1/2, 1, (1/2)*(2 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/(d*sqrt(a + c*x^(2*n))) - (e*x^(1 + n)*sqrt(1 + (c*x^(2*n))/a)*AppellF1((1 + n)/(2*n), 1/2, 1, (1/2)*(3 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/(d^2*(1 + n)*sqrt(a + c*x^(2*n)))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^n)^q*(a+c*x^(2*n))^p*with*p*symbolic=#

    @test_int [(d + e*x^n)^q*(a + c*x^(2*n))^p, x, 0, Unintegrable((d + e*x^n)^q*(a + c*x^(2*n))^p, x)]

    @test_int [(a + c*x^(2*n))^p*(d + e*x^n)^3, x, 10, (3*d*e^2*x^(1 + 2*n)*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁((1/2)*(2 + 1/n), -p, (1/2)*(4 + 1/n), -((c*x^(2*n))/a)))/((1 + (c*x^(2*n))/a)^p*(1 + 2*n)) + (e^3*x^(1 + 3*n)*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁((1/2)*(3 + 1/n), -p, (1/2)*(5 + 1/n), -((c*x^(2*n))/a)))/((1 + (c*x^(2*n))/a)^p*(1 + 3*n)) + (d^3*x*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁(1/(2*n), -p, (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(1 + (c*x^(2*n))/a)^p + (3*d^2*e*x^(1 + n)*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁((1 + n)/(2*n), -p, (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/((1 + (c*x^(2*n))/a)^p*(1 + n))]
    @test_int [(a + c*x^(2*n))^p*(d + e*x^n)^2, x, 8, (e^2*x^(1 + 2*n)*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁((1/2)*(2 + 1/n), -p, (1/2)*(4 + 1/n), -((c*x^(2*n))/a)))/((1 + (c*x^(2*n))/a)^p*(1 + 2*n)) + (d^2*x*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁(1/(2*n), -p, (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(1 + (c*x^(2*n))/a)^p + (2*d*e*x^(1 + n)*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁((1 + n)/(2*n), -p, (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/((1 + (c*x^(2*n))/a)^p*(1 + n))]
    @test_int [(a + c*x^(2*n))^p*(d + e*x^n)^1, x, 6, (d*x*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁(1/(2*n), -p, (1/2)*(2 + 1/n), -((c*x^(2*n))/a)))/(1 + (c*x^(2*n))/a)^p + (e*x^(1 + n)*(a + c*x^(2*n))^p*HypergeometricFunctions._₂F₁((1 + n)/(2*n), -p, (1/2)*(3 + 1/n), -((c*x^(2*n))/a)))/((1 + (c*x^(2*n))/a)^p*(1 + n))]
    @test_int [(a + c*x^(2*n))^p/(d + e*x^n)^1, x, 6, (x*(a + c*x^(2*n))^p*AppellF1(1/(2*n), -p, 1, (1/2)*(2 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*d) - (e*x^(1 + n)*(a + c*x^(2*n))^p*AppellF1((1 + n)/(2*n), -p, 1, (1/2)*(3 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*(d^2*(1 + n)))]
    @test_int [(a + c*x^(2*n))^p/(d + e*x^n)^2, x, 8, (e^2*x^(1 + 2*n)*(a + c*x^(2*n))^p*AppellF1((1/2)*(2 + 1/n), -p, 2, (1/2)*(4 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*(d^4*(1 + 2*n))) + (x*(a + c*x^(2*n))^p*AppellF1(1/(2*n), -p, 2, (1/2)*(2 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*d^2) - (2*e*x^(1 + n)*(a + c*x^(2*n))^p*AppellF1((1 + n)/(2*n), -p, 2, (1/2)*(3 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*(d^3*(1 + n)))]
    @test_int [(a + c*x^(2*n))^p/(d + e*x^n)^3, x, 10, (3*e^2*x^(1 + 2*n)*(a + c*x^(2*n))^p*AppellF1((1/2)*(2 + 1/n), -p, 3, (1/2)*(4 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*(d^5*(1 + 2*n))) - (e^3*x^(1 + 3*n)*(a + c*x^(2*n))^p*AppellF1((1/2)*(3 + 1/n), -p, 3, (1/2)*(5 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*(d^6*(1 + 3*n))) + (x*(a + c*x^(2*n))^p*AppellF1(1/(2*n), -p, 3, (1/2)*(2 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*d^3) - (3*e*x^(1 + n)*(a + c*x^(2*n))^p*AppellF1((1 + n)/(2*n), -p, 3, (1/2)*(3 + 1/n), -((c*x^(2*n))/a), (e^2*x^(2*n))/d^2))/((1 + (c*x^(2*n))/a)^p*(d^4*(1 + n)))]

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

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^n)^q*(a+b*x^n+c*x^(2*n))^p=#

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

    @test_int [(d + e*x^n)*(a + b*x^n + c*x^(2*n)), x, 2, a*d*x + ((b*d + a*e)*x^(1 + n))/(1 + n) + ((c*d + b*e)*x^(1 + 2*n))/(1 + 2*n) + (c*e*x^(1 + 3*n))/(1 + 3*n)]

    @test_int [(d + e*x^n)*(a + b*x^n + c*x^(2*n))^2, x, 2, a^2*d*x + (a*(2*b*d + a*e)*x^(1 + n))/(1 + n) + ((b^2*d + 2*a*c*d + 2*a*b*e)*x^(1 + 2*n))/(1 + 2*n) + ((2*b*c*d + b^2*e + 2*a*c*e)*x^(1 + 3*n))/(1 + 3*n) + (c*(c*d + 2*b*e)*x^(1 + 4*n))/(1 + 4*n) + (c^2*e*x^(1 + 5*n))/(1 + 5*n)]

    @test_int [(d + e*x^n)*(a + b*x^n + c*x^(2*n))^3, x, 2, a^3*d*x + (a^2*(3*b*d + a*e)*x^(1 + n))/(1 + n) + (3*a*(b^2*d + a*c*d + a*b*e)*x^(1 + 2*n))/(1 + 2*n) + ((b^3*d + 6*a*b*c*d + 3*a*b^2*e + 3*a^2*c*e)*x^(1 + 3*n))/(1 + 3*n) + ((3*b^2*c*d + 3*a*c^2*d + b^3*e + 6*a*b*c*e)*x^(1 + 4*n))/(1 + 4*n) + (3*c*(b*c*d + b^2*e + a*c*e)*x^(1 + 5*n))/(1 + 5*n) + (c^2*(c*d + 3*b*e)*x^(1 + 6*n))/(1 + 6*n) + (c^3*e*x^(1 + 7*n))/(1 + 7*n)]

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

    @test_int [(d + e*x^n)^3/(a + b*x^n + c*x^(2*n)), x, 5, (e^2*(3*c*d - b*e)*x)/c^2 + (e^3*x^(1 + n))/(c*(1 + n)) + ((3*c^2*d^2*e - 3*b*c*d*e^2 + b^2*e^3 - a*c*e^3 + ((2*c*d - b*e)*(c^2*d^2 + b^2*e^2 - c*e*(b*d + 3*a*e)))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(c^2*(b - sqrt(b^2 - 4*a*c))) + ((3*c^2*d^2*e - 3*b*c*d*e^2 + b^2*e^3 - a*c*e^3 - ((2*c*d - b*e)*(c^2*d^2 + b^2*e^2 - c*e*(b*d + 3*a*e)))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(c^2*(b + sqrt(b^2 - 4*a*c)))]
    @test_int [(d + e*x^n)^2/(a + b*x^n + c*x^(2*n)), x, 5, (e^2*x)/c + ((2*c*d*e - b*e^2 + (2*c^2*d^2 + b^2*e^2 - 2*c*e*(b*d + a*e))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(c*(b - sqrt(b^2 - 4*a*c))) + ((2*c*d*e - b*e^2 - (2*c^2*d^2 + b^2*e^2 - 2*c*e*(b*d + a*e))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(c*(b + sqrt(b^2 - 4*a*c)))]
    @test_int [(d + e*x^n)^1/(a + b*x^n + c*x^(2*n)), x, 3, ((e + (2*c*d - b*e)/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(b - sqrt(b^2 - 4*a*c)) + ((e - (2*c*d - b*e)/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(b + sqrt(b^2 - 4*a*c))]
    @test_int [1/((d + e*x^n)^1*(a + b*x^n + c*x^(2*n))), x, 6, -((c*(2*c*d - (b + sqrt(b^2 - 4*a*c))*e)*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2))) - (c*(e + (2*c*d - b*e)/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((b + sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)) + (e^2*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 - b*d*e + a*e^2))]
    @test_int [1/((d + e*x^n)^2*(a + b*x^n + c*x^(2*n))), x, 7, -((c*(2*c^2*d^2 + b*(b + sqrt(b^2 - 4*a*c))*e^2 - 2*c*e*(b*d + sqrt(b^2 - 4*a*c)*d + a*e))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2)) - (c*(2*c^2*d^2 + b*(b - sqrt(b^2 - 4*a*c))*e^2 - 2*c*e*(b*d - sqrt(b^2 - 4*a*c)*d + a*e))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2) + (e^2*(2*c*d - b*e)*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 - b*d*e + a*e^2)^2) + (e^2*x*HypergeometricFunctions._₂F₁(2, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d^2*(c*d^2 - b*d*e + a*e^2))]
    @test_int [1/((d + e*x^n)^3*(a + b*x^n + c*x^(2*n))), x, 8, -((c*(2*c^3*d^3 - b^2*(b + sqrt(b^2 - 4*a*c))*e^3 - 3*c^2*d*e*(b*d + sqrt(b^2 - 4*a*c)*d + 2*a*e) + c*e^2*(3*b^2*d + a*sqrt(b^2 - 4*a*c)*e + 3*b*(sqrt(b^2 - 4*a*c)*d + a*e)))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^3)) - (c*(2*c^3*d^3 - b^2*(b - sqrt(b^2 - 4*a*c))*e^3 - 3*c^2*d*e*(b*d - sqrt(b^2 - 4*a*c)*d + 2*a*e) + c*e^2*(3*b^2*d - 3*b*sqrt(b^2 - 4*a*c)*d + 3*a*b*e - a*sqrt(b^2 - 4*a*c)*e))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^3) + (e^2*(3*c^2*d^2 + b^2*e^2 - c*e*(3*b*d + a*e))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 - b*d*e + a*e^2)^3) + (e^2*(2*c*d - b*e)*x*HypergeometricFunctions._₂F₁(2, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d^2*(c*d^2 - b*d*e + a*e^2)^2) + (e^2*x*HypergeometricFunctions._₂F₁(3, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d^3*(c*d^2 - b*d*e + a*e^2))]

    @test_int [(d + e*x^n)^3/(a + b*x^n + c*x^(2*n))^2, x, 9, (x*(b^2*c*d^3 - 2*a*c*d*(c*d^2 - 3*a*e^2) - a*b*e*(3*c*d^2 + a*e^2) - (a*b^2*e^3 + 2*a*c*e*(3*c*d^2 - a*e^2) - b*c*d*(c*d^2 + 3*a*e^2))*x^n))/(a*c*(b^2 - 4*a*c)*n*(a + b*x^n + c*x^(2*n))) + (e^2*(e + (6*c*d - 3*b*e)/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(c*(b - sqrt(b^2 - 4*a*c))) + (((a*b^2*e^3 + 2*a*c*e*(3*c*d^2 - a*e^2) - b*c*d*(c*d^2 + 3*a*e^2))*(1 - n) + (b^2*c*d*(3*a*e^2*(1 - 3*n) - c*d^2*(1 - n)) - a*b^3*e^3*(1 - 3*n) + 4*a*c^2*d*(c*d^2 - 3*a*e^2)*(1 - 2*n) + 2*a*b*c*e*(a*e^2*(2 - 5*n) + 3*c*d^2*n))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*c*(b^2 - 4*a*c)*(b - sqrt(b^2 - 4*a*c))*n) + (e^2*(e - (3*(2*c*d - b*e))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(c*(b + sqrt(b^2 - 4*a*c))) + (((a*b^2*e^3 + 2*a*c*e*(3*c*d^2 - a*e^2) - b*c*d*(c*d^2 + 3*a*e^2))*(1 - n) - (b^2*c*d*(3*a*e^2*(1 - 3*n) - c*d^2*(1 - n)) - a*b^3*e^3*(1 - 3*n) + 4*a*c^2*d*(c*d^2 - 3*a*e^2)*(1 - 2*n) + 2*a*b*c*e*(a*e^2*(2 - 5*n) + 3*c*d^2*n))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*c*(b^2 - 4*a*c)*(b + sqrt(b^2 - 4*a*c))*n)]
    @test_int [(d + e*x^n)^2/(a + b*x^n + c*x^(2*n))^2, x, 9, (x*(b^2*d^2 - 2*a*b*d*e - 2*a*(c*d^2 - a*e^2) + (b*c*d^2 - 4*a*c*d*e + a*b*e^2)*x^n))/(a*(b^2 - 4*a*c)*n*(a + b*x^n + c*x^(2*n))) - (2*e^2*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c)) - (((b*c*d^2 - 4*a*c*d*e + a*b*e^2)*(1 - n) - (b^2*(a*e^2*(1 - 3*n) - c*d^2*(1 - n)) + 4*a*c*(c*d^2 - a*e^2)*(1 - 2*n) + 4*a*b*c*d*e*n)/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b - sqrt(b^2 - 4*a*c))*n) - (2*e^2*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c)) - (((b*c*d^2 - 4*a*c*d*e + a*b*e^2)*(1 - n) + (b^2*(a*e^2*(1 - 3*n) - c*d^2*(1 - n)) + 4*a*c*(c*d^2 - a*e^2)*(1 - 2*n) + 4*a*b*c*d*e*n)/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b + sqrt(b^2 - 4*a*c))*n)]
    @test_int [(d + e*x^n)^1/(a + b*x^n + c*x^(2*n))^2, x, 4, (x*(b^2*d - 2*a*c*d - a*b*e + c*(b*d - 2*a*e)*x^n))/(a*(b^2 - 4*a*c)*n*(a + b*x^n + c*x^(2*n))) - (c*(2*a*(2*c*d*(1 - 2*n) + sqrt(b^2 - 4*a*c)*e*(1 - n)) - b^2*(d - d*n) - b*(sqrt(b^2 - 4*a*c)*d*(1 - n) - 2*a*e*n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*n) - (c*(2*a*(c*d*(2 - 4*n) - sqrt(b^2 - 4*a*c)*e*(1 - n)) - b^2*d*(1 - n) + b*(sqrt(b^2 - 4*a*c)*d*(1 - n) + 2*a*e*n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*n)]
    @test_int [1/((d + e*x^n)^1*(a + b*x^n + c*x^(2*n))^2), x, 10, (x*(b^2*c*d - 2*a*c^2*d - b^3*e + 3*a*b*c*e + c*(b*c*d - b^2*e + 2*a*c*e)*x^n))/(a*(b^2 - 4*a*c)*(c*d^2 - b*d*e + a*e^2)*n*(a + b*x^n + c*x^(2*n))) - (c*e^2*(2*c*d - (b + sqrt(b^2 - 4*a*c))*e)*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2) - (c*((2*a*b*c*e*(2 - 3*n) - 4*a*c^2*d*(1 - 2*n) + b^2*c*d*(1 - n) - b^3*e*(1 - n))/sqrt(b^2 - 4*a*c) + (b*c*d - b^2*e + 2*a*c*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b - sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)*n) - (c*e^2*(2*c*d - (b - sqrt(b^2 - 4*a*c))*e)*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2) + (c*(b*c*(2*a*e*(2 - 3*n) - sqrt(b^2 - 4*a*c)*d*(1 - n)) - 2*a*c*(2*c*d*(1 - 2*n) + sqrt(b^2 - 4*a*c)*e*(1 - n)) - b^3*e*(1 - n) + b^2*(c*d + sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)*n) + (e^4*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 - b*d*e + a*e^2)^2)]
    @test_int [1/((d + e*x^n)^2*(a + b*x^n + c*x^(2*n))^2), x, 11, -((x*(2*b^3*c*d*e - 6*a*b*c^2*d*e - b^4*e^2 - b^2*c*(c*d^2 - 4*a*e^2) + 2*a*c^2*(c*d^2 - a*e^2) + c*(2*b^2*c*d*e - 4*a*c^2*d*e - b^3*e^2 - b*c*(c*d^2 - 3*a*e^2))*x^n))/(a*(b^2 - 4*a*c)*(c*d^2 - b*d*e + a*e^2)^2*n*(a + b*x^n + c*x^(2*n)))) - (2*c*e^2*(3*c^2*d^2 + b*(b + sqrt(b^2 - 4*a*c))*e^2 - c*e*(3*b*d + 2*sqrt(b^2 - 4*a*c)*d + a*e))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^3) + (c*(4*a*c^2*(e*(a*e*(1 - 2*n) + sqrt(b^2 - 4*a*c)*d*(1 - n)) - c*d^2*(1 - 2*n)) - b^2*c*(e*(a*e*(5 - 7*n) + 2*sqrt(b^2 - 4*a*c)*d*(1 - n)) - c*d^2*(1 - n)) + b*c*(c*d*(4*a*e*(2 - 3*n) + sqrt(b^2 - 4*a*c)*d*(1 - n)) - 3*a*sqrt(b^2 - 4*a*c)*e^2*(1 - n)) + b^4*e^2*(1 - n) - b^3*e*(2*c*d - sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2*n) - (2*c*e^2*(3*c^2*d^2 + b*(b - sqrt(b^2 - 4*a*c))*e^2 - c*e*(3*b*d - 2*sqrt(b^2 - 4*a*c)*d + a*e))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^3) + (c*(4*a*c^2*(e*(a*e*(1 - 2*n) - sqrt(b^2 - 4*a*c)*d*(1 - n)) - c*d^2*(1 - 2*n)) - b^2*c*(e*(a*e*(5 - 7*n) - 2*sqrt(b^2 - 4*a*c)*d*(1 - n)) - c*d^2*(1 - n)) + b*c*(c*d*(4*a*e*(2 - 3*n) - sqrt(b^2 - 4*a*c)*d*(1 - n)) + 3*a*sqrt(b^2 - 4*a*c)*e^2*(1 - n)) + b^4*e^2*(1 - n) - b^3*e*(2*c*d + sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2*n) + (2*e^4*(2*c*d - b*e)*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 - b*d*e + a*e^2)^3) + (e^4*x*HypergeometricFunctions._₂F₁(2, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d^2*(c*d^2 - b*d*e + a*e^2)^2)]

    @test_int [(d + e*x^n)^3/(a + b*x^n + c*x^(2*n))^3, x, 11, (x*(b^2*c*d^3 - 2*a*c*d*(c*d^2 - 3*a*e^2) - a*b*e*(3*c*d^2 + a*e^2) - (a*b^2*e^3 + 2*a*c*e*(3*c*d^2 - a*e^2) - b*c*d*(c*d^2 + 3*a*e^2))*x^n))/(2*a*c*(b^2 - 4*a*c)*n*(a + b*x^n + c*x^(2*n))^2) + (e^2*x*(3*b^2*c*d - 6*a*c^2*d - b^3*e + a*b*c*e + c*(3*b*c*d - b^2*e - 2*a*c*e)*x^n))/(a*c^2*(b^2 - 4*a*c)*n*(a + b*x^n + c*x^(2*n))) - (1/(2*a^2*c^2*(b^2 - 4*a*c)^2*n^2*(a + b*x^n + c*x^(2*n))))*(x*(a*b^2*c^2*d*(3*a*e^2*(1 - 9*n) - 5*c*d^2*(1 - 3*n)) + 4*a^2*c^3*d*(c*d^2 - 3*a*e^2)*(1 - 4*n) - 2*a*b^5*e^3*n + 2*a^2*b*c^2*e*(3*c*d^2*(2 - 3*n) - 5*a*e^2*n) - 3*a*b^3*c*e*(c*d^2 - 3*a*e^2*n) + b^4*c*d*(c*d^2*(1 - 2*n) + 6*a*e^2*n) + c*(4*a^2*c^2*e*(3*c*d^2 - a*e^2)*(1 - 3*n) - 2*a*b^4*e^3*n - 2*a*b*c^2*d*(c*d^2*(2 - 7*n) + 3*a*e^2*n) + b^3*c*d*(c*d^2*(1 - 2*n) + 6*a*e^2*n) - a*b^2*c*e*(3*c*d^2 - a*e^2*(1 + 2*n)))*x^n)) + (e^2*(b*c*(2*a*e*(2 - 5*n) + 3*sqrt(b^2 - 4*a*c)*d*(1 - n)) - 2*a*c*(6*c*d*(1 - 2*n) + sqrt(b^2 - 4*a*c)*e*(1 - n)) - b^3*e*(1 - n) + b^2*(3*c*d - sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*c*(b^2 - 4*a*c)*(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*n) + (1/(2*a^2*c*(b^2 - 4*a*c)^2*(b - sqrt(b^2 - 4*a*c))*n^2))*(((1 - n)*(4*a^2*c^2*e*(3*c*d^2 - a*e^2)*(1 - 3*n) - 2*a*b^4*e^3*n - 2*a*b*c^2*d*(c*d^2*(2 - 7*n) + 3*a*e^2*n) + b^3*c*d*(c*d^2*(1 - 2*n) + 6*a*e^2*n) - a*b^2*c*e*(3*c*d^2 - a*e^2*(1 + 2*n))) - (1/sqrt(b^2 - 4*a*c))*(2*a*b^5*e^3*(1 - n)*n - b^4*c*d*(1 - n)*(c*d^2*(1 - 2*n) + 6*a*e^2*n) - 8*a^2*c^3*d*(c*d^2 - 3*a*e^2)*(1 - 6*n + 8*n^2) + 6*a*b^2*c^2*d*(c*d^2*(1 - 4*n + 3*n^2) - a*e^2*(1 - 10*n + 15*n^2)) - 4*a^2*b*c^2*e*(3*c*d^2*(1 - n - 3*n^2) + a*e^2*(1 - 11*n + 19*n^2)) + a*b^3*c*e*(3*c*d^2*(1 - n) + a*e^2*(1 - 19*n + 30*n^2))))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))))) + (e^2*(b*c*(2*a*e*(2 - 5*n) - 3*sqrt(b^2 - 4*a*c)*d*(1 - n)) - 2*a*c*(6*c*d*(1 - 2*n) - sqrt(b^2 - 4*a*c)*e*(1 - n)) - b^3*e*(1 - n) + b^2*(3*c*d + sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*c*(b^2 - 4*a*c)*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*n) + (1/(2*a^2*c*(b^2 - 4*a*c)^2*(b + sqrt(b^2 - 4*a*c))*n^2))*(((1 - n)*(4*a^2*c^2*e*(3*c*d^2 - a*e^2)*(1 - 3*n) - 2*a*b^4*e^3*n - 2*a*b*c^2*d*(c*d^2*(2 - 7*n) + 3*a*e^2*n) + b^3*c*d*(c*d^2*(1 - 2*n) + 6*a*e^2*n) - a*b^2*c*e*(3*c*d^2 - a*e^2*(1 + 2*n))) + (1/sqrt(b^2 - 4*a*c))*(2*a*b^5*e^3*(1 - n)*n - b^4*c*d*(1 - n)*(c*d^2*(1 - 2*n) + 6*a*e^2*n) - 8*a^2*c^3*d*(c*d^2 - 3*a*e^2)*(1 - 6*n + 8*n^2) + 6*a*b^2*c^2*d*(c*d^2*(1 - 4*n + 3*n^2) - a*e^2*(1 - 10*n + 15*n^2)) - 4*a^2*b*c^2*e*(3*c*d^2*(1 - n - 3*n^2) + a*e^2*(1 - 11*n + 19*n^2)) + a*b^3*c*e*(3*c*d^2*(1 - n) + a*e^2*(1 - 19*n + 30*n^2))))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))]
    @test_int [(d + e*x^n)^2/(a + b*x^n + c*x^(2*n))^3, x, 11, (x*(b^2*d^2 - 2*a*b*d*e - 2*a*(c*d^2 - a*e^2) + (b*c*d^2 - 4*a*c*d*e + a*b*e^2)*x^n))/(2*a*(b^2 - 4*a*c)*n*(a + b*x^n + c*x^(2*n))^2) + (e^2*x*(b^2 - 2*a*c + b*c*x^n))/(a*c*(b^2 - 4*a*c)*n*(a + b*x^n + c*x^(2*n))) + (1/(2*a^2*c*(b^2 - 4*a*c)^2*n^2*(a + b*x^n + c*x^(2*n))))*(x*(2*a*b^3*c*d*e - a*b^2*c*(a*e^2*(1 - 9*n) - 5*c*d^2*(1 - 3*n)) - 4*a^2*c^2*(c*d^2 - a*e^2)*(1 - 4*n) - 4*a^2*b*c^2*d*e*(2 - 3*n) - b^4*(c*d^2*(1 - 2*n) + 2*a*e^2*n) + c*(2*a*b^2*c*d*e - 8*a^2*c^2*d*e*(1 - 3*n) + 2*a*b*c*(c*d^2*(2 - 7*n) + a*e^2*n) - b^3*(c*d^2*(1 - 2*n) + 2*a*e^2*n))*x^n)) - (e^2*(4*a*c*(1 - 2*n) - b^2*(1 - n) - b*sqrt(b^2 - 4*a*c)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*n) - (1/(2*a^2*(b^2 - 4*a*c)^2*(b - sqrt(b^2 - 4*a*c))*n^2))*(((1 - n)*(2*a*b^2*c*d*e - 8*a^2*c^2*d*e*(1 - 3*n) + 2*a*b*c*(c*d^2*(2 - 7*n) + a*e^2*n) - b^3*(c*d^2*(1 - 2*n) + 2*a*e^2*n)) + (2*a*b^3*c*d*e*(1 - n) - b^4*(1 - n)*(c*d^2*(1 - 2*n) + 2*a*e^2*n) - 8*a^2*b*c^2*d*e*(1 - n - 3*n^2) - 8*a^2*c^2*(c*d^2 - a*e^2)*(1 - 6*n + 8*n^2) + 2*a*b^2*c*(3*c*d^2*(1 - 4*n + 3*n^2) - a*e^2*(1 - 10*n + 15*n^2)))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))))) - (e^2*(4*a*c*(1 - 2*n) - b^2*(1 - n) + b*sqrt(b^2 - 4*a*c)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*n) - (1/(2*a^2*(b^2 - 4*a*c)^2*(b + sqrt(b^2 - 4*a*c))*n^2))*(((1 - n)*(2*a*b^2*c*d*e - 8*a^2*c^2*d*e*(1 - 3*n) + 2*a*b*c*(c*d^2*(2 - 7*n) + a*e^2*n) - b^3*(c*d^2*(1 - 2*n) + 2*a*e^2*n)) - (2*a*b^3*c*d*e*(1 - n) - b^4*(1 - n)*(c*d^2*(1 - 2*n) + 2*a*e^2*n) - 8*a^2*b*c^2*d*e*(1 - n - 3*n^2) - 8*a^2*c^2*(c*d^2 - a*e^2)*(1 - 6*n + 8*n^2) + 2*a*b^2*c*(3*c*d^2*(1 - 4*n + 3*n^2) - a*e^2*(1 - 10*n + 15*n^2)))/sqrt(b^2 - 4*a*c))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))]
    @test_int [(d + e*x^n)^1/(a + b*x^n + c*x^(2*n))^3, x, 5, (x*(b^2*d - 2*a*c*d - a*b*e + c*(b*d - 2*a*e)*x^n))/(2*a*(b^2 - 4*a*c)*n*(a + b*x^n + c*x^(2*n))^2) + (x*(a*b^3*e - 4*a^2*c^2*d*(1 - 4*n) + 5*a*b^2*c*d*(1 - 3*n) - 2*a^2*b*c*e*(2 - 3*n) - b^4*d*(1 - 2*n) + c*(a*b^2*e + 2*a*b*c*d*(2 - 7*n) - 4*a^2*c*e*(1 - 3*n) - b^3*d*(1 - 2*n))*x^n))/(2*a^2*(b^2 - 4*a*c)^2*n^2*(a + b*x^n + c*x^(2*n))) + (1/(2*a^2*(b^2 - 4*a*c)^2*(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*n^2))*(c*(a*b^2*(sqrt(b^2 - 4*a*c)*e + 6*c*d*(1 - 3*n))*(1 - n) + b^3*(a*e - sqrt(b^2 - 4*a*c)*d*(1 - 2*n))*(1 - n) - b^4*d*(1 - 3*n + 2*n^2) - 2*a*b*c*(2*a*e*(1 - n - 3*n^2) - sqrt(b^2 - 4*a*c)*d*(2 - 9*n + 7*n^2)) - 4*a^2*c*(sqrt(b^2 - 4*a*c)*e*(1 - 4*n + 3*n^2) + 2*c*d*(1 - 6*n + 8*n^2)))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))))) - (1/(2*a^2*(b^2 - 4*a*c)^2*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*n^2))*(c*(a*b^2*(sqrt(b^2 - 4*a*c)*e - 6*c*d*(1 - 3*n))*(1 - n) - b^3*(a*e + sqrt(b^2 - 4*a*c)*d*(1 - 2*n))*(1 - n) + b^4*d*(1 - 3*n + 2*n^2) + 2*a*b*c*(2*a*e*(1 - n - 3*n^2) + sqrt(b^2 - 4*a*c)*d*(2 - 9*n + 7*n^2)) - 4*a^2*c*(sqrt(b^2 - 4*a*c)*e*(1 - 4*n + 3*n^2) - 2*c*d*(1 - 6*n + 8*n^2)))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))]
    @test_int [1/((d + e*x^n)^1*(a + b*x^n + c*x^(2*n))^3), x, 15, (x*(b^2*c*d - 2*a*c^2*d - b^3*e + 3*a*b*c*e + c*(b*c*d - b^2*e + 2*a*c*e)*x^n))/(2*a*(b^2 - 4*a*c)*(c*d^2 - b*d*e + a*e^2)*n*(a + b*x^n + c*x^(2*n))^2) + (e^2*x*(b^2*c*d - 2*a*c^2*d - b^3*e + 3*a*b*c*e + c*(b*c*d - b^2*e + 2*a*c*e)*x^n))/(a*(b^2 - 4*a*c)*(c*d^2 - b*d*e + a*e^2)^2*n*(a + b*x^n + c*x^(2*n))) + (x*(2*a^2*b*c^2*e*(4 - 11*n) - 3*a*b^3*c*e*(2 - 5*n) - 4*a^2*c^3*d*(1 - 4*n) + 5*a*b^2*c^2*d*(1 - 3*n) - b^4*c*d*(1 - 2*n) + b^5*(e - 2*e*n) - c*(a*b^2*c*e*(5 - 14*n) - 2*a*b*c^2*d*(2 - 7*n) - 4*a^2*c^2*e*(1 - 3*n) + b^3*c*d*(1 - 2*n) - b^4*e*(1 - 2*n))*x^n))/(2*a^2*(b^2 - 4*a*c)^2*(c*d^2 - b*d*e + a*e^2)*n^2*(a + b*x^n + c*x^(2*n))) - (c*e^4*(2*c*d - (b + sqrt(b^2 - 4*a*c))*e)*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^3) + (c*e^2*(b*c*(2*a*e*(2 - 3*n) + sqrt(b^2 - 4*a*c)*d*(1 - n)) - 2*a*c*(2*c*d*(1 - 2*n) - sqrt(b^2 - 4*a*c)*e*(1 - n)) - b^3*e*(1 - n) + b^2*(c*d - sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2*n) - (1/(2*a^2*(b^2 - 4*a*c)^2*(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)*n^2))*(c*(a*b^2*c*(sqrt(b^2 - 4*a*c)*e*(5 - 14*n) - 6*c*d*(1 - 3*n))*(1 - n) + b^3*c*(a*e*(7 - 18*n) + sqrt(b^2 - 4*a*c)*d*(1 - 2*n))*(1 - n) - b^5*e*(1 - 3*n + 2*n^2) + b^4*(c*d - sqrt(b^2 - 4*a*c)*e)*(1 - 3*n + 2*n^2) - 4*a^2*c^2*(sqrt(b^2 - 4*a*c)*e*(1 - 4*n + 3*n^2) - 2*c*d*(1 - 6*n + 8*n^2)) - 2*a*b*c^2*(sqrt(b^2 - 4*a*c)*d*(2 - 9*n + 7*n^2) + 2*a*e*(3 - 13*n + 13*n^2)))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))))) - (c*e^4*(2*c*d - (b - sqrt(b^2 - 4*a*c))*e)*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^3) + (c*e^2*(b*c*(2*a*e*(2 - 3*n) - sqrt(b^2 - 4*a*c)*d*(1 - n)) - 2*a*c*(2*c*d*(1 - 2*n) + sqrt(b^2 - 4*a*c)*e*(1 - n)) - b^3*e*(1 - n) + b^2*(c*d + sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2*n) + (1/(2*a^2*(b^2 - 4*a*c)^2*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)*n^2))*(c*(a*b^2*c*(sqrt(b^2 - 4*a*c)*e*(5 - 14*n) + 6*c*d*(1 - 3*n))*(1 - n) - b^3*c*(a*e*(7 - 18*n) - sqrt(b^2 - 4*a*c)*d*(1 - 2*n))*(1 - n) + b^5*e*(1 - 3*n + 2*n^2) - b^4*(c*d + sqrt(b^2 - 4*a*c)*e)*(1 - 3*n + 2*n^2) - 4*a^2*c^2*(sqrt(b^2 - 4*a*c)*e*(1 - 4*n + 3*n^2) + 2*c*d*(1 - 6*n + 8*n^2)) - 2*a*b*c^2*(sqrt(b^2 - 4*a*c)*d*(2 - 9*n + 7*n^2) - 2*a*e*(3 - 13*n + 13*n^2)))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c))))) + (e^6*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 - b*d*e + a*e^2)^3)]
    @test_int [1/((d + e*x^n)^2*(a + b*x^n + c*x^(2*n))^3), x, 16, -((x*(2*b^3*c*d*e - 6*a*b*c^2*d*e - b^4*e^2 - b^2*c*(c*d^2 - 4*a*e^2) + 2*a*c^2*(c*d^2 - a*e^2) + c*(2*b^2*c*d*e - 4*a*c^2*d*e - b^3*e^2 - b*c*(c*d^2 - 3*a*e^2))*x^n))/(2*a*(b^2 - 4*a*c)*(c*d^2 - b*d*e + a*e^2)^2*n*(a + b*x^n + c*x^(2*n))^2)) - (e^2*x*(5*b^3*c*d*e - 14*a*b*c^2*d*e - 2*b^4*e^2 - b^2*c*(3*c*d^2 - 7*a*e^2) + 2*a*c^2*(3*c*d^2 - a*e^2) + c*(5*b^2*c*d*e - 8*a*c^2*d*e - 2*b^3*e^2 - b*c*(3*c*d^2 - 5*a*e^2))*x^n))/(a*(b^2 - 4*a*c)*(c*d^2 - b*d*e + a*e^2)^3*n*(a + b*x^n + c*x^(2*n))) - (x*(a*b^2*c^2*(a*e^2*(13 - 37*n) - 5*c*d^2*(1 - 3*n)) - b^4*c*(a*e^2*(7 - 17*n) - c*d^2*(1 - 2*n)) - 4*a^2*b*c^3*d*e*(4 - 11*n) + 6*a*b^3*c^2*d*e*(2 - 5*n) + 4*a^2*c^3*(c*d^2 - a*e^2)*(1 - 4*n) - 2*b^5*c*d*e*(1 - 2*n) + b^6*e^2*(1 - 2*n) + c*(2*a*b*c^2*(a*e^2*(4 - 13*n) - c*d^2*(2 - 7*n)) - b^3*c*(2*a*e^2*(3 - 8*n) - c*d^2*(1 - 2*n)) + 2*a*b^2*c^2*d*e*(5 - 14*n) - 8*a^2*c^3*d*e*(1 - 3*n) - 2*b^4*c*d*e*(1 - 2*n) + b^5*e^2*(1 - 2*n))*x^n))/(2*a^2*(b^2 - 4*a*c)^2*(c*d^2 - b*d*e + a*e^2)^2*n^2*(a + b*x^n + c*x^(2*n))) - (c*e^4*(10*c^2*d^2 + 3*b*(b + sqrt(b^2 - 4*a*c))*e^2 - 2*c*e*(5*b*d + 3*sqrt(b^2 - 4*a*c)*d + a*e))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^4) + (c*e^2*(4*a*c^2*(e*(a*e*(1 - 2*n) + 2*sqrt(b^2 - 4*a*c)*d*(1 - n)) - 3*c*d^2*(1 - 2*n)) - b^2*c*(e*(a*e*(9 - 13*n) + 5*sqrt(b^2 - 4*a*c)*d*(1 - n)) - 3*c*d^2*(1 - n)) + b*c*(c*d*(4*a*e*(5 - 8*n) + 3*sqrt(b^2 - 4*a*c)*d*(1 - n)) - 5*a*sqrt(b^2 - 4*a*c)*e^2*(1 - n)) + 2*b^4*e^2*(1 - n) - b^3*e*(5*c*d - 2*sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c - b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^3*n) + (c*((2*a*b*c^2*(a*e^2*(4 - 13*n) - c*d^2*(2 - 7*n)) - b^3*c*(2*a*e^2*(3 - 8*n) - c*d^2*(1 - 2*n)) + 2*a*b^2*c^2*d*e*(5 - 14*n) - 8*a^2*c^3*d*e*(1 - 3*n) - 2*b^4*c*d*e*(1 - 2*n) + b^5*e^2*(1 - 2*n))*(1 - n) - (1/sqrt(b^2 - 4*a*c))*(b^4*c*(4*a*e^2*(2 - 5*n) - c*d^2*(1 - 2*n))*(1 - n) + 2*b^5*c*d*e*(1 - 3*n + 2*n^2) - b^6*e^2*(1 - 3*n + 2*n^2) - 8*a^2*c^3*(c*d^2 - a*e^2)*(1 - 6*n + 8*n^2) + 8*a^2*b*c^3*d*e*(3 - 13*n + 13*n^2) - 2*a*b^3*c^2*d*e*(7 - 25*n + 18*n^2) + 2*a*b^2*c^2*(3*c*d^2*(1 - 4*n + 3*n^2) - a*e^2*(9 - 38*n + 35*n^2))))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))))/(2*a^2*(b^2 - 4*a*c)^2*(b - sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2*n^2) - (c*e^4*(10*c^2*d^2 + 3*b*(b - sqrt(b^2 - 4*a*c))*e^2 - 2*c*e*(5*b*d - 3*sqrt(b^2 - 4*a*c)*d + a*e))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^4) + (c*e^2*(4*a*c^2*(e*(a*e*(1 - 2*n) - 2*sqrt(b^2 - 4*a*c)*d*(1 - n)) - 3*c*d^2*(1 - 2*n)) - b^2*c*(e*(a*e*(9 - 13*n) - 5*sqrt(b^2 - 4*a*c)*d*(1 - n)) - 3*c*d^2*(1 - n)) + b*c*(c*d*(4*a*e*(5 - 8*n) - 3*sqrt(b^2 - 4*a*c)*d*(1 - n)) + 5*a*sqrt(b^2 - 4*a*c)*e^2*(1 - n)) + 2*b^4*e^2*(1 - n) - b^3*e*(5*c*d + 2*sqrt(b^2 - 4*a*c)*e)*(1 - n))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*(b^2 - 4*a*c)*(b^2 - 4*a*c + b*sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^3*n) + (c*((2*a*b*c^2*(a*e^2*(4 - 13*n) - c*d^2*(2 - 7*n)) - b^3*c*(2*a*e^2*(3 - 8*n) - c*d^2*(1 - 2*n)) + 2*a*b^2*c^2*d*e*(5 - 14*n) - 8*a^2*c^3*d*e*(1 - 3*n) - 2*b^4*c*d*e*(1 - 2*n) + b^5*e^2*(1 - 2*n))*(1 - n) + (1/sqrt(b^2 - 4*a*c))*(b^4*c*(4*a*e^2*(2 - 5*n) - c*d^2*(1 - 2*n))*(1 - n) + 2*b^5*c*d*e*(1 - 3*n + 2*n^2) - b^6*e^2*(1 - 3*n + 2*n^2) - 8*a^2*c^3*(c*d^2 - a*e^2)*(1 - 6*n + 8*n^2) + 8*a^2*b*c^3*d*e*(3 - 13*n + 13*n^2) - 2*a*b^3*c^2*d*e*(7 - 25*n + 18*n^2) + 2*a*b^2*c^2*(3*c*d^2*(1 - 4*n + 3*n^2) - a*e^2*(9 - 38*n + 35*n^2))))*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(2*a^2*(b^2 - 4*a*c)^2*(b + sqrt(b^2 - 4*a*c))*(c*d^2 - b*d*e + a*e^2)^2*n^2) + (3*e^6*(2*c*d - b*e)*x*HypergeometricFunctions._₂F₁(1, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d*(c*d^2 - b*d*e + a*e^2)^4) + (e^6*x*HypergeometricFunctions._₂F₁(2, 1/n, 1 + 1/n, -((e*x^n)/d)))/(d^2*(c*d^2 - b*d*e + a*e^2)^3)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^n)^q*(a+b*x^n+c*x^(2*n))^(p/2)=#

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

    @test_int [(d + e*x^n)*(a + b*x^n + c*x^(2*n))^(1/2), x, 6, (e*x^(1 + n)*sqrt(a + b*x^n + c*x^(2*n))*AppellF1(1 + 1/n, -(1/2), -(1/2), 2 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + n)*sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))) + (d*x*sqrt(a + b*x^n + c*x^(2*n))*AppellF1(1/n, -(1/2), -(1/2), 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c))))]

    @test_int [(d + e*x^n)*(a + b*x^n + c*x^(2*n))^(3/2), x, 6, (a*e*x^(1 + n)*sqrt(a + b*x^n + c*x^(2*n))*AppellF1(1 + 1/n, -(3/2), -(3/2), 2 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + n)*sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))) + (a*d*x*sqrt(a + b*x^n + c*x^(2*n))*AppellF1(1/n, -(3/2), -(3/2), 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c))))]

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

    @test_int [(d + e*x^n)/(a + b*x^n + c*x^(2*n))^(1/2), x, 6, (e*x^(1 + n)*sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))*AppellF1(1 + 1/n, 1/2, 1/2, 2 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + n)*sqrt(a + b*x^n + c*x^(2*n))) + (d*x*sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))*AppellF1(1/n, 1/2, 1/2, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/sqrt(a + b*x^n + c*x^(2*n))]

    @test_int [(d + e*x^n)/(a + b*x^n + c*x^(2*n))^(3/2), x, 6, (e*x^(1 + n)*sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))*AppellF1(1 + 1/n, 3/2, 3/2, 2 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*(1 + n)*sqrt(a + b*x^n + c*x^(2*n))) + (d*x*sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))*AppellF1(1/n, 3/2, 3/2, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a*sqrt(a + b*x^n + c*x^(2*n)))]

    @test_int [(d + e*x^n)/(a + b*x^n + c*x^(2*n))^(5/2), x, 6, (e*x^(1 + n)*sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))*AppellF1(1 + 1/n, 5/2, 5/2, 2 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a^2*(1 + n)*sqrt(a + b*x^n + c*x^(2*n))) + (d*x*sqrt(1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))*sqrt(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))*AppellF1(1/n, 5/2, 5/2, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/(a^2*sqrt(a + b*x^n + c*x^(2*n)))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(d+e*x^n)^q*(a+b*x^n+c*x^(2*n))^p*with*p*symbolic=#

    @test_int [(d + e*x^n)^q*(a + b*x^n + c*x^(2*n))^p, x, 0, Unintegrable((d + e*x^n)^q*(a + b*x^n + c*x^(2*n))^p, x)]

    @test_int [(a + b*x^n + c*x^(2*n))^p*(d + e*x^n)^3, x, 10, (3*d^2*e*x^(1 + n)*(a + b*x^n + c*x^(2*n))^p*AppellF1(1 + 1/n, -p, -p, 2 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p*(1 + n)) + (3*d*e^2*x^(1 + 2*n)*(a + b*x^n + c*x^(2*n))^p*AppellF1(2 + 1/n, -p, -p, 3 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p*(1 + 2*n)) + (e^3*x^(1 + 3*n)*(a + b*x^n + c*x^(2*n))^p*AppellF1(3 + 1/n, -p, -p, 4 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p*(1 + 3*n)) + (d^3*x*(a + b*x^n + c*x^(2*n))^p*AppellF1(1/n, -p, -p, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p)]
    @test_int [(a + b*x^n + c*x^(2*n))^p*(d + e*x^n)^2, x, 8, (2*d*e*x^(1 + n)*(a + b*x^n + c*x^(2*n))^p*AppellF1(1 + 1/n, -p, -p, 2 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p*(1 + n)) + (e^2*x^(1 + 2*n)*(a + b*x^n + c*x^(2*n))^p*AppellF1(2 + 1/n, -p, -p, 3 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p*(1 + 2*n)) + (d^2*x*(a + b*x^n + c*x^(2*n))^p*AppellF1(1/n, -p, -p, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p)]
    @test_int [(a + b*x^n + c*x^(2*n))^p*(d + e*x^n)^1, x, 6, (e*x^(1 + n)*(a + b*x^n + c*x^(2*n))^p*AppellF1(1 + 1/n, -p, -p, 2 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p*(1 + n)) + (d*x*(a + b*x^n + c*x^(2*n))^p*AppellF1(1/n, -p, -p, 1 + 1/n, -((2*c*x^n)/(b - sqrt(b^2 - 4*a*c))), -((2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))))/((1 + (2*c*x^n)/(b - sqrt(b^2 - 4*a*c)))^p*(1 + (2*c*x^n)/(b + sqrt(b^2 - 4*a*c)))^p)]
    @test_int [(a + b*x^n + c*x^(2*n))^p/(d + e*x^n)^1, x, 0, Unintegrable((a + b*x^n + c*x^(2*n))^p/(d + e*x^n), x)]
    @test_int [(a + b*x^n + c*x^(2*n))^p/(d + e*x^n)^2, x, 0, Unintegrable((a + b*x^n + c*x^(2*n))^p/(d + e*x^n)^2, x)]
    @test_int [(a + b*x^n + c*x^(2*n))^p/(d + e*x^n)^3, x, 0, Unintegrable((a + b*x^n + c*x^(2*n))^p/(d + e*x^n)^3, x)]
    end

max_stars_repo_path: test/1 Algebraic functions/1.2 Trinomial products/1.2.3 General/1.2.3.3 (d+e x^n)^q (a+b x^n+c x^(2 n))^p.jl


text:
function wider_normal_model(t :: Trace, data :: Vector{Float64})
    loc = sample(t, :loc, Normal(0.0, 10.0))
    scale = sample(t, :scale, LogNormal())
    for i in 1:length(data)
        observe(t, (:obs, i), Normal(loc, scale), data[i])
    end
end

@testset "prior metropolis proposal 1" begin
    data = randn(100) .+ 4.0
    t = trace()
    wider_normal_model(t, data)
    @info "True loc = 4.0"
    @info "True std = 1.0"

    locs = []
    scales = []
    lls = []

    for i in 1:2500
        t = mh_step(t, wider_normal_model; params = (data,))
        push!(locs, t[:loc].value)
        push!(scales, t[:scale].value)
        push!(lls, loglikelihood(t))
    end

    @info "inferred E[loc] = $(mean(locs[1000:end]))"
    @info "inferred E[scale] = $(mean(scales[1000:end]))"
    @info "approximate p(x) = sum_z p(x|z) = $(mean(lls[1000:end]))"
end

@testset "prior metropolis proposal 2" begin
    data = randn(10) .+ 4.0
    @info "True loc = 4.0"
    @info "True std = 1.0"
    results = mh(wider_normal_model; params=(data,))
    mean_loc = mean(results, :loc)
    std_loc = std(results, :loc)
    @info "Mean loc = $mean_loc"
    @info "Std loc = $std_loc"
end

loc_proposal(old_t :: Trace, new_t :: Trace, data) = propose(new_t, :loc, Normal(old_t[:loc].value, 0.25))
scale_proposal(old_t :: Trace, new_t :: Trace, data) = propose(new_t, :scale, truncated(Normal(old_t[:scale].value, 0.25), 0.0, Inf))

@testset "general metropolis proposal 1" begin
    data = randn(100) .+ 4.0
    t = trace()
    wider_normal_model(t, data)

    locs = []
    scales = []
    lls = []

    for i in 1:2500
        t = mh_step(t, wider_normal_model, loc_proposal; params = (data,))
        t = mh_step(t, wider_normal_model, scale_proposal; params = (data,))
        push!(locs, t[:loc].value)
        push!(scales, t[:scale].value)
        push!(lls, loglikelihood(t))
    end

    @info "inferred E[loc] = $(mean(locs[1000:end]))"
    @info "inferred E[scale] = $(mean(scales[1000:end]))"
    @info "approximate p(x) = sum_z p(x|z) = $(mean(lls[1000:end]))"
end

@testset "generic metropolis proposal 2" begin
    data = randn(100) .+ 4.0
    @info "Using full results struct"
    results = mh(wider_normal_model, [loc_proposal, scale_proposal]; params = (data,), inverse_verbosity = Inf)
    @info "Using bare results struct"
    results = mh(wider_normal_model, [loc_proposal, scale_proposal], (:loc,); params = (data,), inverse_verbosity = Inf)
end

function random_sum_model(t :: Trace, data)
    n = sample(t, :n, Geometric(0.1))
    loc = 0.0
    for i in 1:(n + 1)
        loc += sample(t, (:loc, i), Normal())
    end
    obs = Array{Float64, 1}()
    for j in 1:length(data)
        o = observe(t, (:data, j), Normal(loc, 1.0), data[j])
        push!(obs, o)
    end
    obs
end

function random_n_proposal(old_trace, new_trace, params...)
    old_n = float(old_trace[:n].value)
    if old_n > 0
        propose(new_trace, :n, Poisson(old_n))
    else
        propose(new_trace, :n, Poisson(1.0))
    end
end

function gen_loc_proposal(old_trace, new_trace, ix, params...)
    propose(new_trace, (:loc, ix), Normal(old_trace[(:loc, ix)].value, 0.25))
end

@testset "generic metropolis proposal 3" begin
    t = trace()
    data = random_sum_model(t, fill(nothing, 25))
    @info "True :n = $(t[:n].value)"
    random_sum_model(t, data)

    ns = []
    loc_proposals = [
        (o, n, params...) -> gen_loc_proposal(o, n, i, params...) for i in 1:100
    ]

    for i in 1:5000
        t = mh_step(t, random_sum_model, random_n_proposal; params=(data,))
        for j in 1:(t[:n].value + 1)
            t = mh_step(t, random_sum_model, loc_proposals[j]; params=(data,))
        end
        push!(ns, t[:n].value)
    end

    @info "Posterior E[:n] = $(mean(ns[1000:end]))"
end

const Maybe{T} = Union{T, Nothing}

function eye(d :: Int)
    mat = zeros(Float64, d, d)
    for i in 1:d
        mat[i, i] = 1.0
    end
    mat
end

function linear_model!(t :: Trace, out :: Vector{Float64}, X :: Matrix{Float64}, y :: Maybe{Vector{Float64}})
    size_X = size(X)
    D = size_X[1]
    N = size_X[2]
    β = sample(t, :β, MvNormal(zeros(D), eye(D)))
    scale = sample(t, :scale, LogNormal(0.0, 1.0))
    loc = X' * β
    if y === nothing
        for n in 1:N
            out[n] = sample(t, (:y, n), Normal(loc[n], scale))
        end
    else
        for n in 1:N
            out[n] = observe(t, (:y, n), Normal(loc[n], scale), y[n])
        end
    end
end

beta_proposal(old_t :: Trace, new_t :: Trace, _, _, _) = propose(new_t, :β, MvNormal(old_t[:β].value, 0.5 .* eye(length(old_t[:β].value))))
scale_proposal(old_t :: Trace, new_t :: Trace, _, _, _) = propose(new_t, :scale, truncated(Normal(old_t[:scale].value, 0.25), 0.0, Inf))

@testset "generic metropolis proposal 4" begin
    D = 10
    N = 200
    X = randn(D, N)
    out = Vector{Float64}(undef, N)
    @info "Using model to generate dataset"
    t = trace()
    linear_model!(t, out, X, nothing)
    y = [t[(:y, n)].value for n in 1:N]
    β_true = t[:β].value
    @info "True regression coefficients: $β_true"

    @info "Conducting inference using user-defined Metropolis kernels"
    # smoketest only --- low number of iterations. see examples/basic.jl for actual inference results
    @time results = mh(
        linear_model!,
        [beta_proposal, scale_proposal];
        params = (out, X, y),
        burn = 50,
        thin = 10,
        num_iterations = 500
    )
    β_mean = mean(results, :β)
    β_std = std(results, :β)
    @info "Posterior mean regression coefficients = $β_mean"
    @info "Posterior std regression coefficients = $β_std"
end

ext: jl


text:
using MLStyle

@active Re{r :: Regex}(x) begin
    match(r, x)
end

match_numbers = @λ begin
    Re{r"\G\d+"}(_) -> true
    _ -> false
end

@assert match_numbers("12345  ")
@assert !match_numbers("   12345")

struct RGB
    R :: Int
    G :: Int
    B :: Int
end

red = RGB(220, 20, 60)

green = RGB(0, 150, 50)

@active Red(x) begin
    @match (x.R, x.G, x.B) begin
        (118:138, 0:10, 0:10) => :maroon
        (129:149, 0:10, 0:10) => :dark_red
        (210:230, 10:30, 50:70) => :crimson
        (155:175, 32:52, 32:52) => :brown
        (100:255, 0:110, 0:110) => :unknown
        _ => nothing
    end
end

@active Green(x) begin
    @match (x.R, x.G, x.B) begin
        (0:10, 90:110, 0:10) => :dark_green
        (0:10, 118:138, 0:10) => :green
        (24:44, 129:149, 24:44) => :forest_green
        (0:100, 100:255, 0:100) => :unknown
        _ => nothing
    end
end

macro f(x) println(macroexpand(Main, x)) end
@assert @match red begin
        Red(x) => (println(x); true)
        x => (show(x); false)
end

@assert @match green begin
    Green(x) => (println(x); true)
    _ => false
end

max_stars_repo_name: thautwarm/MLStyle-Playground

max_issues_repo_name: cherichy/MLStyle-Playground

max_forks_repo_name: cherichy/MLStyle-Playground


text:
tests = ["testini.jl",
         "testhttp.jl",
         "testsimple.jl",
         "testmerge.jl"
]

for test in tests
    include(test)
end

outfile = "confs/out.conf"
if isfile(outfile) == true
    rm(outfile)
end


text:
# ---
# title: 974. Subarray Sums Divisible by K
# id: problem974
# author: Indigo
# date: 2021-02-21
# difficulty: Medium
# categories: Array, Hash Table
# link: <https://leetcode.com/problems/subarray-sums-divisible-by-k/description/>
# hidden: true
# ---
#
# Given an array `A` of integers, return the number of (contiguous, non-empty)
# subarrays that have a sum divisible by `K`.
#
#
#
# **Example 1:**
#
#
#
#     Input: A = [4,5,0,-2,-3,1], K = 5
#     Output: 7
#     Explanation: There are 7 subarrays with a sum divisible by K = 5:
#     [4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3]
#
#
#
#
# **Note:**
#
#   1. `1 <= A.length <= 30000`
#   2. `-10000 <= A[i] <= 10000`
#   3. `2 <= K <= 10000`
#
#
## @lc code=start
using LeetCode

function subarrays_div_by_k(A::Vector{Int}, K::Int)
    dct = DefaultDict{Int,Int}(0)
    dct[0] = 1
    prex = res = 0
    for num in A
        prex = mod(num + prex, K)
        res += dct[prex]
        dct[prex] += 1
    end
    res
end
## @lc code=end


text:
@testset "Hadwick-James Cycles" begin

    # Simple graph gives expected circuits
    ex1 = DiGraph(5)
    add_edge!(ex1, 1, 2)
    add_edge!(ex1, 2, 3)
    add_edge!(ex1, 3, 4)
    add_edge!(ex1, 3, 5)
    add_edge!(ex1, 4, 5)
    add_edge!(ex1, 5, 2)

    expected_circuits = Vector{Int}[
        [2, 3, 4, 5],
        [2, 3, 5]
    ]
    for g in testdigraphs(ex1)
        ex1_circuits = simplecycles_hadwick_james(g)

        @test issubset(expected_circuits, ex1_circuits)
        @test issubset(ex1_circuits, expected_circuits)

        # Adding self-edges gives new circuits
        add_edge!(g, 1, 1)
        add_edge!(g, 3, 3)

        ex1_circuits_self = simplecycles_hadwick_james(g)

        @test issubset(expected_circuits, ex1_circuits_self)
        @test [1] ∈ ex1_circuits_self && [3] ∈ ex1_circuits_self
    end

    # Path DiGraph
    ex2_size = 10
    ex2 = testdigraphs(PathDiGraph(ex2_size))
    for g in ex2
        @test isempty(simplecycles_hadwick_james(g))
    end

    # Complete DiGraph
    ex3_size = 5
    ex3 = testdigraphs(CompleteDiGraph(ex3_size))
    for g in ex3
        ex3_circuits = simplecycles_hadwick_james(g)
        @test length(ex3_circuits) == length(unique(ex3_circuits))
    end

    # Almost fully connected DiGraph
    ex4 = DiGraph(9)
    for (src, dest) in [(1,2),(1,5),(1,7),(1,8),(2,9),(3,4),(3,6),
                        (4,5),(4,7),(5,6),(6,7),(6,8),(7,9),(8,9)]
        add_edge!(ex4, src, dest)
        add_edge!(ex4, dest, src)
    end
    for g in testdigraphs(ex4)
        ex4_output = simplecycles_hadwick_james(g)
        @test [1, 2] ∈ ex4_output && [8, 9] ∈ ex4_output
    end
end

max_stars_repo_name: AsileBcd/JohnsonCycles

max_issues_repo_name: AsileBcd/JohnsonCycles

max_forks_repo_name: AsileBcd/JohnsonCycles


text:
#Start Test Script
using PlotShapefiles
using Base.Test

# Run tests

tic()
println("Test 1")
@time @test include("plotshape.jl")
println("Test 2")
@time @test include("choropleth.jl")
toc()


text:
using DDF

using LinearAlgebra
using StaticArrays

@testset "Empty manifold D=$D" for D in 0:Dmax
    S = Float64
    mfd = empty_manifold(Val(D), S; optimize_mesh=false)
    @test invariant(mfd)
    for R in 0:D
        @test nsimplices(mfd, R) == 0
    end
    @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)
    for R in 0:D
        @test isempty(get_volumes(mfd, R))
        @test isempty(get_dualvolumes(mfd, R))
    end
end

@testset "Simplex manifold D=$D" for D in 0:Dmax
    S = Float64
    mfd = simplex_manifold(Val(D), S; optimize_mesh=false)
    @test invariant(mfd)
    for R in 0:D
        @test nsimplices(mfd, R) == binomial(D + 1, R + 1)
    end
    @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)

    N = D + 1
    for i in ID{0}(1):ID{0}(N), j in (i + 1):ID{0}(N)
        @test norm(get_coords(mfd)[i] - get_coords(mfd)[j]) ≈ 1
    end

    for R in 0:D
        # <https://en.wikipedia.org/wiki/Simplex#Volume>
        vol = sqrt(S(R + 1) / 2^R) / factorial(R)
        @test all(≈(vol), get_volumes(mfd, R))
        @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥ 0.01
        @test all(>(0), get_dualvolumes(mfd, R))
        @test minimum(get_dualvolumes(mfd, R)) /
              maximum(get_dualvolumes(mfd, R)) ≥ 0.01
    end
    # <https://en.wikipedia.org/wiki/Simplex#Volume>
    vol = sqrt(S(D + 1) / 2^D) / factorial(D)
    @test all(==(1), get_volumes(mfd, 0))
    @test sum(get_volumes(mfd, D)) ≈ vol
    @test sum(get_dualvolumes(mfd, 0)) ≈ vol
    @test all(==(1), get_dualvolumes(mfd, D))
end

@testset "Orthogonal simplex manifold D=$D" for D in 0:Dmax
    S = Float64
    mfd = orthogonal_simplex_manifold(Val(D), S; optimize_mesh=false)
    @test invariant(mfd)
    for R in 0:D
        @test nsimplices(mfd, R) == binomial(D + 1, R + 1)
    end
    @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)
    for R in 0:D
        @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥ 0.01
        if mfd.dualkind == BarycentricDuals || (D ≤ 2 &&
            mfd.dualkind == CircumcentricDuals &&
            mfd.use_weighted_duals)
            @test all(>(0), get_dualvolumes(mfd, R))
            @test minimum(get_dualvolumes(mfd, R)) /
                  maximum(get_dualvolumes(mfd, R)) ≥ 0.01
        end
    end

    # <https://en.wikipedia.org/wiki/Simplex#Volume>
    vol = S(1) / factorial(D)
    @test all(==(1), get_volumes(mfd, 0))
    @test sum(get_volumes(mfd, D)) ≈ vol
    @test sum(get_dualvolumes(mfd, 0)) ≈ vol
    @test all(==(1), get_dualvolumes(mfd, D))
end

@testset "Hypercube manifold D=$D" for D in 0:Dmax
    S = Float64
    mfd = hypercube_manifold(Val(D), S)
    @test invariant(mfd)
    @test nsimplices(mfd, 0) == 2^D
    @test nsimplices(mfd, D) == factorial(D)
    # TODO: Find rule for other dimensions
    @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)
    for R in 0:D
        @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥ 0.01
        if mfd.dualkind == BarycentricDuals ||
           (mfd.dualkind == CircumcentricDuals && mfd.use_weighted_duals)
            @test all(>(0), get_dualvolumes(mfd, R))
            @test minimum(get_dualvolumes(mfd, R)) /
                  maximum(get_dualvolumes(mfd, R)) ≥ 0.01
        end
    end

    vol = 1
    @test all(==(1), get_volumes(mfd, 0))
    @test sum(get_volumes(mfd, D)) ≈ vol
    @test sum(get_dualvolumes(mfd, 0)) ≈ vol
    @test all(==(1), get_dualvolumes(mfd, D))
end

@testset "Large hypercube manifold D=$D" for D in 0:Dmax
    S = Float64
    n = 4
    mfd = large_hypercube_manifold(Val(D), S; nelts=ntuple(d -> n, D),
                                   optimize_mesh=false)
    @test invariant(mfd)
    @test nsimplices(mfd, 0) == (n + 1)^D
    @test nsimplices(mfd, D) == n^D * factorial(D)
    # TODO: Find rule for other dimensions
    @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)
    for R in 0:D
        @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥ 0.01
        if mfd.dualkind == BarycentricDuals ||
           (mfd.dualkind == CircumcentricDuals && mfd.use_weighted_duals)
            @test all(>(0), get_dualvolumes(mfd, R))
            @test minimum(get_dualvolumes(mfd, R)) /
                  maximum(get_dualvolumes(mfd, R)) ≥
                  (D ≤ 3 ? 0.01 : D ≤ 4 ? 0.001 : 0.0001)
        end
    end

    vol = 1
    @test all(==(1), get_volumes(mfd, 0))
    @test sum(get_volumes(mfd, D)) ≈ vol
    if !(sum(get_dualvolumes(mfd, 0)) ≈ vol)
        @show D extrema(get_dualvolumes(mfd, 0))
    end
    @test sum(get_dualvolumes(mfd, 0)) ≈ vol
    @test all(==(1), get_dualvolumes(mfd, D))
end

# @testset "Large hypertorus manifold D=$D" for D in 0:Dmax
#     S = Float64
#     mfd = large_hypercube_manifold(Val(D), S; nelts=ntuple(d -> 2, D),
#                                    torus=true)
#     @test invariant(mfd)
#     @test nsimplices(mfd, 0) == 2^D
#     @test nsimplices(mfd, D) == 2^D * factorial(D)
#     # TODO: Find rule for other dimensions
#     @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)
#     for R in 0:D
#         @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥ 0.01
#         if mfd.dualkind == BarycentricDuals ||
#            (mfd.dualkind == CircumcentricDuals && mfd.use_weighted_duals)
#             @test all(>(0), get_dualvolumes(mfd, R))
#             @test minimum(get_dualvolumes(mfd, R)) /
#                   maximum(get_dualvolumes(mfd, R)) ≥ 0.01
#         end
#     end
#
#     vol = 1
#     @test all(==(1), get_volumes(mfd, 0))
#     @test sum(get_volumes(mfd, D)) ≈ vol
#     @test sum(get_dualvolumes(mfd, 0)) ≈ vol
#     @test all(==(1), get_dualvolumes(mfd, D))
# end

@testset "Delaunay hypercube manifold D=$D" for D in 0:Dmax
    S = Float64
    mfd = delaunay_hypercube_manifold(Val(D), S)
    @test invariant(mfd)
    @test nsimplices(mfd, 0) == 2^D
    @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)
    for R in 0:D
        @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥ 0.01
        if mfd.dualkind == BarycentricDuals || (D ≤ 3 &&
            mfd.dualkind == CircumcentricDuals &&
            mfd.use_weighted_duals)
            @test all(>(0), get_dualvolumes(mfd, R))
            @test minimum(get_dualvolumes(mfd, R)) /
                  maximum(get_dualvolumes(mfd, R)) ≥ 0.01
        end
    end

    vol = 1
    @test all(==(1), get_volumes(mfd, 0))
    @test sum(get_volumes(mfd, D)) ≈ vol
    @test sum(get_dualvolumes(mfd, 0)) ≈ vol
    @test all(==(1), get_dualvolumes(mfd, D))
end

@testset "Large delaunay hypercube manifold D=$D" for D in 0:Dmax
    S = Float64
    mfd = large_delaunay_hypercube_manifold(Val(D), S)
    @test invariant(mfd)
    n = D == 0 ? 1 : round(Int, nsimplices(mfd, 0)^(1 / D)) - 1
    @test nsimplices(mfd, 0) == (n + 1)^D
    @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)
    for R in 0:D
        if mfd.dualkind == BarycentricDuals || D ≤ 3
            @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥
                  0.01
        end
        if mfd.dualkind == BarycentricDuals || (D ≤ 2 &&
            mfd.dualkind == CircumcentricDuals &&
            mfd.use_weighted_duals)
            @test all(>(0), get_dualvolumes(mfd, R))
            @test minimum(get_dualvolumes(mfd, R)) /
                  maximum(get_dualvolumes(mfd, R)) ≥ 0.01
        end
    end

    vol = 1
    @test all(==(1), get_volumes(mfd, 0))
    @test sum(get_volumes(mfd, D)) ≈ vol
    @test sum(get_dualvolumes(mfd, 0)) ≈ vol
    @test all(==(1), get_dualvolumes(mfd, D))
end

# @testset "Random hypercube manifold D=$D" for D in 0:Dmax
#     S = Float64
#     xmin = SVector{D,S}(0 for d in 1:D)
#     xmax = SVector{D,S}(1 for d in 1:D)
#     n = 4
#     mfd = random_hypercube_manifold(xmin, xmax, n)
#     @test invariant(mfd)
#     @test nsimplices(mfd, 0) == (n + 2)^D
#     @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)
#     for R in 0:D
#         @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥ 0.01
#         if mfd.dualkind == BarycentricDuals ||
#            (mfd.dualkind == CircumcentricDuals && mfd.use_weighted_duals)
#             @test all(>(0), get_dualvolumes(mfd, R))
#             @test minimum(get_dualvolumes(mfd, R)) /
#                   maximum(get_dualvolumes(mfd, R)) ≥ 0.01
#         end
#     end
#
#     vol = 1
#     @test all(==(1), get_volumes(mfd, 0))
#     @test sum(get_volumes(mfd, D)) ≈ vol
#     if !(sum(get_dualvolumes(mfd, 0)) ≈ vol)
#         @show extrema(get_dualvolumes(mfd, 0))
#     end
#     @test sum(get_dualvolumes(mfd, 0)) ≈ vol
#     @test all(==(1), get_dualvolumes(mfd, D))
# end

@testset "Refined simplex manifold D=$D" for D in 0:Dmax
    S = Float64
    mfd = refined_simplex_manifold(Val(D), S)
    @test invariant(mfd)
    @test nsimplices(mfd, 0) == binomial(D + 1, 1) + binomial(D + 1, 2)
    @test nsimplices(mfd, D) == 2^D
    @test get_lookup(mfd, 0, D) ≡ get_simplices(mfd, D)

    for R in 0:D
        if R == 0 || R == D
            # <https://en.wikipedia.org/wiki/Simplex#Volume>
            vol = sqrt(S(R + 1) / 2^R) / (factorial(R) * 2^R)
            @test all(≈(vol), get_volumes(mfd, R))
        end
        if mfd.dualkind == BarycentricDuals || D ≤ 3
            @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥
                  0.01
        end
        if mfd.dualkind == BarycentricDuals || (D ≤ 4 &&
            mfd.dualkind == CircumcentricDuals &&
            mfd.use_weighted_duals)
            @test all(>(0), get_dualvolumes(mfd, R))
            if D ≤ 3
                @test minimum(get_dualvolumes(mfd, R)) /
                      maximum(get_dualvolumes(mfd, R)) ≥ 0.01
            end
        end
    end
    # <https://en.wikipedia.org/wiki/Simplex#Volume>
    vol = sqrt(S(D + 1) / 2^D) / factorial(D)
    @test all(==(1), get_volumes(mfd, 0))
    @test sum(get_volumes(mfd, D)) ≈ vol
    @test sum(get_dualvolumes(mfd, 0)) ≈ vol
    @test all(==(1), get_dualvolumes(mfd, D))
end

@testset "Boundary simplex manifold D=$D" for D in 0:Dmax
    S = Float64
    mfd = boundary_simplex_manifold(Val(D), S)
    @test invariant(mfd)
    for R in 0:D
        @test nsimplices(mfd, R) == binomial(D + 2, R + 1)
    end

    N = D + 2
    for i in ID{0}(1):ID{0}(N), j in (i + 1):ID{0}(N)
        @test norm(get_coords(mfd)[i] - get_coords(mfd)[j]) ≈ 1
    end

    for R in 0:D
        # <https://en.wikipedia.org/wiki/Simplex#Volume>
        vol = sqrt(S(R + 1) / 2^R) / factorial(R)
        @test all(≈(vol), get_volumes(mfd, R))
        @test minimum(get_volumes(mfd, R)) / maximum(get_volumes(mfd, R)) ≥ 0.01
        @test all(>(0), get_dualvolumes(mfd, R))
        @test minimum(get_dualvolumes(mfd, R)) /
              maximum(get_dualvolumes(mfd, R)) ≥ 0.01
    end
end


text:
########################################################################
# Asynchronous Vertical Federated Logistic Regression for Adult dataset
########################################################################
using VerFedLogistic
using Printf
using SparseArrays

# load data
filename = "adult"
Xtrain, Ytrain, Xtest, Ytest = load_data(filename)

# config
config = Dict{String, Union{Int64, Float64, String}}()
config["num_classes"] = 2
config["num_clients"] = 3
config["batch_size"] = 2837
config["learning_rate"] = 0.5
config["time_limit"] = 5.0
config["local_model"] = "mlp"

# vertically split data
Xtrain_split, Xtest_split = split_data(Xtrain, Xtest, config["num_clients"])

# initialize server
server = AsynServer(Ytrain, Ytest, config)

# initialize clients
clients = Vector{AsynClient}(undef, config["num_clients"])
for id = 1:config["num_clients"]
    ts = 0.01
    # ts = 0.01
    c = AsynClient(id, Xtrain_split[id], Xtest_split[id], ts, config)
    clients[id] = c
    # connect with server
    connect(server, c)
end

# training
vertical_lr_train(server, clients, config["time_limit"])

# evaluation
evaluation(server, clients)


text:
function get_conversion_Nd(l::LatticeDescription)
    if length(l.primitiveVectors) == 1
        # we have only x points, so add artificial y direction
        return pos -> Point2f0((pos[1], 0.)...)
    elseif length(l.primitiveVectors) == 2
        return pos -> Point2f0(pos...)
    elseif length(l.primitiveVectors) == 3
        return pos -> Point3f0(pos...)
    end
end

function positionsPlottingPerAtom(unit_cells, l::LatticeDescription)
    # gets absolute positions for plotting, including an artificial y direction if needed, per atom for easy plotting
    positions, mapping_index = positionsLattice(unit_cells, l)
    points = []
    convert_Nd = get_conversion_Nd(l)
    for x in keys(sort(l.basisAtoms))
        p = [convert_Nd(positions[x][i]) for i in 1:length(positions[x])]
        push!(points, p)
    end
    return points
end

function positionsPlotting(unit_cells, l::LatticeDescription)
    # gets absolute positions for plotting, including an artificial y direction if needed, with the ordering the same as returned by mapping
    positions, mapping_index = positionsLattice(unit_cells, l)
    convert_Nd = get_conversion_Nd(l)

    res = zeros(Point{2,Float32}, length(mappingAtoms(unit_cells)))
    for x in keys(l.basisAtoms)
        for i in 1:length(positions[x])
            res[mapping_index[x][i]] = convert_Nd(positions[x][i])
        end
    end
    return res
end

function plot_atoms!(unit_cells, l::LatticeDescription; markersize = 15)
    points = positionsPlottingPerAtom(unit_cells, l)
    colors = [:red :blue :green :yellow]

    for (p, c) in zip(points, colors)
        scatter!(p, markersize = markersize, color = c)
    end

end

function plot_density!(unit_cells, l::LatticeDescription, dens)
    points = positionsPlotting(unit_cells, l)
    cg = cgrad(:viridis)
    dens = dens ./ maximum(dens)
    scatter!(points, colormap = cg, color = dens, markersize = 100 / sqrt(length(points)))
end

function plot_density(unit_cells, l::LatticeDescription, dens)

    f = Figure()
    ax = Axis(f[1, 1])

    plot_density!(unit_cells, l, dens)
    current_axis().aspect = AxisAspect(1)

    return f
end
function plot_atoms(unit_cells, l::LatticeDescription; markersize = 15, force_2D = false)
    f = Figure()
    if length(l.primitiveVectors) < 3 || force_2D
        ax = Axis(f[1, 1])
        current_axis().aspect = AxisAspect(1)
    else
        lscene = LScene(f[1, 1], scenekw = (camera = cam3d!, raw = false))
    end
    plot_atoms!(unit_cells, l, markersize = markersize)

    return f
end

function plot_connections!(unit_cells, l::LatticeDescription, coupling::Matrix; linecolor = :grey, linewidth = 1,)
    mapping = mappingAtoms(unit_cells)
    inversemapping = Dict(value => key for (key, value) in mapping)

    x = []
    y = []
    z = []
    u = []
    v = []
    w = []
    for i in 1:size(coupling)[1]
        for j in 1:size(coupling)[1]
            if coupling[i,j] != 0
                p1, p2 = (
                    absPositionsParticle(inversemapping[i], l),
                    absPositionsParticle(inversemapping[j], l))
                if length(p1) == 1
                    push!(p1, 0, 0)
                    push!(p2, 0, 0)
                elseif length(p1) == 2
                    push!(p1, 0)
                    push!(p2, 0)
                end
                # push!(arrow_positions, p1)
                # push!(directions, p2 - p1)
                push!(x, p1[1])
                push!(y, p1[2])
                push!(z, p1[3])

                push!(u, p2[1] - p1[1])
                push!(v, p2[2] - p1[2])
                push!(w, p2[3] - p1[3])

                # push!(x, Point2f0(p1...))
                # push!(u, Point2f0((p2 - p1)...))
            end
        end
    end
    if length(l.primitiveVectors) < 3
        arrows!(x, y, u, v; linecolor = linecolor, linewidth = linewidth, arrowsize = 0.1linewidth)
    else
        arrows!(x, y, z, u, v, w; linecolor = linecolor, linewidth = linewidth, arrowsize = 0.1linewidth)
    end

    # current_axis().aspect = AxisAspect(1)

end

function plot_connections(unit_cells, l::LatticeDescription, coupling::Matrix; linecolor = :grey, linewidth = 1, markersize = 15)
    fig = plot_atoms(unit_cells, l, markersize = markersize)
    plot_connections!(unit_cells, l, coupling; linecolor = linecolor, linewidth = linewidth)
    return fig
end

max_stars_repo_name: pgunnink/LLGTools

max_issues_repo_name: pgunnink/LLGTools

max_forks_repo_name: pgunnink/LLGTools


text:
struct CGdata{T}
    r::Array{T,1}
    p::Array{T,1}
    z::Array{T,1}
    xinit::Array{T,1}#TODO remove this
    firstrun::Base.RefValue{Bool}
end

CGdata(r::AbstractArray{T},p::AbstractArray{T},z::AbstractArray{T}) where T = CGdata{T}(r,p,z, T[], Ref(true))

CGdata(size) = CGdata{Float64}(Array{Float64,1}(undef, size), Array{Float64,1}(undef, size), Array{Float64,1}(undef, size), Array{Float64,1}(undef, size), Ref(true))

function conjugategradient!(x,A,b; useasinitial=true)
    cgdata = CGdata(similar(b), similar(b), similar(b))
    if !useasinitial
        x .= 1.0
    end
    conjugategradient!(x, A, b, cgdata.r, cgdata.p, cgdata.z)
    return cgdata
end

"""
`conjugategradient!(x,A,b,r,p,Ap; tol = size(A,2)*eps(), max_iters = 10000)`

Solve `A*x==b` with the conjugate gradient method.
Uses `x` as warm start and stores solution in `x`.
`r`,`p`,`Ap` should be same size as `x` and will be changed.

Implemented as in "Matrix Compuatations" 2nd edition, Golub and Van Loan (1989)
"""
function conjugategradient!(x,A,b,r,p,Ap; tol = size(A,2)*eps(), max_iters = 10000)
    mul!(Ap, A, x)
    r .= b .- Ap
    p .= r
    rn = dot(r,r)
    iter = 1
    while true
        mul!(Ap, A, p)
        α = rn/dot(Ap,p)
        x .+= α.*p
        r .-= α.*Ap
        if norm(r) <= tol || iter >= max_iters
            break
        end
        rnold = rn
        rn = dot(r,r)
        β = rn/rnold
        #p .= r .+ β.*p
        p .*= β
        p .+= r
        iter += 1
    end
    iter == max_iters && @warn "CG reached max iterations, result may be inaccurate"
    return iter
end


text:
module MyQuadtree

export  insertOn!,
        retrieve!

include("types.jl")
include("functions/insertOn.jl")
include("functions/split.jl")
include("functions/get_index.jl")
include("functions/retrieve.jl")

trace_index_fake_object = Int64[]
trace_index = Int64[]
level = 0::Int64
max_level_quadtree = [0]
cont = 1

end


text:
const binorm = "
transformed data {
  matrix[2,2] Sigma;
  vector[2] mu;
  mu[1] <- 0.0;
  mu[2] <- 0.0;
  Sigma[1,1] <- 1.0;
  Sigma[2,2] <- 1.0;
  Sigma[1,2] <- 0.10;
  Sigma[2,1] <- 0.10;
}
parameters {
  vector[2] y;
}
model {
    y ~ multi_normal(mu,Sigma);
}
"


text:
using Distributions
using JSON

n = 3
p = 0.2
d = Binomial( n,p )

x = [ -5, -2.5, 0, 2.5, 5 ]

dmgf(t) = mgf(d, t )
y = map( dmgf, x )
println( y )

data = Dict([
	("n", n),
	("p", p),
	("data", x),
	("expected", y)
])

outfile = open("./test/fixtures/number.json", "w")
JSON.json(data)

write( outfile, JSON.json(data) )

max_stars_repo_name: distributions-io/binomial-mgf

max_issues_repo_name: distributions-io/binomial-mgf

max_forks_repo_name: distributions-io/binomial-mgf