text:
@testset "6.5.3 Hyperbolic secant functions" begin
    (a, b, c, d, n, p, x, ) = @variables a b c d n p x

    #= ::Package:: =#

    #= ::Title:: =#
    #=Integration*Problems*Involving*Hyperbolic*Secants=#

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(c*sech(a+b*x))^n=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*sech(a+b*x)^n=#

    @test_int [sech(a + b*x), x, 1, atan(sinh(a + b*x))/b]
    @test_int [sech(a + b*x)^2, x, 2, tanh(a + b*x)/b]
    @test_int [sech(a + b*x)^3, x, 2, atan(sinh(a + b*x))/(2*b) + (sech(a + b*x)*tanh(a + b*x))/(2*b)]
    @test_int [sech(a + b*x)^4, x, 2, tanh(a + b*x)/b - tanh(a + b*x)^3/(3*b)]
    @test_int [sech(a + b*x)^5, x, 3, (3*atan(sinh(a + b*x)))/(8*b) + (3*sech(a + b*x)*tanh(a + b*x))/(8*b) + (sech(a + b*x)^3*tanh(a + b*x))/(4*b)]
    @test_int [sech(a + b*x)^6, x, 2, tanh(a + b*x)/b - (2*tanh(a + b*x)^3)/(3*b) + tanh(a + b*x)^5/(5*b)]

    @test_int [sech(7*x)^4, x, 2, (1/7)*tanh(7*x) - (1/21)*tanh(7*x)^3]

    @test_int [sech(pi*x)^6, x, 2, tanh(pi*x)/pi - (2*tanh(pi*x)^3)/(3*pi) + tanh(pi*x)^5/(5*pi)]

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

    @test_int [sech(a + b*x)^(5/2), x, 3, -((2*im*sqrt(cosh(a + b*x))*Elliptic.F((1/2)*im*(a + b*x), 2)*sqrt(sech(a + b*x)))/(3*b)) + (2*sech(a + b*x)^(3/2)*sinh(a + b*x))/(3*b)]
    @test_int [sech(a + b*x)^(3/2), x, 3, (2*im*sqrt(cosh(a + b*x))*Elliptic.E((1/2)*im*(a + b*x), 2)*sqrt(sech(a + b*x)))/b + (2*sqrt(sech(a + b*x))*sinh(a + b*x))/b]
    @test_int [sech(a + b*x)^(1/2), x, 2, -((2*im*sqrt(cosh(a + b*x))*Elliptic.F((1/2)*im*(a + b*x), 2)*sqrt(sech(a + b*x)))/b)]
    @test_int [1/sech(a + b*x)^(1/2), x, 2, -((2*im*sqrt(cosh(a + b*x))*Elliptic.E((1/2)*im*(a + b*x), 2)*sqrt(sech(a + b*x)))/b)]
    @test_int [1/sech(a + b*x)^(3/2), x, 3, -((2*im*sqrt(cosh(a + b*x))*Elliptic.F((1/2)*im*(a + b*x), 2)*sqrt(sech(a + b*x)))/(3*b)) + (2*sinh(a + b*x))/(3*b*sqrt(sech(a + b*x)))]
    @test_int [1/sech(a + b*x)^(5/2), x, 3, -((6*im*sqrt(cosh(a + b*x))*Elliptic.E((1/2)*im*(a + b*x), 2)*sqrt(sech(a + b*x)))/(5*b)) + (2*sinh(a + b*x))/(5*b*sech(a + b*x)^(3/2))]

    @test_int [(b*sech(c + d*x))^(7/2), x, 4, (6*im*b^4*Elliptic.E((1/2)*im*(c + d*x), 2))/(5*d*sqrt(cosh(c + d*x))*sqrt(b*sech(c + d*x))) + (6*b^3*sqrt(b*sech(c + d*x))*sinh(c + d*x))/(5*d) + (2*b*(b*sech(c + d*x))^(5/2)*sinh(c + d*x))/(5*d)]
    @test_int [(b*sech(c + d*x))^(5/2), x, 3, -((2*im*b^2*sqrt(cosh(c + d*x))*Elliptic.F((1/2)*im*(c + d*x), 2)*sqrt(b*sech(c + d*x)))/(3*d)) + (2*b*(b*sech(c + d*x))^(3/2)*sinh(c + d*x))/(3*d)]
    @test_int [(b*sech(c + d*x))^(3/2), x, 3, (2*im*b^2*Elliptic.E((1/2)*im*(c + d*x), 2))/(d*sqrt(cosh(c + d*x))*sqrt(b*sech(c + d*x))) + (2*b*sqrt(b*sech(c + d*x))*sinh(c + d*x))/d]
    @test_int [(b*sech(c + d*x))^(1/2), x, 2, -((2*im*sqrt(cosh(c + d*x))*Elliptic.F((1/2)*im*(c + d*x), 2)*sqrt(b*sech(c + d*x)))/d)]
    @test_int [1/(b*sech(c + d*x))^(1/2), x, 2, -((2*im*Elliptic.E((1/2)*im*(c + d*x), 2))/(d*sqrt(cosh(c + d*x))*sqrt(b*sech(c + d*x))))]
    @test_int [1/(b*sech(c + d*x))^(3/2), x, 3, -((2*im*sqrt(cosh(c + d*x))*Elliptic.F((1/2)*im*(c + d*x), 2)*sqrt(b*sech(c + d*x)))/(3*b^2*d)) + (2*sinh(c + d*x))/(3*b*d*sqrt(b*sech(c + d*x)))]
    @test_int [1/(b*sech(c + d*x))^(5/2), x, 3, -((6*im*Elliptic.E((1/2)*im*(c + d*x), 2))/(5*b^2*d*sqrt(cosh(c + d*x))*sqrt(b*sech(c + d*x)))) + (2*sinh(c + d*x))/(5*b*d*(b*sech(c + d*x))^(3/2))]
    @test_int [1/(b*sech(c + d*x))^(7/2), x, 4, -((10*im*sqrt(cosh(c + d*x))*Elliptic.F((1/2)*im*(c + d*x), 2)*sqrt(b*sech(c + d*x)))/(21*b^4*d)) + (2*sinh(c + d*x))/(7*b*d*(b*sech(c + d*x))^(5/2)) + (10*sinh(c + d*x))/(21*b^3*d*sqrt(b*sech(c + d*x)))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(c*sech(a+b*x))^n*with*n*symbolic=#

    @test_int [(b*sech(c + d*x))^n, x, 2, -((b*HypergeometricFunctions._₂F₁(1/2, (1 - n)/2, (3 - n)/2, cosh(c + d*x)^2)*(b*sech(c + d*x))^(-1 + n)*sinh(c + d*x))/(d*(1 - n)*sqrt(-sinh(c + d*x)^2)))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*(c*sech(a+b*x)^m)^n=#

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

    @test_int [(sech(a + b*x)^2)^(7/2), x, 5, (5*asin(tanh(a + b*x)))/(16*b) + (5*sqrt(sech(a + b*x)^2)*tanh(a + b*x))/(16*b) + (5*(sech(a + b*x)^2)^(3/2)*tanh(a + b*x))/(24*b) + ((sech(a + b*x)^2)^(5/2)*tanh(a + b*x))/(6*b)]
    @test_int [(sech(a + b*x)^2)^(5/2), x, 4, (3*asin(tanh(a + b*x)))/(8*b) + (3*sqrt(sech(a + b*x)^2)*tanh(a + b*x))/(8*b) + ((sech(a + b*x)^2)^(3/2)*tanh(a + b*x))/(4*b)]
    @test_int [(sech(a + b*x)^2)^(3/2), x, 3, asin(tanh(a + b*x))/(b*2) + (sqrt(sech(a + b*x)^2)*tanh(a + b*x))/(2*b)]
    @test_int [(sech(a + b*x)^2)^(1/2), x, 2, asin(tanh(a + b*x))/b]
    @test_int [1/(sech(a + b*x)^2)^(1/2), x, 2, tanh(a + b*x)/(b*sqrt(sech(a + b*x)^2))]
    @test_int [1/(sech(a + b*x)^2)^(3/2), x, 3, tanh(a + b*x)/(3*b*(sech(a + b*x)^2)^(3/2)) + (2*tanh(a + b*x))/(3*b*sqrt(sech(a + b*x)^2))]
    @test_int [1/(sech(a + b*x)^2)^(5/2), x, 4, tanh(a + b*x)/(5*b*(sech(a + b*x)^2)^(5/2)) + (4*tanh(a + b*x))/(15*b*(sech(a + b*x)^2)^(3/2)) + (8*tanh(a + b*x))/(15*b*sqrt(sech(a + b*x)^2))]
    @test_int [1/(sech(a + b*x)^2)^(7/2), x, 5, tanh(a + b*x)/(7*b*(sech(a + b*x)^2)^(7/2)) + (6*tanh(a + b*x))/(35*b*(sech(a + b*x)^2)^(5/2)) + (8*tanh(a + b*x))/(35*b*(sech(a + b*x)^2)^(3/2)) + (16*tanh(a + b*x))/(35*b*sqrt(sech(a + b*x)^2))]

    @test_int [(a*sech(x)^2)^(5/2), x, 5, (3/8)*a^(5/2)*atan((sqrt(a)*tanh(x))/sqrt(a*sech(x)^2)) + (3/8)*a^2*sqrt(a*sech(x)^2)*tanh(x) + (1/4)*a*(a*sech(x)^2)^(3/2)*tanh(x)]
    @test_int [(a*sech(x)^2)^(3/2), x, 4, (1/2)*a^(3/2)*atan((sqrt(a)*tanh(x))/sqrt(a*sech(x)^2)) + (1/2)*a*sqrt(a*sech(x)^2)*tanh(x)]
    @test_int [(a*sech(x)^2)^(1/2), x, 3, sqrt(a)*atan((sqrt(a)*tanh(x))/sqrt(a*sech(x)^2))]
    @test_int [1/(a*sech(x)^2)^(1/2), x, 2, tanh(x)/sqrt(a*sech(x)^2)]
    @test_int [1/(a*sech(x)^2)^(3/2), x, 3, tanh(x)/(3*(a*sech(x)^2)^(3/2)) + (2*tanh(x))/(3*a*sqrt(a*sech(x)^2))]
    @test_int [1/(a*sech(x)^2)^(5/2), x, 4, tanh(x)/(5*(a*sech(x)^2)^(5/2)) + (4*tanh(x))/(15*a*(a*sech(x)^2)^(3/2)) + (8*tanh(x))/(15*a^2*sqrt(a*sech(x)^2))]
    @test_int [1/(a*sech(x)^2)^(7/2), x, 5, tanh(x)/(7*(a*sech(x)^2)^(7/2)) + (6*tanh(x))/(35*a*(a*sech(x)^2)^(5/2)) + (8*tanh(x))/(35*a^2*(a*sech(x)^2)^(3/2)) + (16*tanh(x))/(35*a^3*sqrt(a*sech(x)^2))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(c*sech(a+b*x)^3)^n=#

    @test_int [(a*sech(x)^3)^(5/2), x, 7, (154/195)*im*a^2*cosh(x)^(3/2)*Elliptic.E((im*x)/2, 2)*sqrt(a*sech(x)^3) + (154/195)*a^2*cosh(x)*sqrt(a*sech(x)^3)*sinh(x) + (154/585)*a^2*sqrt(a*sech(x)^3)*tanh(x) + (22/117)*a^2*sech(x)^2*sqrt(a*sech(x)^3)*tanh(x) + (2/13)*a^2*sech(x)^4*sqrt(a*sech(x)^3)*tanh(x)]
    @test_int [(a*sech(x)^3)^(3/2), x, 5, (-(10/21))*im*a*cosh(x)^(3/2)*Elliptic.F((im*x)/2, 2)*sqrt(a*sech(x)^3) + (10/21)*a*sqrt(a*sech(x)^3)*sinh(x) + (2/7)*a*sech(x)*sqrt(a*sech(x)^3)*tanh(x)]
    @test_int [(a*sech(x)^3)^(1/2), x, 4, 2*im*cosh(x)^(3/2)*Elliptic.E((im*x)/2, 2)*sqrt(a*sech(x)^3) + 2*cosh(x)*sqrt(a*sech(x)^3)*sinh(x)]
    @test_int [1/(a*sech(x)^3)^(1/2), x, 4, -((2*im*Elliptic.F((im*x)/2, 2))/(3*cosh(x)^(3/2)*sqrt(a*sech(x)^3))) + (2*tanh(x))/(3*sqrt(a*sech(x)^3))]
    @test_int [1/(a*sech(x)^3)^(3/2), x, 5, -((14*im*Elliptic.E((im*x)/2, 2))/(15*a*cosh(x)^(3/2)*sqrt(a*sech(x)^3))) + (14*sinh(x))/(45*a*sqrt(a*sech(x)^3)) + (2*cosh(x)^2*sinh(x))/(9*a*sqrt(a*sech(x)^3))]
    @test_int [1/(a*sech(x)^3)^(5/2), x, 7, -((26*im*Elliptic.F((im*x)/2, 2))/(77*a^2*cosh(x)^(3/2)*sqrt(a*sech(x)^3))) + (78*cosh(x)*sinh(x))/(385*a^2*sqrt(a*sech(x)^3)) + (26*cosh(x)^3*sinh(x))/(165*a^2*sqrt(a*sech(x)^3)) + (2*cosh(x)^5*sinh(x))/(15*a^2*sqrt(a*sech(x)^3)) + (26*tanh(x))/(77*a^2*sqrt(a*sech(x)^3))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*(c*sech(a+b*x)^4)^n=#

    @test_int [(a*sech(x)^4)^(7/2), x, 3, a^3*cosh(x)*sqrt(a*sech(x)^4)*sinh(x) - 2*a^3*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x) + 3*a^3*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^3 - (20/7)*a^3*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^5 + (5/3)*a^3*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^7 - (6/11)*a^3*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^9 + (1/13)*a^3*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^11]
    @test_int [(a*sech(x)^4)^(5/2), x, 3, a^2*cosh(x)*sqrt(a*sech(x)^4)*sinh(x) - (4/3)*a^2*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x) + (6/5)*a^2*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^3 - (4/7)*a^2*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^5 + (1/9)*a^2*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^7]
    @test_int [(a*sech(x)^4)^(3/2), x, 3, a*cosh(x)*sqrt(a*sech(x)^4)*sinh(x) - (2/3)*a*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x) + (1/5)*a*sqrt(a*sech(x)^4)*sinh(x)^2*tanh(x)^3]
    @test_int [(a*sech(x)^4)^(1/2), x, 3, cosh(x)*sqrt(a*sech(x)^4)*sinh(x)]
    @test_int [1/(a*sech(x)^4)^(1/2), x, 3, (x*sech(x)^2)/(2*sqrt(a*sech(x)^4)) + tanh(x)/(2*sqrt(a*sech(x)^4))]
    @test_int [1/(a*sech(x)^4)^(3/2), x, 5, (5*x*sech(x)^2)/(16*a*sqrt(a*sech(x)^4)) + (5*cosh(x)*sinh(x))/(24*a*sqrt(a*sech(x)^4)) + (cosh(x)^3*sinh(x))/(6*a*sqrt(a*sech(x)^4)) + (5*tanh(x))/(16*a*sqrt(a*sech(x)^4))]
    @test_int [1/(a*sech(x)^4)^(5/2), x, 7, (63*x*sech(x)^2)/(256*a^2*sqrt(a*sech(x)^4)) + (21*cosh(x)*sinh(x))/(128*a^2*sqrt(a*sech(x)^4)) + (21*cosh(x)^3*sinh(x))/(160*a^2*sqrt(a*sech(x)^4)) + (9*cosh(x)^5*sinh(x))/(80*a^2*sqrt(a*sech(x)^4)) + (cosh(x)^7*sinh(x))/(10*a^2*sqrt(a*sech(x)^4)) + (63*tanh(x))/(256*a^2*sqrt(a*sech(x)^4))]

    #= ::Subsection:: =#
    #=Integrands*of*the*form*(c*sech(a+b*x)^m)^n=#

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*Hyper(c+d*x)^m*(a+b*sech(c+d*x))^n=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*sinh(c+d*x)^m*(a+b*sech(c+d*x))^n=#

    #= ::Subsubsection::Closed:: =#
    #=a^2-b^2=0=#

    @test_int [sinh(x)^4/(a + a*sech(x)), x, 7, -(x/(8*a)) - (cosh(x)*sinh(x))/(8*a) + (cosh(x)^3*sinh(x))/(4*a) - sinh(x)^3/(3*a)]
    @test_int [sinh(x)^3/(a + a*sech(x)), x, 6, cosh(x)^3/(3*a) - sinh(x)^2/(2*a)]
    @test_int [sinh(x)^2/(a + a*sech(x)), x, 5, x/(2*a) - sinh(x)/a + (cosh(x)*sinh(x))/(2*a)]
    @test_int [sinh(x)^1/(a + a*sech(x)), x, 5, cosh(x)/a - log(1 + cosh(x))/a]
    @test_int [csch(x)^1/(a + a*sech(x)), x, 6, -(atanh(cosh(x))/(2*a)) - (coth(x)*csch(x))/(2*a) + csch(x)^2/(2*a)]
    @test_int [csch(x)^2/(a + a*sech(x)), x, 6, -(coth(x)^3/(3*a)) + csch(x)^3/(3*a)]
    @test_int [csch(x)^3/(a + a*sech(x)), x, 7, atanh(cosh(x))/(8*a) - (coth(x)*csch(x))/(8*a) - (coth(x)*csch(x)^3)/(4*a) + csch(x)^4/(4*a)]
    @test_int [csch(x)^4/(a + a*sech(x)), x, 7, coth(x)^3/(3*a) - coth(x)^5/(5*a) + csch(x)^5/(5*a)]

    #= ::Subsubsection::Closed:: =#
    #=a^2-b^2!=0=#

    @test_int [sinh(x)^4/(a + b*sech(x)), x, 6, ((3*a^4 - 12*a^2*b^2 + 8*b^4)*x)/(8*a^5) - (2*(a - b)^(3/2)*b*(a + b)^(3/2)*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/a^5 + ((8*b*(a^2 - b^2) - a*(3*a^2 - 4*b^2)*cosh(x))*sinh(x))/(8*a^4) - ((4*b - 3*a*cosh(x))*sinh(x)^3)/(12*a^2)]
    @test_int [sinh(x)^3/(a + b*sech(x)), x, 5, -(((a^2 - b^2)*cosh(x))/a^3) - (b*cosh(x)^2)/(2*a^2) + cosh(x)^3/(3*a) + (b*(a^2 - b^2)*log(b + a*cosh(x)))/a^4]
    @test_int [sinh(x)^2/(a + b*sech(x)), x, 5, -(((a^2 - 2*b^2)*x)/(2*a^3)) + (2*sqrt(a - b)*b*sqrt(a + b)*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/a^3 - ((2*b - a*cosh(x))*sinh(x))/(2*a^2)]
    @test_int [sinh(x)^1/(a + b*sech(x)), x, 5, cosh(x)/a - (b*log(b + a*cosh(x)))/a^2]
    @test_int [csch(x)^1/(a + b*sech(x)), x, 4, log(1 - cosh(x))/(2*(a + b)) - log(1 + cosh(x))/(2*(a - b)) + (b*log(b + a*cosh(x)))/(a^2 - b^2)]
    @test_int [csch(x)^2/(a + b*sech(x)), x, 5, (2*a*b*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/((a - b)^(3/2)*(a + b)^(3/2)) + ((b - a*cosh(x))*csch(x))/(a^2 - b^2)]
    @test_int [csch(x)^3/(a + b*sech(x)), x, 6, ((b - a*cosh(x))*csch(x)^2)/(2*(a^2 - b^2)) - (a*log(1 - cosh(x)))/(4*(a + b)^2) + (a*log(1 + cosh(x)))/(4*(a - b)^2) - (a^2*b*log(b + a*cosh(x)))/(a^2 - b^2)^2]
    @test_int [csch(x)^4/(a + b*sech(x)), x, 6, -((2*a^3*b*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/((a - b)^(5/2)*(a + b)^(5/2))) - ((3*a^2*b - a*(2*a^2 + b^2)*cosh(x))*csch(x))/(3*(a^2 - b^2)^2) + ((b - a*cosh(x))*csch(x)^3)/(3*(a^2 - b^2))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*cosh(c+d*x)^m*(a+b*sech(c+d*x))^n=#

    #= ::Subsubsection::Closed:: =#
    #=a^2-b^2=0=#

    @test_int [cosh(x)^4/(a + a*sech(x)), x, 7, (15*x)/(8*a) - (4*sinh(x))/a + (15*cosh(x)*sinh(x))/(8*a) + (5*cosh(x)^3*sinh(x))/(4*a) - (cosh(x)^3*sinh(x))/(a + a*sech(x)) - (4*sinh(x)^3)/(3*a)]
    @test_int [cosh(x)^3/(a + a*sech(x)), x, 6, -((3*x)/(2*a)) + (4*sinh(x))/a - (3*cosh(x)*sinh(x))/(2*a) - (cosh(x)^2*sinh(x))/(a + a*sech(x)) + (4*sinh(x)^3)/(3*a)]
    @test_int [cosh(x)^2/(a + a*sech(x)), x, 5, (3*x)/(2*a) - (2*sinh(x))/a + (3*cosh(x)*sinh(x))/(2*a) - (cosh(x)*sinh(x))/(a + a*sech(x))]
    @test_int [cosh(x)^1/(a + a*sech(x)), x, 4, -(x/a) + (2*sinh(x))/a - sinh(x)/(a + a*sech(x))]
    @test_int [sech(x)^1/(a + a*sech(x)), x, 1, tanh(x)/(a + a*sech(x))]
    @test_int [sech(x)^2/(a + a*sech(x)), x, 3, atan(sinh(x))/a - tanh(x)/(a + a*sech(x))]
    @test_int [sech(x)^3/(a + a*sech(x)), x, 4, -(atan(sinh(x))/a) + tanh(x)/a + tanh(x)/(a + a*sech(x))]
    @test_int [sech(x)^4/(a + a*sech(x)), x, 6, (3*atan(sinh(x)))/(2*a) - (2*tanh(x))/a + (3*sech(x)*tanh(x))/(2*a) - (sech(x)^2*tanh(x))/(a + a*sech(x))]

    @test_int [1/(a + a*sech(c + d*x)), x, 2, x/a - tanh(c + d*x)/(d*(a + a*sech(c + d*x)))]

    @test_int [1/(a - a*sech(c + d*x)), x, 2, x/a - tanh(c + d*x)/(d*(a - a*sech(c + d*x)))]

    @test_int [(a + a*sech(c + d*x))^(5/2), x, 5, (2*a^(5/2)*atanh((sqrt(a)*tanh(c + d*x))/sqrt(a + a*sech(c + d*x))))/d + (14*a^3*tanh(c + d*x))/(3*d*sqrt(a + a*sech(c + d*x))) + (2*a^2*sqrt(a + a*sech(c + d*x))*tanh(c + d*x))/(3*d)]
    @test_int [(a + a*sech(c + d*x))^(3/2), x, 4, (2*a^(3/2)*atanh((sqrt(a)*tanh(c + d*x))/sqrt(a + a*sech(c + d*x))))/d + (2*a^2*tanh(c + d*x))/(d*sqrt(a + a*sech(c + d*x)))]
    @test_int [(a + a*sech(c + d*x))^(1/2), x, 2, (2*sqrt(a)*atanh((sqrt(a)*tanh(c + d*x))/sqrt(a + a*sech(c + d*x))))/d]
    @test_int [1/(a + a*sech(c + d*x))^(1/2), x, 5, (2*atanh((sqrt(a)*tanh(c + d*x))/sqrt(a + a*sech(c + d*x))))/(sqrt(a)*d) - (sqrt(2)*atanh((sqrt(a)*tanh(c + d*x))/(sqrt(2)*sqrt(a + a*sech(c + d*x)))))/(sqrt(a)*d)]
    @test_int [1/(a + a*sech(c + d*x))^(3/2), x, 6, (2*atanh((sqrt(a)*tanh(c + d*x))/sqrt(a + a*sech(c + d*x))))/(a^(3/2)*d) - (5*atanh((sqrt(a)*tanh(c + d*x))/(sqrt(2)*sqrt(a + a*sech(c + d*x)))))/(2*sqrt(2)*a^(3/2)*d) - tanh(c + d*x)/(2*d*(a + a*sech(c + d*x))^(3/2))]

    @test_int [sqrt(a - a*sech(c + d*x)), x, 2, (2*sqrt(a)*atanh((sqrt(a)*tanh(c + d*x))/sqrt(a - a*sech(c + d*x))))/d]
    @test_int [1/sqrt(a - a*sech(c + d*x)), x, 5, (2*atanh((sqrt(a)*tanh(c + d*x))/sqrt(a - a*sech(c + d*x))))/(sqrt(a)*d) - (sqrt(2)*atanh((sqrt(a)*tanh(c + d*x))/(sqrt(2)*sqrt(a - a*sech(c + d*x)))))/(sqrt(a)*d)]

    @test_int [sqrt(3 + 3*sech(x)), x, 2, 2*sqrt(3)*atanh(tanh(x)/sqrt(1 + sech(x)))]
    @test_int [sqrt(3 - 3*sech(x)), x, 2, 2*sqrt(3)*atanh(tanh(x)/sqrt(1 - sech(x)))]

    #= ::Subsubsection::Closed:: =#
    #=a^2-b^2!=0=#

    @test_int [(a + b*sech(c + d*x))^4, x, 6, a^4*x + (2*a*b*(2*a^2 + b^2)*atan(sinh(c + d*x)))/d + (b^2*(17*a^2 + 2*b^2)*tanh(c + d*x))/(3*d) + (4*a*b^3*sech(c + d*x)*tanh(c + d*x))/(3*d) + (b^2*(a + b*sech(c + d*x))^2*tanh(c + d*x))/(3*d)]
    @test_int [(a + b*sech(c + d*x))^3, x, 5, a^3*x + (b*(6*a^2 + b^2)*atan(sinh(c + d*x)))/(2*d) + (5*a*b^2*tanh(c + d*x))/(2*d) + (b^2*(a + b*sech(c + d*x))*tanh(c + d*x))/(2*d)]
    @test_int [(a + b*sech(c + d*x))^2, x, 4, a^2*x + (2*a*b*atan(sinh(c + d*x)))/d + (b^2*tanh(c + d*x))/d]
    @test_int [(a + b*sech(c + d*x))^1, x, 2, a*x + (b*atan(sinh(c + d*x)))/d]
    @test_int [1/(a + b*sech(c + d*x))^1, x, 3, x/a - (2*b*atan((sqrt(a - b)*tanh((1/2)*(c + d*x)))/sqrt(a + b)))/(a*sqrt(a - b)*sqrt(a + b)*d)]
    @test_int [1/(a + b*sech(c + d*x))^2, x, 5, x/a^2 - (2*b*(2*a^2 - b^2)*atan((sqrt(a - b)*tanh((1/2)*(c + d*x)))/sqrt(a + b)))/(a^2*(a - b)^(3/2)*(a + b)^(3/2)*d) + (b^2*tanh(c + d*x))/(a*(a^2 - b^2)*d*(a + b*sech(c + d*x)))]
    @test_int [1/(a + b*sech(c + d*x))^3, x, 6, x/a^3 - (b*(6*a^4 - 5*a^2*b^2 + 2*b^4)*atan((sqrt(a - b)*tanh((1/2)*(c + d*x)))/sqrt(a + b)))/(a^3*(a - b)^(5/2)*(a + b)^(5/2)*d) + (b^2*tanh(c + d*x))/(2*a*(a^2 - b^2)*d*(a + b*sech(c + d*x))^2) + (b^2*(5*a^2 - 2*b^2)*tanh(c + d*x))/(2*a^2*(a^2 - b^2)^2*d*(a + b*sech(c + d*x)))]

    @test_int [1/sqrt(a + b*sech(c + d*x)), x, 1, (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*d)]

    @test_int [cosh(x)^4/(a + b*sech(x)), x, 8, ((3*a^4 + 4*a^2*b^2 + 8*b^4)*x)/(8*a^5) - (2*b^5*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a^5*sqrt(a - b)*sqrt(a + b)) - (b*(2*a^2 + 3*b^2)*sinh(x))/(3*a^4) + ((3*a^2 + 4*b^2)*cosh(x)*sinh(x))/(8*a^3) - (b*cosh(x)^2*sinh(x))/(3*a^2) + (cosh(x)^3*sinh(x))/(4*a)]
    @test_int [cosh(x)^3/(a + b*sech(x)), x, 7, -((b*(a^2 + 2*b^2)*x)/(2*a^4)) + (2*b^4*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a^4*sqrt(a - b)*sqrt(a + b)) + ((2*a^2 + 3*b^2)*sinh(x))/(3*a^3) - (b*cosh(x)*sinh(x))/(2*a^2) + (cosh(x)^2*sinh(x))/(3*a)]
    @test_int [cosh(x)^2/(a + b*sech(x)), x, 6, ((a^2 + 2*b^2)*x)/(2*a^3) - (2*b^3*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a^3*sqrt(a - b)*sqrt(a + b)) - (b*sinh(x))/a^2 + (cosh(x)*sinh(x))/(2*a)]
    @test_int [cosh(x)^1/(a + b*sech(x)), x, 5, -((b*x)/a^2) + (2*b^2*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a^2*sqrt(a - b)*sqrt(a + b)) + sinh(x)/a]
    @test_int [sech(x)^1/(a + b*sech(x)), x, 3, (2*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(sqrt(a - b)*sqrt(a + b))]
    @test_int [sech(x)^2/(a + b*sech(x)), x, 5, atan(sinh(x))/b - (2*a*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(sqrt(a - b)*b*sqrt(a + b))]
    @test_int [sech(x)^3/(a + b*sech(x)), x, 6, -((a*atan(sinh(x)))/b^2) + (2*a^2*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(sqrt(a - b)*b^2*sqrt(a + b)) + tanh(x)/b]
    @test_int [sech(x)^4/(a + b*sech(x)), x, 7, ((2*a^2 + b^2)*atan(sinh(x)))/(2*b^3) - (2*a^3*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(sqrt(a - b)*b^3*sqrt(a + b)) - (a*tanh(x))/b^2 + (sech(x)*tanh(x))/(2*b)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*tanh(c+d*x)^m*(a+b*sech(c+d*x))^n*when*a^2-b^2=0=#

    #= ::Subsubsection:: =#
    #=n>0=#

    #= ::Subsubsection::Closed:: =#
    #=n<0=#

    @test_int [tanh(x)^6/(a + a*sech(x)), x, 5, x/a - (3*atan(sinh(x)))/(8*a) - ((8 - 3*sech(x))*tanh(x))/(8*a) - ((4 - 3*sech(x))*tanh(x)^3)/(12*a)]
    @test_int [tanh(x)^5/(a + a*sech(x)), x, 3, log(cosh(x))/a + sech(x)/a + sech(x)^2/(2*a) - sech(x)^3/(3*a)]
    @test_int [tanh(x)^4/(a + a*sech(x)), x, 4, x/a - atan(sinh(x))/(2*a) - ((2 - sech(x))*tanh(x))/(2*a)]
    @test_int [tanh(x)^3/(a + a*sech(x)), x, 3, log(cosh(x))/a + sech(x)/a]
    @test_int [tanh(x)^2/(a + a*sech(x)), x, 3, x/a - atan(sinh(x))/a]
    @test_int [tanh(x)^1/(a + a*sech(x)), x, 2, log(1 + cosh(x))/a]
    @test_int [coth(x)^1/(a + a*sech(x)), x, 3, 1/(2*a*(1 + cosh(x))) + log(1 - cosh(x))/(4*a) + (3*log(1 + cosh(x)))/(4*a)]
    @test_int [coth(x)^2/(a + a*sech(x)), x, 4, x/a - (coth(x)*(3 - 2*sech(x)))/(3*a) - (coth(x)^3*(1 - sech(x)))/(3*a)]
    @test_int [coth(x)^3/(a + a*sech(x)), x, 3, 1/(8*a*(1 - cosh(x))) - 1/(8*a*(1 + cosh(x))^2) + 3/(4*a*(1 + cosh(x))) + (5*log(1 - cosh(x)))/(16*a) + (11*log(1 + cosh(x)))/(16*a)]
    @test_int [coth(x)^4/(a + a*sech(x)), x, 5, x/a - (coth(x)*(15 - 8*sech(x)))/(15*a) - (coth(x)^3*(5 - 4*sech(x)))/(15*a) - (coth(x)^5*(1 - sech(x)))/(5*a)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*tanh(c+d*x)^m*(a+b*sech(c+d*x))^n=#

    #= ::Subsubsection:: =#
    #=n>0=#

    #= ::Subsubsection::Closed:: =#
    #=n<0=#

    @test_int [tanh(x)^7/(a + b*sech(x)), x, 3, log(cosh(x))/a - ((a^2 - b^2)^3*log(a + b*sech(x)))/(a*b^6) + ((a^4 - 3*a^2*b^2 + 3*b^4)*sech(x))/b^5 - (a*(a^2 - 3*b^2)*sech(x)^2)/(2*b^4) + ((a^2 - 3*b^2)*sech(x)^3)/(3*b^3) - (a*sech(x)^4)/(4*b^2) + sech(x)^5/(5*b)]
    @test_int [tanh(x)^6/(a + b*sech(x)), x, 15, x/a - (3*atan(sinh(x)))/(8*b) - ((a^2 - 3*b^2)*atan(sinh(x)))/(2*b^3) - ((a^4 - 3*a^2*b^2 + 3*b^4)*atan(sinh(x)))/b^5 + (2*(a - b)^(5/2)*(a + b)^(5/2)*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a*b^5) + (a*tanh(x))/b^2 + (a*(a^2 - 3*b^2)*tanh(x))/b^4 - (3*sech(x)*tanh(x))/(8*b) - ((a^2 - 3*b^2)*sech(x)*tanh(x))/(2*b^3) - (sech(x)^3*tanh(x))/(4*b) - (a*tanh(x)^3)/(3*b^2)]
    @test_int [tanh(x)^5/(a + b*sech(x)), x, 3, log(cosh(x))/a + ((a^2 - b^2)^2*log(a + b*sech(x)))/(a*b^4) - ((a^2 - 2*b^2)*sech(x))/b^3 + (a*sech(x)^2)/(2*b^2) - sech(x)^3/(3*b)]
    @test_int [tanh(x)^4/(a + b*sech(x)), x, 6, x/a + ((2*a^2 - 3*b^2)*atan(sinh(x)))/(2*b^3) - (2*(a - b)^(3/2)*(a + b)^(3/2)*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a*b^3) - (a*tanh(x))/b^2 + (sech(x)*tanh(x))/(2*b)]
    @test_int [tanh(x)^3/(a + b*sech(x)), x, 3, log(cosh(x))/a + ((1 - a^2/b^2)*log(a + b*sech(x)))/a + sech(x)/b]
    @test_int [tanh(x)^2/(a + b*sech(x)), x, 7, x/a - atan(sinh(x))/b + (2*sqrt(a - b)*sqrt(a + b)*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a*b)]
    @test_int [tanh(x)^1/(a + b*sech(x)), x, 4, log(cosh(x))/a + log(a + b*sech(x))/a]
    @test_int [coth(x)^1/(a + b*sech(x)), x, 3, log(cosh(x))/a + log(1 - sech(x))/(2*(a + b)) + log(1 + sech(x))/(2*(a - b)) - (b^2*log(a + b*sech(x)))/(a*(a^2 - b^2))]
    @test_int [coth(x)^2/(a + b*sech(x)), x, 9, (a*x)/(a^2 - b^2) - (b^2*x)/(a*(a^2 - b^2)) + (2*b^3*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a*(a - b)^(3/2)*(a + b)^(3/2)) - (a*coth(x))/(a^2 - b^2) + (b*csch(x))/(a^2 - b^2)]
    @test_int [coth(x)^3/(a + b*sech(x)), x, 3, log(cosh(x))/a + ((2*a + 3*b)*log(1 - sech(x)))/(4*(a + b)^2) + ((2*a - 3*b)*log(1 + sech(x)))/(4*(a - b)^2) + (b^4*log(a + b*sech(x)))/(a*(a^2 - b^2)^2) - 1/(4*(a + b)*(1 - sech(x))) - 1/(4*(a - b)*(1 + sech(x)))]
    @test_int [coth(x)^4/(a + b*sech(x)), x, 15, -((a*b^2*x)/(a^2 - b^2)^2) + (b^4*x)/(a*(a^2 - b^2)^2) + (a*x)/(a^2 - b^2) - (2*b^5*atan((sqrt(a - b)*tanh(x/2))/sqrt(a + b)))/(a*(a - b)^(5/2)*(a + b)^(5/2)) + (a*b^2*coth(x))/(a^2 - b^2)^2 - (a*coth(x))/(a^2 - b^2) - (a*coth(x)^3)/(3*(a^2 - b^2)) - (b^3*csch(x))/(a^2 - b^2)^2 + (b*csch(x))/(a^2 - b^2) + (b*csch(x)^3)/(3*(a^2 - b^2))]
    @test_int [coth(x)^5/(a + b*sech(x)), x, 3, log(cosh(x))/a + ((8*a^2 + 21*a*b + 15*b^2)*log(1 - sech(x)))/(16*(a + b)^3) + ((8*a^2 - 21*a*b + 15*b^2)*log(1 + sech(x)))/(16*(a - b)^3) - (b^6*log(a + b*sech(x)))/(a*(a^2 - b^2)^3) - 1/(16*(a + b)*(1 - sech(x))^2) - (5*a + 7*b)/(16*(a + b)^2*(1 - sech(x))) - 1/(16*(a - b)*(1 + sech(x))^2) - (5*a - 7*b)/(16*(a - b)^2*(1 + sech(x)))]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*tanh(c+d*x)^m*(a+b*sech(c+d*x))^(n/2)=#

    #= ::Subsubsection::Closed:: =#
    #=n>0=#

    @test_int [tanh(c + d*x)^5*sqrt(a + b*sech(c + d*x)), x, 5, (2*sqrt(a)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/d - (2*sqrt(a + b*sech(c + d*x)))/d + (2*a*(a^2 - 2*b^2)*(a + b*sech(c + d*x))^(3/2))/(3*b^4*d) - (2*(3*a^2 - 2*b^2)*(a + b*sech(c + d*x))^(5/2))/(5*b^4*d) + (6*a*(a + b*sech(c + d*x))^(7/2))/(7*b^4*d) - (2*(a + b*sech(c + d*x))^(9/2))/(9*b^4*d)]
    @test_int [tanh(c + d*x)^3*sqrt(a + b*sech(c + d*x)), x, 5, (2*sqrt(a)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/d - (2*sqrt(a + b*sech(c + d*x)))/d - (2*a*(a + b*sech(c + d*x))^(3/2))/(3*b^2*d) + (2*(a + b*sech(c + d*x))^(5/2))/(5*b^2*d)]
    @test_int [tanh(c + d*x)^1*sqrt(a + b*sech(c + d*x)), x, 4, (2*sqrt(a)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/d - (2*sqrt(a + b*sech(c + d*x)))/d]
    @test_int [coth(c + d*x)^1*sqrt(a + b*sech(c + d*x)), x, 7, (2*sqrt(a)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/d - (sqrt(a - b)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b)))/d - (sqrt(a + b)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b)))/d]
    @test_int [coth(c + d*x)^3*sqrt(a + b*sech(c + d*x)), x, 13, (2*sqrt(a)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/d - (a*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b)))/(sqrt(a - b)*d) + (3*b*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b)))/(4*sqrt(a - b)*d) - (a*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b)))/(sqrt(a + b)*d) - (3*b*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b)))/(4*sqrt(a + b)*d) - (coth(c + d*x)^2*sqrt(a + b*sech(c + d*x)))/(2*d)]

    @test_int [tanh(c + d*x)^2*sqrt(a + b*sech(c + d*x)), x, 7, -((2*a*(a - b)*sqrt(a + b)*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(3*b^2*d)) - (2*sqrt(a + b)*(a + 2*b)*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(3*b*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/d - (2*sqrt(a + b*sech(c + d*x))*tanh(c + d*x))/(3*d)]
    @test_int [tanh(c + d*x)^0*sqrt(a + b*sech(c + d*x)), x, 1, (2*coth(c + d*x)*Elliptic.Pi(a/(a + b), asin(sqrt(a + b)/sqrt(a + b*sech(c + d*x))), (a - b)/(a + b))*sqrt(-((b*(1 - sech(c + d*x)))/(a + b*sech(c + d*x))))*sqrt((b*(1 + sech(c + d*x)))/(a + b*sech(c + d*x)))*(a + b*sech(c + d*x)))/(sqrt(a + b)*d)]
    @test_int [coth(c + d*x)^2*sqrt(a + b*sech(c + d*x)), x, 5, (sqrt(a + b)*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/d - (coth(c + d*x)*sqrt(a + b*sech(c + d*x)))/d + (2*coth(c + d*x)*Elliptic.Pi(a/(a + b), asin(sqrt(a + b)/sqrt(a + b*sech(c + d*x))), (a - b)/(a + b))*sqrt(-((b*(1 - sech(c + d*x)))/(a + b*sech(c + d*x))))*sqrt((b*(1 + sech(c + d*x)))/(a + b*sech(c + d*x)))*(a + b*sech(c + d*x)))/(sqrt(a + b)*d)]

    #= ::Subsubsection::Closed:: =#
    #=n<0=#

    @test_int [tanh(c + d*x)^5/sqrt(a + b*sech(c + d*x)), x, 5, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(sqrt(a)*d) + (2*a*(a^2 - 2*b^2)*sqrt(a + b*sech(c + d*x)))/(b^4*d) - (2*(3*a^2 - 2*b^2)*(a + b*sech(c + d*x))^(3/2))/(3*b^4*d) + (6*a*(a + b*sech(c + d*x))^(5/2))/(5*b^4*d) - (2*(a + b*sech(c + d*x))^(7/2))/(7*b^4*d)]
    @test_int [tanh(c + d*x)^3/sqrt(a + b*sech(c + d*x)), x, 5, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(sqrt(a)*d) - (2*a*sqrt(a + b*sech(c + d*x)))/(b^2*d) + (2*(a + b*sech(c + d*x))^(3/2))/(3*b^2*d)]
    @test_int [tanh(c + d*x)^1/sqrt(a + b*sech(c + d*x)), x, 3, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(sqrt(a)*d)]
    @test_int [coth(c + d*x)^1/sqrt(a + b*sech(c + d*x)), x, 7, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(sqrt(a)*d) - atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b))/(sqrt(a - b)*d) - atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b))/(sqrt(a + b)*d)]
    @test_int [coth(c + d*x)^3/sqrt(a + b*sech(c + d*x)), x, 11, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(sqrt(a)*d) - atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b))/(sqrt(a - b)*d) + (b*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b)))/(4*(a - b)^(3/2)*d) - (b*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b)))/(4*(a + b)^(3/2)*d) - atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b))/(sqrt(a + b)*d) - sqrt(a + b*sech(c + d*x))/(4*(a + b)*d*(1 - sech(c + d*x))) - sqrt(a + b*sech(c + d*x))/(4*(a - b)*d*(1 + sech(c + d*x)))]

    @test_int [tanh(c + d*x)^4/sqrt(a + b*sech(c + d*x)), x, 11, -((4*(a - b)*sqrt(a + b)*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(b^2*d)) + (2*(a - b)*sqrt(a + b)*(8*a^2 + 9*b^2)*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(15*b^4*d) - (4*sqrt(a + b)*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(b*d) + (2*sqrt(a + b)*(8*a^2 - 2*a*b + 9*b^2)*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(15*b^3*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*d) - (8*a*sqrt(a + b*sech(c + d*x))*tanh(c + d*x))/(15*b^2*d) + (2*sech(c + d*x)*sqrt(a + b*sech(c + d*x))*tanh(c + d*x))/(5*b*d)]
    @test_int [tanh(c + d*x)^2/sqrt(a + b*sech(c + d*x)), x, 6, -((2*(a - b)*sqrt(a + b)*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(b^2*d)) - (2*sqrt(a + b)*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(b*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*d)]
    @test_int [tanh(c + d*x)^0/sqrt(a + b*sech(c + d*x)), x, 1, (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*d)]
    @test_int [coth(c + d*x)^2/sqrt(a + b*sech(c + d*x)), x, 9, (coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(sqrt(a + b)*d) - (coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(sqrt(a + b)*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*d) - coth(c + d*x)/(d*sqrt(a + b*sech(c + d*x))) - (b^2*tanh(c + d*x))/((a^2 - b^2)*d*sqrt(a + b*sech(c + d*x)))]

    @test_int [tanh(c + d*x)^5/(a + b*sech(c + d*x))^(3/2), x, 5, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(a^(3/2)*d) - (2*(a^2 - b^2)^2)/(a*b^4*d*sqrt(a + b*sech(c + d*x))) - (2*(3*a^2 - 2*b^2)*sqrt(a + b*sech(c + d*x)))/(b^4*d) + (2*a*(a + b*sech(c + d*x))^(3/2))/(b^4*d) - (2*(a + b*sech(c + d*x))^(5/2))/(5*b^4*d)]
    @test_int [tanh(c + d*x)^3/(a + b*sech(c + d*x))^(3/2), x, 5, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(a^(3/2)*d) + (2*(a^2 - b^2))/(a*b^2*d*sqrt(a + b*sech(c + d*x))) + (2*sqrt(a + b*sech(c + d*x)))/(b^2*d)]
    @test_int [tanh(c + d*x)^1/(a + b*sech(c + d*x))^(3/2), x, 4, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(a^(3/2)*d) - 2/(a*d*sqrt(a + b*sech(c + d*x)))]
    @test_int [coth(c + d*x)^1/(a + b*sech(c + d*x))^(3/2), x, 7, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(a^(3/2)*d) - atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b))/((a - b)^(3/2)*d) - atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b))/((a + b)^(3/2)*d) + (2*b^2)/(a*(a^2 - b^2)*d*sqrt(a + b*sech(c + d*x)))]
    @test_int [coth(c + d*x)^3/(a + b*sech(c + d*x))^(3/2), x, 11, (2*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a)))/(a^(3/2)*d) - ((2*a - 3*b)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b)))/(2*(a - b)^(5/2)*d) + (b*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a - b)))/(4*(a - b)^(5/2)*d) - (b*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b)))/(4*(a + b)^(5/2)*d) - ((2*a + 3*b)*atanh(sqrt(a + b*sech(c + d*x))/sqrt(a + b)))/(2*(a + b)^(5/2)*d) - (2*b^4)/(a*(a^2 - b^2)^2*d*sqrt(a + b*sech(c + d*x))) - sqrt(a + b*sech(c + d*x))/(4*(a + b)^2*d*(1 - sech(c + d*x))) - sqrt(a + b*sech(c + d*x))/(4*(a - b)^2*d*(1 + sech(c + d*x)))]

    @test_int [tanh(c + d*x)^4/(a + b*sech(c + d*x))^(3/2), x, 17, -((2*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*sqrt(a + b)*d)) + (4*a*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(b^2*sqrt(a + b)*d) - (2*a*(8*a^2 - 5*b^2)*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(3*b^4*sqrt(a + b)*d) + (2*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*sqrt(a + b)*d) + (4*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(b*sqrt(a + b)*d) - (2*(2*a + b)*(4*a + b)*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(3*b^3*sqrt(a + b)*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a^2*d) - (4*a*tanh(c + d*x))/((a^2 - b^2)*d*sqrt(a + b*sech(c + d*x))) + (2*b^2*tanh(c + d*x))/(a*(a^2 - b^2)*d*sqrt(a + b*sech(c + d*x))) - (2*a^2*sech(c + d*x)*tanh(c + d*x))/(b*(a^2 - b^2)*d*sqrt(a + b*sech(c + d*x))) + (2*(4*a^2 - b^2)*sqrt(a + b*sech(c + d*x))*tanh(c + d*x))/(3*b^2*(a^2 - b^2)*d)]
    @test_int [tanh(c + d*x)^2/(a + b*sech(c + d*x))^(3/2), x, 7, (2*(a - b)*sqrt(a + b)*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*b^2*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*b*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a^2*d) - (2*tanh(c + d*x))/(a*d*sqrt(a + b*sech(c + d*x)))]
    @test_int [tanh(c + d*x)^0/(a + b*sech(c + d*x))^(3/2), x, 6, -((2*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*sqrt(a + b)*d)) + (2*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*sqrt(a + b)*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a^2*d) + (2*b^2*tanh(c + d*x))/(a*(a^2 - b^2)*d*sqrt(a + b*sech(c + d*x)))]
    @test_int [coth(c + d*x)^2/(a + b*sech(c + d*x))^(3/2), x, 14, (4*a*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/((a - b)*(a + b)^(3/2)*d) - (2*coth(c + d*x)*Elliptic.E(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*sqrt(a + b)*d) - ((3*a - b)*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/((a - b)*(a + b)^(3/2)*d) + (2*coth(c + d*x)*Elliptic.F(asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a*sqrt(a + b)*d) + (2*sqrt(a + b)*coth(c + d*x)*Elliptic.Pi((a + b)/a, asin(sqrt(a + b*sech(c + d*x))/sqrt(a + b)), (a + b)/(a - b))*sqrt((b*(1 - sech(c + d*x)))/(a + b))*sqrt(-((b*(1 + sech(c + d*x)))/(a - b))))/(a^2*d) - coth(c + d*x)/(d*(a + b*sech(c + d*x))^(3/2)) - (b^2*tanh(c + d*x))/((a^2 - b^2)*d*(a + b*sech(c + d*x))^(3/2)) - (4*a*b^2*tanh(c + d*x))/((a^2 - b^2)^2*d*sqrt(a + b*sech(c + d*x))) + (2*b^2*tanh(c + d*x))/(a*(a^2 - b^2)*d*sqrt(a + b*sech(c + d*x)))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*ℯ^(a+b*x)*sech(c+d*x)^m=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*ℯ^(c*(a+b*x))*(sech(a*c+b*c*x)^2)^(m/2)=#

    @test_int [ℯ^(c*(a + b*x))*(sech(a*c + b*c*x)^2)^(7/2), x, 6, (32*cosh(a*c + b*c*x)*sqrt(sech(a*c + b*c*x)^2))/(3*b*c*(1 + ℯ^(2*c*(a + b*x)))^6) - (192*cosh(a*c + b*c*x)*sqrt(sech(a*c + b*c*x)^2))/(5*b*c*(1 + ℯ^(2*c*(a + b*x)))^5) + (48*cosh(a*c + b*c*x)*sqrt(sech(a*c + b*c*x)^2))/(b*c*(1 + ℯ^(2*c*(a + b*x)))^4) - (64*cosh(a*c + b*c*x)*sqrt(sech(a*c + b*c*x)^2))/(3*b*c*(1 + ℯ^(2*c*(a + b*x)))^3)]
    @test_int [ℯ^(c*(a + b*x))*(sech(a*c + b*c*x)^2)^(5/2), x, 6, (-4*cosh(a*c + b*c*x)*sqrt(sech(a*c + b*c*x)^2))/(b*c*(1 + ℯ^(2*c*(a + b*x)))^4) + (32*cosh(a*c + b*c*x)*sqrt(sech(a*c + b*c*x)^2))/(3*b*c*(1 + ℯ^(2*c*(a + b*x)))^3) - (8*cosh(a*c + b*c*x)*sqrt(sech(a*c + b*c*x)^2))/(b*c*(1 + ℯ^(2*c*(a + b*x)))^2)]
    @test_int [ℯ^(c*(a + b*x))*(sech(a*c + b*c*x)^2)^(3/2), x, 4, (2*ℯ^(4*c*(a + b*x))*cosh(a*c + b*c*x)*sqrt(sech(a*c + b*c*x)^2))/(b*c*(1 + ℯ^(2*c*(a + b*x)))^2)]
    @test_int [ℯ^(c*(a + b*x))*sqrt(sech(a*c + b*c*x)^2), x, 4, (cosh(a*c + b*c*x)*log(1 + ℯ^(2*c*(a + b*x)))*sqrt(sech(a*c + b*c*x)^2))/(b*c)]
    @test_int [ℯ^(c*(a + b*x))/sqrt(sech(a*c + b*c*x)^2), x, 5, (ℯ^(2*c*(a + b*x))*sech(a*c + b*c*x))/(4*b*c*sqrt(sech(a*c + b*c*x)^2)) + (x*sech(a*c + b*c*x))/(2*sqrt(sech(a*c + b*c*x)^2))]
    @test_int [ℯ^(c*(a + b*x))/(sech(a*c + b*c*x)^2)^(3/2), x, 6, -sech(a*c + b*c*x)/(16*b*c*ℯ^(2*c*(a + b*x))*sqrt(sech(a*c + b*c*x)^2)) + (3*ℯ^(2*c*(a + b*x))*sech(a*c + b*c*x))/(16*b*c*sqrt(sech(a*c + b*c*x)^2)) + (ℯ^(4*c*(a + b*x))*sech(a*c + b*c*x))/(32*b*c*sqrt(sech(a*c + b*c*x)^2)) + (3*x*sech(a*c + b*c*x))/(8*sqrt(sech(a*c + b*c*x)^2))]
    @test_int [ℯ^(c*(a + b*x))/(sech(a*c + b*c*x)^2)^(5/2), x, 6, -sech(a*c + b*c*x)/(128*b*c*ℯ^(4*c*(a + b*x))*sqrt(sech(a*c + b*c*x)^2)) - (5*sech(a*c + b*c*x))/(64*b*c*ℯ^(2*c*(a + b*x))*sqrt(sech(a*c + b*c*x)^2)) + (5*ℯ^(2*c*(a + b*x))*sech(a*c + b*c*x))/(32*b*c*sqrt(sech(a*c + b*c*x)^2)) + (5*ℯ^(4*c*(a + b*x))*sech(a*c + b*c*x))/(128*b*c*sqrt(sech(a*c + b*c*x)^2)) + (ℯ^(6*c*(a + b*x))*sech(a*c + b*c*x))/(192*b*c*sqrt(sech(a*c + b*c*x)^2)) + (5*x*sech(a*c + b*c*x))/(16*sqrt(sech(a*c + b*c*x)^2))]

    #= ::Section::Closed:: =#
    #=Integrands*of*the*form*x^m*sech(a+b*log(c*x^n))^p=#

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*x^m*sech(b*log(c*x^n))^(p/2)=#

    @test_int [x^5/sech(2*log(c*x))^(1/2), x, 6, (2*x^2)/(21*c^4*sqrt(sech(2*log(c*x)))) + x^6/(7*sqrt(sech(2*log(c*x)))) + (sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.F(2*acot(c*x), 1/2))/(21*c^5*(c^4 + 1/x^4)*x*sqrt(sech(2*log(c*x))))]
    @test_int [x^4/sech(2*log(c*x))^(1/2), x, 3, ((c^4 + 1/x^4)*x^5)/(6*c^4*sqrt(sech(2*log(c*x))))]
    @test_int [x^3/sech(2*log(c*x))^(1/2), x, 8, 2/(5*c^4*sqrt(sech(2*log(c*x)))) - 2/(5*c^4*(c^2 + 1/x^2)*x^2*sqrt(sech(2*log(c*x)))) + x^4/(5*sqrt(sech(2*log(c*x)))) + (2*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.E(2*acot(c*x), 1/2))/(5*c^3*(c^4 + 1/x^4)*x*sqrt(sech(2*log(c*x)))) - (sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.F(2*acot(c*x), 1/2))/(5*c^3*(c^4 + 1/x^4)*x*sqrt(sech(2*log(c*x))))]
    @test_int [x^2/sech(2*log(c*x))^(1/2), x, 6, x^3/(4*sqrt(sech(2*log(c*x)))) + atanh(sqrt(1 + 1/(c^4*x^4)))/(4*c^4*sqrt(1 + 1/(c^4*x^4))*x*sqrt(sech(2*log(c*x))))]
    @test_int [x^1/sech(2*log(c*x))^(1/2), x, 5, x^2/(3*sqrt(sech(2*log(c*x)))) - (sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.F(2*acot(c*x), 1/2))/(3*c*(c^4 + 1/x^4)*x*sqrt(sech(2*log(c*x))))]
    @test_int [x^0/sech(2*log(c*x))^(1/2), x, 6, x/(2*sqrt(sech(2*log(c*x)))) - acsch(c^2*x^2)/(2*c^2*sqrt(1 + 1/(c^4*x^4))*x*sqrt(sech(2*log(c*x))))]
    @test_int [sech(2*log(c*x))^(1/2)/x^1, x, 3, (-im)*sqrt(cosh(2*log(c*x)))*Elliptic.F(im*log(c*x), 2)*sqrt(sech(2*log(c*x)))]
    @test_int [sech(2*log(c*x))^(1/2)/x^2, x, 5, (-(1/2))*c^2*sqrt(1 + 1/(c^4*x^4))*x*acsch(c^2*x^2)*sqrt(sech(2*log(c*x)))]
    @test_int [sech(2*log(c*x))^(1/2)/x^3, x, 6, -(((c^4 + 1/x^4)*sqrt(sech(2*log(c*x))))/(c^2 + 1/x^2)) + c*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*x*Elliptic.E(2*acot(c*x), 1/2)*sqrt(sech(2*log(c*x))) - (1/2)*c*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*x*Elliptic.F(2*acot(c*x), 1/2)*sqrt(sech(2*log(c*x)))]
    @test_int [sech(2*log(c*x))^(1/2)/x^4, x, 3, (-(1/2))*(c^4 + 1/x^4)*x*sqrt(sech(2*log(c*x)))]
    @test_int [sech(2*log(c*x))^(1/2)/x^5, x, 5, (-(1/3))*(c^4 + 1/x^4)*sqrt(sech(2*log(c*x))) + (1/6)*c^3*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*x*Elliptic.F(2*acot(c*x), 1/2)*sqrt(sech(2*log(c*x)))]

    @test_int [x^8/sech(2*log(c*x))^(3/2), x, 8, x/(32*c^4*(c^4 + 1/x^4)*sech(2*log(c*x))^(3/2)) + x^5/(16*(c^4 + 1/x^4)*sech(2*log(c*x))^(3/2)) + x^9/(12*sech(2*log(c*x))^(3/2)) - atanh(sqrt(1 + 1/(c^4*x^4)))/(32*c^12*(1 + 1/(c^4*x^4))^(3/2)*x^3*sech(2*log(c*x))^(3/2))]
    @test_int [x^7/sech(2*log(c*x))^(3/2), x, 7, 4/(77*c^4*(c^4 + 1/x^4)*sech(2*log(c*x))^(3/2)) + (6*x^4)/(77*(c^4 + 1/x^4)*sech(2*log(c*x))^(3/2)) + x^8/(11*sech(2*log(c*x))^(3/2)) + (2*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.F(2*acot(c*x), 1/2))/(77*c^5*(c^4 + 1/x^4)^2*x^3*sech(2*log(c*x))^(3/2))]
    @test_int [x^6/sech(2*log(c*x))^(3/2), x, 3, ((c^4 + 1/x^4)*x^7)/(10*c^4*sech(2*log(c*x))^(3/2))]
    @test_int [x^5/sech(2*log(c*x))^(3/2), x, 9, -(4/(15*c^4*(c^4 + 1/x^4)*(c^2 + 1/x^2)*x^4*sech(2*log(c*x))^(3/2))) + 4/(15*c^4*(c^4 + 1/x^4)*x^2*sech(2*log(c*x))^(3/2)) + (2*x^2)/(15*(c^4 + 1/x^4)*sech(2*log(c*x))^(3/2)) + x^6/(9*sech(2*log(c*x))^(3/2)) + (4*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.E(2*acot(c*x), 1/2))/(15*c^3*(c^4 + 1/x^4)^2*x^3*sech(2*log(c*x))^(3/2)) - (2*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.F(2*acot(c*x), 1/2))/(15*c^3*(c^4 + 1/x^4)^2*x^3*sech(2*log(c*x))^(3/2))]
    @test_int [x^4/sech(2*log(c*x))^(3/2), x, 7, (3*x)/(16*(c^4 + 1/x^4)*sech(2*log(c*x))^(3/2)) + x^5/(8*sech(2*log(c*x))^(3/2)) + (3*atanh(sqrt(1 + 1/(c^4*x^4))))/(16*c^8*(1 + 1/(c^4*x^4))^(3/2)*x^3*sech(2*log(c*x))^(3/2))]
    @test_int [x^3/sech(2*log(c*x))^(3/2), x, 6, 2/(7*(c^4 + 1/x^4)*sech(2*log(c*x))^(3/2)) + x^4/(7*sech(2*log(c*x))^(3/2)) - (2*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.F(2*acot(c*x), 1/2))/(7*c*(c^4 + 1/x^4)^2*x^3*sech(2*log(c*x))^(3/2))]
    @test_int [x^2/sech(2*log(c*x))^(3/2), x, 7, 1/(2*(c^4 + 1/x^4)*x*sech(2*log(c*x))^(3/2)) + x^3/(6*sech(2*log(c*x))^(3/2)) - acsch(c^2*x^2)/(2*c^6*(1 + 1/(c^4*x^4))^(3/2)*x^3*sech(2*log(c*x))^(3/2))]
    @test_int [x^1/sech(2*log(c*x))^(3/2), x, 8, -(12/(5*(c^4 + 1/x^4)*(c^2 + 1/x^2)*x^4*sech(2*log(c*x))^(3/2))) + 6/(5*(c^4 + 1/x^4)*x^2*sech(2*log(c*x))^(3/2)) + x^2/(5*sech(2*log(c*x))^(3/2)) + (12*c*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.E(2*acot(c*x), 1/2))/(5*(c^4 + 1/x^4)^2*x^3*sech(2*log(c*x))^(3/2)) - (6*c*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*Elliptic.F(2*acot(c*x), 1/2))/(5*(c^4 + 1/x^4)^2*x^3*sech(2*log(c*x))^(3/2))]
    @test_int [x^0/sech(2*log(c*x))^(3/2), x, 7, -(3/(4*(c^4 + 1/x^4)*x^3*sech(2*log(c*x))^(3/2))) + x/(4*sech(2*log(c*x))^(3/2)) + (3*atanh(sqrt(1 + 1/(c^4*x^4))))/(4*c^4*(1 + 1/(c^4*x^4))^(3/2)*x^3*sech(2*log(c*x))^(3/2))]
    @test_int [sech(2*log(c*x))^(3/2)/x^1, x, 4, im*sqrt(cosh(2*log(c*x)))*Elliptic.E(im*log(c*x), 2)*sqrt(sech(2*log(c*x))) + sqrt(sech(2*log(c*x)))*sinh(2*log(c*x))]
    @test_int [sech(2*log(c*x))^(3/2)/x^2, x, 3, (1/2)*(c^4 + 1/x^4)*x^3*sech(2*log(c*x))^(3/2)]
    @test_int [sech(2*log(c*x))^(3/2)/x^3, x, 5, (1/2)*(c^4 + 1/x^4)*x^2*sech(2*log(c*x))^(3/2) - ((c^4 + 1/x^4)*sqrt((c^4 + 1/x^4)/(c^2 + 1/x^2)^2)*(c^2 + 1/x^2)*x^3*Elliptic.F(2*acot(c*x), 1/2)*sech(2*log(c*x))^(3/2))/(4*c)]
    @test_int [sech(2*log(c*x))^(3/2)/x^4, x, 6, (1/2)*(c^4 + 1/x^4)*x*sech(2*log(c*x))^(3/2) - (1/2)*c^6*(1 + 1/(c^4*x^4))^(3/2)*x^3*acsch(c^2*x^2)*sech(2*log(c*x))^(3/2)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*x^m*sech(a+b*log(c*x^n))^p=#

    @test_int [sech(a + b*log(c*x^n)), x, 4, (2*ℯ^a*x*(c*x^n)^b*HypergeometricFunctions._₂F₁(1, (b + 1/n)/(2*b), (1/2)*(3 + 1/(b*n)), (-ℯ^(2*a))*(c*x^n)^(2*b)))/(1 + b*n)]
    @test_int [sech(a + b*log(c*x^n))^2, x, 4, (4*ℯ^(2*a)*x*(c*x^n)^(2*b)*HypergeometricFunctions._₂F₁(2, (1/2)*(2 + 1/(b*n)), (1/2)*(4 + 1/(b*n)), (-ℯ^(2*a))*(c*x^n)^(2*b)))/(1 + 2*b*n)]
    @test_int [sech(a + b*log(c*x^n))^3, x, 4, (8*ℯ^(3*a)*x*(c*x^n)^(3*b)*HypergeometricFunctions._₂F₁(3, (3*b + 1/n)/(2*b), (1/2)*(5 + 1/(b*n)), (-ℯ^(2*a))*(c*x^n)^(2*b)))/(1 + 3*b*n)]
    @test_int [sech(a + b*log(c*x^n))^4, x, 4, (16*ℯ^(4*a)*x*(c*x^n)^(4*b)*HypergeometricFunctions._₂F₁(4, (1/2)*(4 + 1/(b*n)), (1/2)*(6 + 1/(b*n)), (-ℯ^(2*a))*(c*x^n)^(2*b)))/(1 + 4*b*n)]

    @test_int [2*b^2*n^2*sech(a + b*log(c*x^n))^3 + (1 - b^2*n^2)*sech(a + b*log(c*x^n)), x, -9, x*sech(a + b*log(c*x^n)) + b*n*x*sech(a + b*log(c*x^n))*tanh(a + b*log(c*x^n))]

    @test_int [sech(a + 2*log(c*x^(1/2)))^3, x, 3, (2*c^6)/(ℯ^a*(c^4 + 1/(ℯ^(2*a)*x^2))^2)]
    @test_int [sech(a + 2*log(c/x^(1/2)))^3, x, 4, (2*c^2)/(ℯ^(3*a)*(ℯ^(-2*a) + c^4/x^2)^2)]
    @test_int [sech(a + 1/(n*(-2 + p))*log(c*x^n))^p, x, 3, (ℯ^(2*a)*(2 - p)*x*(1 + (c*x^n)^(2/(n*(2 - p)))/ℯ^(2*a))*sech(a - log(c*x^n)/(n*(2 - p)))^p)/((c*x^n)^(2/(n*(2 - p)))*(2*(1 - p)))]
    @test_int [sech(a - 1/(n*(-2 + p))*log(c*x^n))^p, x, 3, ((2 - p)*x*(1 + 1/(ℯ^(2*a)*(c*x^n)^(2/(n*(2 - p)))))*sech(a + log(c*x^n)/(n*(2 - p)))^p)/(2*(1 - p))]

    @test_int [sech(a + b*log(c*x^n))/x, x, 2, atan(sinh(a + b*log(c*x^n)))/(b*n)]
    @test_int [sech(a + b*log(c*x^n))^2/x, x, 3, tanh(a + b*log(c*x^n))/(b*n)]
    @test_int [sech(a + b*log(c*x^n))^3/x, x, 3, atan(sinh(a + b*log(c*x^n)))/(2*b*n) + (sech(a + b*log(c*x^n))*tanh(a + b*log(c*x^n)))/(2*b*n)]
    @test_int [sech(a + b*log(c*x^n))^4/x, x, 3, tanh(a + b*log(c*x^n))/(b*n) - tanh(a + b*log(c*x^n))^3/(3*b*n)]
    @test_int [sech(a + b*log(c*x^n))^5/x, x, 4, (3*atan(sinh(a + b*log(c*x^n))))/(8*b*n) + (3*sech(a + b*log(c*x^n))*tanh(a + b*log(c*x^n)))/(8*b*n) + (sech(a + b*log(c*x^n))^3*tanh(a + b*log(c*x^n)))/(4*b*n)]

    #= ::Subsection::Closed:: =#
    #=Integrands*of*the*form*x^m*sech(a+b*log(c*x^n))^(p/2)=#

    @test_int [sech(a + b*log(c*x^n))^(5/2)/x, x, 4, -((2*im*sqrt(cosh(a + b*log(c*x^n)))*Elliptic.F((1/2)*im*(a + b*log(c*x^n)), 2)*sqrt(sech(a + b*log(c*x^n))))/(3*b*n)) + (2*sech(a + b*log(c*x^n))^(3/2)*sinh(a + b*log(c*x^n)))/(3*b*n)]
    @test_int [sech(a + b*log(c*x^n))^(3/2)/x, x, 4, (2*im*sqrt(cosh(a + b*log(c*x^n)))*Elliptic.E((1/2)*im*(a + b*log(c*x^n)), 2)*sqrt(sech(a + b*log(c*x^n))))/(b*n) + (2*sqrt(sech(a + b*log(c*x^n)))*sinh(a + b*log(c*x^n)))/(b*n)]
    @test_int [sqrt(sech(a + b*log(c*x^n)))/x, x, 3, -((2*im*sqrt(cosh(a + b*log(c*x^n)))*Elliptic.F((1/2)*im*(a + b*log(c*x^n)), 2)*sqrt(sech(a + b*log(c*x^n))))/(b*n))]
    @test_int [1/(x*sqrt(sech(a + b*log(c*x^n)))), x, 3, -((2*im*sqrt(cosh(a + b*log(c*x^n)))*Elliptic.E((1/2)*im*(a + b*log(c*x^n)), 2)*sqrt(sech(a + b*log(c*x^n))))/(b*n))]
    @test_int [1/(x*sech(a + b*log(c*x^n))^(3/2)), x, 4, -((2*im*sqrt(cosh(a + b*log(c*x^n)))*Elliptic.F((1/2)*im*(a + b*log(c*x^n)), 2)*sqrt(sech(a + b*log(c*x^n))))/(3*b*n)) + (2*sinh(a + b*log(c*x^n)))/(3*b*n*sqrt(sech(a + b*log(c*x^n))))]
    @test_int [1/(x*sech(a + b*log(c*x^n))^(5/2)), x, 4, -((6*im*sqrt(cosh(a + b*log(c*x^n)))*Elliptic.E((1/2)*im*(a + b*log(c*x^n)), 2)*sqrt(sech(a + b*log(c*x^n))))/(5*b*n)) + (2*sinh(a + b*log(c*x^n)))/(5*b*n*sech(a + b*log(c*x^n))^(3/2))]
    end

max_stars_repo_path: test/6 Hyperbolic functions/6.5 Hyperbolic secant/6.5.3 Hyperbolic secant functions.jl


text:
# (2) Wage and labor force participation
labfpus = get_data(api_fred, "CIVPART"; units = "ch1", observation_start = "2008-01-01")
wageus = get_data(api_fred, "ECIWAG"; units = "ch1", observation_start = "2008-01-01")

plot_unempus = layer(labfpus.data, x = :date, y = :value, Geom.line, Theme(default_color=colorant"red"),
    xintercept = [Date("2020-02-08")], Geom.vline(color = "black", style=[[1mm,1mm]])
    );
plot_ptempus = layer(wageus.data, x = :date, y = :value, Geom.line, Theme(default_color=colorant"deepskyblue"),
    xintercept = [Date("2008-09-01")], Geom.vline(color = "grey", size=[10.5mm])
    );
plt_labour0 = plot(plot_unempus, plot_ptempus,
        Guide.manual_color_key("Labor market",
                                ["Labor force participation rate ($(maximum(labfpus.data[:date])): $(round(last(labfpus.data[:value]), digits = 1)))",
                                 "Employment cost - wage and salary ($(maximum(wageus.data[:date])): $(round(last(wageus.data[:value]), digits = 1)))"],
                                ["red", "deepskyblue"],
                                pos = [0.2w,0.38h]
                               ),
         Guide.xlabel("Time"), Guide.ylabel("Change from a year ago, percent"),
        Coord.cartesian(xmin=minimum(weius.data[:date]), xmax=maxvalue=maximum(weius.data[:date])),
        Scale.x_continuous(minvalue=minimum(weius.data[:date]), maxvalue=maximum(weius.data[:date]))
    )
pngout = SVG("plt_labour0.svg", 5inch, 4inch)
draw(pngout, plt_labour0)

ext: jl


text:
####################################
# Load libraries
using DelimitedFiles
using Plots
using DataFrames
using CSV
using LaTeXStrings

####################################
# Load functions
include("bils_chang_kim_2011/steady_state_equilibrium.jl")

####################################
# Approximate value, policy, and wage functions,
# reservation productivity function, and stationary distributions
# given θ = 1
para            = ModelParams()
W, U, J, emp_policy, unemp_policy, wage = SolveWage(para)
x_star          = ReservationProductivity(para, W, U)
π_emp, π_unemp  = FindStationaryMeasures(para, emp_policy, unemp_policy, x_star)

####################################
# Save all objects externally
writedlm( "bils_chang_kim_2011/data/W.csv",  W, ',')
writedlm( "bils_chang_kim_2011/data/U.csv",  U, ',')
writedlm( "bils_chang_kim_2011/data/J.csv",  J, ',')
writedlm( "bils_chang_kim_2011/data/emp_policy.csv",  emp_policy, ',')
writedlm( "bils_chang_kim_2011/data/unemp_policy.csv",  unemp_policy, ',')
writedlm( "bils_chang_kim_2011/data/wage.csv",  wage, ',')
writedlm( "bils_chang_kim_2011/data/x_star.csv",  x_star, ',')
writedlm( "bils_chang_kim_2011/data/pi_emp.csv",  π_emp, ',')
writedlm( "bils_chang_kim_2011/data/pi_unemp.csv",  π_unemp, ',')

####################################
# Import objects (if necessary)
## Value of employment
W = CSV.read("bils_chang_kim_2011/data/W.csv", DataFrame, header = false)
W = Matrix(W)
## Value of unemployment
U = CSV.read("bils_chang_kim_2011/data/U.csv", DataFrame, header = false)
U = Matrix(U)
## Value of a matched job
J = CSV.read("bils_chang_kim_2011/data/J.csv", DataFrame, header = false)
J = Matrix(J)
## Asset policy function under employment
emp_policy      = CSV.read("bils_chang_kim_2011/data/emp_policy.csv", DataFrame, header = false)
emp_policy      = Matrix(emp_policy)
## Asset policy function under unemployment
unemp_policy    = CSV.read("bils_chang_kim_2011/data/unemp_policy.csv", DataFrame, header = false)
unemp_policy    = Matrix(unemp_policy)
## Wage function
wage            = CSV.read("bils_chang_kim_2011/data/wage.csv", DataFrame, header = false)
wage            = Matrix(wage)
## Employed distribution
pi_emp          = CSV.read("bils_chang_kim_2011/data/pi_emp.csv", DataFrame, header = false)
pi_emp          = Matrix(pi_emp)
## Unemployed distribution
pi_unemp        = CSV.read("bils_chang_kim_2011/data/pi_unemp.csv", DataFrame, header = false)
pi_unemp        = Matrix(pi_unemp)

####################################
# Plot all objects and save externally
## Save asset grid for x-axes
agrid = para.agrid
xgrid = para.xgrid
N_a = length(agrid)
N_x = length(xgrid)
## Plot value of employment for each x
fig1 = plot(title = "Asset Policy Under Employment");
for i in 1:9
    plot!(fig1, agrid, emp_policy[:,i], label="x=$(round(xgrid[i],digits=2))");
end
xlabel!("Current Assets");
ylabel!("Future Assets");
## Plot value of unemployment for each x
fig2 = plot(title = "Asset Policy Under Unemployment");
plot!(fig2, agrid, unemp_policy, label="");
xlabel!("Current Assets");
ylabel!("Future Assets");
## Plot value of firm-worker match for each x
fig3 = plot(title = "Matched Firm Value");
for i in 1:9
    plot!(fig3, agrid, J[:,i], label="x=$(round(xgrid[i],digits=2))");
end
xlabel!("Level of Asset Holdings");
ylabel!(L"J");
## Plot wages for each x
fig4 = plot(title = "Wage Schedule");
for i in 1:9
    plot!(fig4, agrid, wage[:,i], label="x=$(round(xgrid[i],digits=2))");
end
xlabel!("Level of Asset Holdings");
ylabel!("Wage");
## Plot W - U for each x
fig5 = plot(title = "Employment vs. Unemployment");
for i in 1:9
    plot!(fig5, agrid, W[:,i] - U, label="x=$(round(xgrid[i],digits=2))");
end
xlabel!("Level of Asset Holdings");
ylabel!(L"W-U");
## Plot asset distributions for employed and unemployed
fig6 = plot(title = "Asset Distributions for Employed and Unemployed");
emp_distr   = zeros(length(agrid))
unemp_distr = zeros(length(agrid))
for i in 1:N_a
    emp_distr[i]    = sum([π_emp[i+N_a*(j-1)] for j in 1:N_x])
    unemp_distr[i]  = sum([π_unemp[i+N_a*(j-1)] for j in 1:N_x])
end
plot!(fig6, agrid, emp_distr, label = "Employed");
plot!(fig6, agrid, unemp_distr, label = "Unemployed");
xlabel!("Level of Asset Holdings");
## Plot reservation match productivity
fig7 = plot(title = "Worker Assets and Reservation Match Productivity");
plot!(fig7, agrid, x_star, label = L"x^\ast(a)");
xlabel!("Level of Asset Holdings");
ylabel!("Productivity");
## All plots together
plot(fig1)
plot(fig2)
plot(fig3)
plot(fig4)
plot(fig5)
plot(fig6)
plot(fig7)
## Export plots
savefig(fig1, "bils_chang_kim_2011/figures/fig1.png")
savefig(fig2, "bils_chang_kim_2011/figures/fig2.png")
savefig(fig3, "bils_chang_kim_2011/figures/fig3.png")
savefig(fig4, "bils_chang_kim_2011/figures/fig4.png")
savefig(fig5, "bils_chang_kim_2011/figures/fig5.png")
savefig(fig6, "bils_chang_kim_2011/figures/fig6.png")
savefig(fig7, "bils_chang_kim_2011/figures/fig7.png")


text:
using Distributed
import Base.Threads.@spawn

#=
@author Ignacio Fuenzalida veas
=#

# mergesort_paralelo
function mergesort_paralelo!(array, tail::Int64=1, head::Int64=length(array))
    # retornamos si el array es unico
    if tail >= head && return array end

    middle = div(head+tail,2)
    #Se resuelve la parte izquierda
    leftArray = @spawn mergesort_paralelo!(array, tail, middle)
    #Se resuelve la parte derecha
    mergesort_paralelo!(array, middle+1, head)

    #Esperamos al izquierda
    wait(leftArray)

    #Array temporal par aunir ambos
    temp = array[tail:middle]

    i ,k ,j = 1, tail, middle + 1
    #merge los dos arrays en un temporal
    @inbounds while k < j <= head

        if array[j] < temp[i]
            array[k] = array[j]
            j += 1
        else
            array[k] = temp[i]
            i += 1
        end
        k += 1
    end
    @inbounds while k < j
        array[k] = temp[i]
        k += 1
        i += 1
    end

    return array

end

#Tamanio del array a evaluar
tamanio = 10000000;
#Genracion de array
array = [rem(rand(Int64),100) for i =1:tamanio]
@time mergesort_paralelo!(array);

max_stars_repo_name: NaChOoV/mergesort

max_issues_repo_name: NaChOoV/mergesort

max_forks_repo_name: NaChOoV/mergesort


text:
@testset "parsing" begin
    @testset "install" begin
        @testset "download" begin
            args = argparse(["install", "download", "0.3"])
            @test args == Dict(
                "%COMMAND%" => "install",
                "install" => Dict(
                    "%COMMAND%" => "download",
                    "download" => Dict(
                        "labels" => AbstractString[],
                        "version" => v"0.3",
                    )
                ),
                "debug" => false
            )
        end
        @testset "link" begin
            args = argparse(["install", "link", "/path/to/julia", "--labels", "julia-src"])
            @test args == Dict(
                "%COMMAND%" => "install",
                "install" => Dict(
                    "%COMMAND%" => "link",
                    "link" => Dict(
                        "labels" => AbstractString["julia-src"],
                        "dir" => p"/path/to/julia"
                    )
                ),
                "debug" => false
            )
        end
    end
    @testset "create" begin
        @testset "defaults" begin
            args = argparse(["create"])
            @test args == Dict(
                "%COMMAND%" => "create",
                "create" => Dict(
                    "dir" => Path(),
                    "requirements" => Path(),
                    "name" => "",
                    "julia-version" => "",
                    "registry" => "",
                    "branch" => "",
                ),
                "debug" => false
            )
        end
        @testset "arguments" begin
            args = argparse(
                [
                    "create", "/path/to/playground",
                    "--name", "myplayground",
                    "--julia-version", "julia-0.3",
                    "--requirements", "/path/to/requirements",
                    "--registry", "https://github.com/JuliaLang/METADATA.jl",
                    "--branch", "metadata-v2",
                ]
            )
        end
    end

    @testset "activate" begin
        @testset "defaults" begin
            args = argparse(["activate"])
            @test args == Dict(
                "%COMMAND%" => "activate",
                "activate" => Dict(
                    "dir" => Path(),
                    "name" => ""
                ),
                "debug" => false
            )
        end
        @testset "arguments" begin
            args = argparse(["activate", "--name", "myplayground"])
            @test args == Dict(
                "%COMMAND%" => "activate",
                "activate" => Dict(
                    "dir" => Path(),
                    "name" => "myplayground"
                ),
                "debug" => false
            )
        end
    end

    @testset "exec" begin
        args = argparse(["exec", "ls -al", "--name", "myplayground"])
        @test args == Dict(
            "%COMMAND%" => "exec",
            "exec" => Dict(
                "cmd" => "ls -al",
                "dir" => Path(),
                "name" => "myplayground"
            ),
            "debug" => false
        )
    end

    @testset "list" begin
        args = argparse(["list", "--show-links"])
        @test args == Dict(
            "%COMMAND%" => "list",
            "list" => Dict(
                "show-links" => true
            ),
            "debug" => false
        )
    end

    @testset "clean" begin
        args = argparse(["clean"])
        @test args == Dict(
            "%COMMAND%" => "clean",
            "clean" => Dict(),
            "debug" => false
        )
    end

    @testset "remove" begin
        args = argparse(["rm", "myplayground"])
        @test args == Dict(
            "%COMMAND%" => "rm",
            "rm" => Dict(
                "dir" => Path(),
                "name" => "myplayground"
            ),
            "debug" => false
        )
    end
end


text:
function uri2filepath(uri::AbstractString)
    uri_path = normpath(URIParser.unescape(URIParser.URI(uri).path))

    if Sys.iswindows()
        if uri_path[1] == '\\' || uri_path[1] == '/'
            uri_path = uri_path[2:end]
        end
    end
    return uri_path
end

function filepath2uri(file::String)
    if Sys.iswindows()
        file = normpath(file)
        file = replace(file, "\\" => "/")
        file = URIParser.escape(file)
        file = replace(file, "%2F" => "/")
        return string("file:///", file)
    else
        file = normpath(file)
        file = URIParser.escape(file)
        file = replace(file, "%2F" => "/")
        return string("file://", file)
    end
end

function joinuriwithpath(uri::AbstractString, path::AbstractString)
    left_file_path = uri2filepath(uri)
    combined_path = joinpath(left_file_path, path)
    return filepath2uri(combined_path)
end

function should_file_be_linted(uri, server)
    !server.runlinter && return false

    uri_path = uri2filepath(uri)

    if length(server.workspaceFolders)==0
        return false
    else
        return any(i->startswith(uri_path, i), server.workspaceFolders)
    end
end

CompletionItemKind(t) = t in [:String, :AbstractString] ? 1 :
                                t == :Function ? 3 :
                                t == :DataType ? 7 :
                                t == :Module ? 9 : 6

SymbolKind(t) = t in [:String, :AbstractString] ? 15 :
                        t == :Function ? 12 :
                        t == :DataType ? 5 :
                        t == :Module ? 2 :
                        t == :Bool ? 17 : 13

str_value(x) = ""
str_value(x::T) where T <: Union{IDENTIFIER,LITERAL} = x.val
str_value(x::OPERATOR) = string(Expr(x))

# Find location of default datatype constructor
const DefaultTypeConstructorLoc= let def = first(methods(Int))
    Base.find_source_file(string(def.file)), def.line
end

function is_ignored(uri, server)
    fpath = uri2filepath(uri)
    fpath in server.ignorelist && return true
    for ig in server.ignorelist
        if !endswith(ig, ".jl")
            if startswith(fpath, ig)
                return true
            end
        end
    end
    return false
end

is_ignored(uri::URI2, server) = is_ignored(uri._uri, server)

function toggle_file_lint(doc, server)
    if doc._runlinter
        doc._runlinter = false
        empty!(doc.diagnostics)
    else
        doc._runlinter = true
        # L = lint(doc, server)
        # doc.diagnostics = L.diagnostics
    end
    publish_diagnostics(doc, server)
end

function remove_workspace_files(root, server)
    for (uri, doc) in server.documents
        fpath = uri2filepath(uri._uri)
        doc._open_in_editor && continue
        if startswith(fpath, fpath)
            for folder in server.workspaceFolders
                if startswith(fpath, folder)
                    continue
                end
                delete!(server.documents, uri)
            end
        end
    end
end

function find_root(doc::Document, server)
    path = uri2filepath(doc._uri)
    for (uri1,f) in server.documents
        for incl in f.code.state.includes
            if path == incl.file
                if doc.code.index != incl.index
                    doc.code.index = incl.index
                    doc.code.nb = incl.pos
                end

                return find_root(f, server)
            end
        end
    end
    return doc
end

function Base.getindex(server::LanguageServerInstance, r::Regex)
    out = []
    for (uri,doc) in server.documents
        occursin(r, uri._uri) && push!(out, doc)
    end
    return out
end

function _offset_unitrange(r::UnitRange{Int}, first = true)
    return r.start-1:r.stop
end

function get_toks(doc, offset)
    ts = CSTParser.Tokenize.tokenize(doc._content)
    CSTParser.Tokens.EMPTY_TOKEN(CSTParser.Tokens.RawToken)
    CSTParser.Tokens.RawToken()
    ppt = CSTParser.Tokens.RawToken(CSTParser.Tokens.ERROR, (0,0), (0,0), 1, 0, CSTParser.Tokens.NO_ERR, false)
    pt = CSTParser.Tokens.RawToken(CSTParser.Tokens.ERROR, (0,0), (0,0), 1, 0, CSTParser.Tokens.NO_ERR, false)
    t = CSTParser.Tokenize.Lexers.next_token(ts)
    if offset >= length(doc._content)
        offset = sizeof(doc._content) - 1
    end

    while t.kind != CSTParser.Tokenize.Tokens.ENDMARKER
        if t.startbyte < offset <= t.endbyte + 1
            break
        end
        ppt = pt
        pt = t
        t = CSTParser.Tokenize.Lexers.next_token(ts)
    end
    return ppt, pt, t
end

function find_ref(doc, offset)
    for rref in doc.code.rref
        if rref.r.loc.offset == offset
            return rref
        elseif rref.r.loc.offset > offset
            break
        end
    end
    return nothing
end

function get_locations(rref::StaticLint.ResolvedRef, bindings, locations, server)
    if rref.b isa StaticLint.ImportBinding
        for l in get(rref.b.val, ".methods", [])
            push!(locations, Location(filepath2uri(get(l, "file", "")), get(l, "line", 0)))
        end
    elseif rref.b.t in (StaticLint._Function, StaticLint._DataType)
        for b in StaticLint.get_methods(rref, bindings)
            get_locations(b, bindings, locations, server)
        end
    else
        get_locations(rref.b, bindings, locations, server)
    end
end

function get_locations(b::StaticLint.Binding, bindings, locations, server)
    if b.val isa CSTParser.AbstractEXPR
        uri2 = filepath2uri(b.loc.file)
        if !(URI2(uri2) in keys(server.documents))
            uri3 = string("untitled:",b.loc.file)
            if URI2(uri3) in keys(server.documents)
                uri2 = uri3
            else
                return
            end
        end
        doc2 = server.documents[URI2(uri2)]
        push!(locations, Location(uri2, Range(doc2, b.loc.offset .+ b.val.span)))
    elseif b.val isa Function
        for m in methods(b.val)
            file = isabspath(string(m.file)) ? string(m.file) : Base.find_source_file(string(m.file))
            if (file, m.line) == DefaultTypeConstructorLoc || file == nothing
                continue
            end
            push!(locations, Location(filepath2uri(file), Range(m.line - 1, 0, m.line, 0)))
        end
    end
end


text:
using YaoBlocks, SymEngine, LuxurySparse, LinearAlgebra

Base.promote_rule(::Type{Bool}, ::Type{Basic}) = Basic
Base.conj(x::Basic) = real(x) - imag(x)

const SymReal = Union{Basic, SymEngine.BasicRealNumber}
YaoBlocks.RotationGate(block::GT, theta::T) where {N, T <: SymReal, GT<:AbstractBlock{N}} = RotationGate{N, T, GT}(block, theta)

YaoBlocks.phase(θ::SymReal) = PhaseGate(θ)
YaoBlocks.shift(θ::SymReal) = ShiftGate(θ)

YaoBlocks.mat(::Type{Basic}, ::HGate) = 1/sqrt(Basic(2)) * Basic[1 1;1 -1]
YaoBlocks.mat(::Type{Basic}, ::XGate) = Basic[0 1;1 0]
YaoBlocks.mat(::Type{Basic}, ::YGate) = Basic[0 -1im;1im 0]
YaoBlocks.mat(::Type{Basic}, ::ZGate) = Basic[1 0;0 -1]

YaoBlocks.mat(gate::ShiftGate{<:SymReal}) =
    Diagonal([1.0, exp(im * gate.theta)])
YaoBlocks.mat(gate::PhaseGate{<:SymReal}) =
    exp(im * gate.theta) * IMatrix{2}()
function YaoBlocks.mat(R::RotationGate{N, <:SymReal}) where N
    I = IMatrix{1<<N}()
    return I * cos(R.theta / 2) - im * sin(R.theta / 2) * mat(Basic,R.block)
end

YaoBlocks.PSwap{N}(locs::Tuple{Int, Int}, θ::SymReal) where N = YaoBlocks.PutBlock{N}(rot(ConstGate.SWAPGate(), θ), locs)

YaoBlocks.pswap(n::Int, i::Int, j::Int, α::SymReal) = PSwap{n}((i,j), α)
YaoBlocks.pswap(i::Int, j::Int, α::SymReal) = n->pswap(n,i,j,α)


text:
#=move.jl - Updates the game file with a move, accepts 1 command line argument,<filename> => database
=#
include("square.jl")
  include("dParse.jl")

module move_cheat
using ST
  using dParse

  using SQLite

  #=----Parses the database and determines where pieces are on the board----=#

  #= ---- Opens the Database for reading ---- =#
  database = ARGS[1] #/path/to/database/file {string}
  db = SQLite.DB(database) #Opens the database gamefile

  #= ---- Determines whos turn it is (white or black) ---- =#

  res = SQLite.query(db, """SELECT max("move_number") from moves;""") #Finds the last played move (maximum move_number)
  lastMoveIDNullable = res[1,1] #SQL query with max move_number (POSSIBLY "NULL" if no moves have been made)

  if (!isnull(lastMoveIDNullable)) #Checks that lastMoveID was not NULL
    lastMoveID = get(res[1,1])#Parses the last move move_number as an Int

  else #lastMoveID is NULL
    lastMoveID = 0 #move_number "0" is unsused. This implies no moves have been made

  end

  #=---- Determines a move to make (AI integration below)----=#
  move_number = lastMoveID+1 #The current move is move#: move_number

  function isCheck()
    if (even(move_number) == true)
      team = "w"
    else
      team = "b"

    #first finds the x y coordinates of king
    for x in 1:9
      for y in 1:9
        if (k(board[x][y]) == true) #there's a king
          if board[x][y].team == team
            kingx = x
            kingy = y
          end
        end
      end
    end

    for x in 1:9
      for y in 1:9
        if (isEmpty(board[x][y]) == false)
          unit = board[x][y].piece
          team = board[x][y].team
          if (moveValidate(unit, "move", team, x, y, kingx, kingy) == true)
            return true #resign
          end
        end
      end
    end
    return false
  end

  end

#=
  #Todo: write AI: must define variables: move_type, sourcex, sourcey, targetx, targety, option, i_am_cheating

  # get all of our pieces on board set numbers to them  ####if piece is our piece its choosable

  create array

  # check every square if empty square dont add to list, if piece colour = opponent dont add, if ours add

  if piece colour = our colour add to list
  create temppiece

  # choose random piece from list based on random number from list (rand mod listend)

  find array length
  do temppiece = rand % arraylength

  # set temp piece to it
  # use validate file to see what moves it can make, number them, put them in a list  ####movevalidate

  create another array, if piece -> target = movevalidate, add to list,

  # make a move based on random number from list (rand mod listend)

  makemove = rand % array2length

 #random number part
 #use random function mod max val it can be
=#

#=
if isCheck == true
  SQLite.query(db,"INSERT INTO moves (move_number, move_type, sourcex, sourcey, targetx, targety, option, i_am_cheating)
  VALUES ($(move_number),$(move_type),$sourcex, $sourcey,$targetx, $targety, $option, $(i_am_cheating));")
=#

  # ---- Saves the determined move in the database ---- =#
  SQLite.query(db,"INSERT INTO moves (move_number, move_type)
  VALUES ($(move_number),'resign');")
#=
  SQLite.query(db,"""INSERT INTO moves (move_number, move_type, sourcex, sourcey, targetx, targety, option, i_am_cheating)
  VALUES ("$(move_number)","$(move_type)","$sourcex","$sourcey","$targetx","$targety", "$option", "$(i_am_cheating)")""";)
=#

end

max_stars_repo_name: kinoroy/Shogi

max_issues_repo_name: kinoroy/Shulia

max_forks_repo_name: kinoroy/Shulia


text:
using Pkg
using SafeTestsets
const LONGER_TESTS = false

const GROUP = get(ENV, "GROUP", "All")
const is_APPVEYOR = Sys.iswindows() && haskey(ENV,"APPVEYOR")

@time begin

if GROUP == "All" || GROUP == "Interface"
  #@time @safetestset "Linear Solver Tests" begin include("interface/linear_solver_test.jl") end
  @time @safetestset "Basic Tests + Some AD" begin include("basictests.jl") end
end

end


text:
const IdProp = Tuple{Symbol, Symbol}

struct CallbackId
    state ::Vector{IdProp}
    input ::Vector{IdProp}
    output ::Vector{IdProp}
end

CallbackId(;input,
            output,
            state = Vector{IdProp}()
            ) = CallbackId(state, input, output)

Base.convert(::Type{Vector{IdProp}}, v::IdProp) = [v]
struct ClientsideFunction
    namespace ::String
    function_name ::String
end
struct Callback
    func ::Union{Function, ClientsideFunction}
    id ::CallbackId
end

struct PreventUpdate <: Exception

end

struct NoUpdate
end

no_update() = NoUpdate()

const ExternalSrcType = Union{String, Dict{String, String}}


text:
#!/usr/bin/env julia

using Test
using EAGO, JuMP, MathOptInterface, Ipopt, ForwardDiff
using IntervalArithmetic, SpecialFunctions
const MOI = MathOptInterface
using ForwardDiff: Dual, Partials

include("branch_bound.jl")
include("domain_reduction.jl")
include("optimizer.jl")
include("script_optimizer.jl")
include("semiinfinite.jl")


text:
macro FZ_RL()#(N, F_yf, F_yr, V, Ax, R)
	code=quote
		# define the lateral tire forces
		F_yf = @F_YF()
		F_yr = @F_YR()
		FZ_rl = zeros(length(Ax),1)
		for ii in eachindex(Ax)
			FZ_rl[ii] = 0.5*(FzR0 + KZX*(Ax[ii] - V[ii]*R[ii])) - KZYR*((F_yf[ii] + F_yr[ii])/m)
		end
		FZ_rl
	end
	return esc(code)
end


text:
module GPLinearODEMaker

using LinearAlgebra
using SpecialFunctions
using Random
using Distributed
using SharedArrays
using SymEngine
using IterativeSolvers
using Statistics

import Base.ndims

include("general_functions.jl")
include("GLO_functions.jl")
include("gp_functions.jl")
include("prior_functions.jl")
include("kernel_base_functions.jl")
include("kernel_creation_functions.jl")
include("diagnostic_functions.jl")

end # module

max_stars_repo_name: christiangil/GPLinearODEMaker

max_issues_repo_name: christiangil/GPLinearODEMaker

max_forks_repo_name: christiangil/GPLinearODEMaker


text:
"""
	$(SIGNATURES)

Information for one symbol: name, latex symbol, description, group.

For printing: `\\` needs to be escaped as `\\\\` in `latex`.
"""
struct SymbolInfo
    name :: Symbol
    latex :: String
    description :: String
    group :: String
end

"""
	$(SIGNATURES)

Constructor from strings.

# Arguments:
- name
- latex symbol
- description
- group
"""
SymbolInfo(name :: AbstractString, l :: AbstractString,
    d :: AbstractString, g :: AbstractString) =
    SymbolInfo(Symbol(name), l, d, g);

Base.show(io :: IO, si :: SymbolInfo) =
    print(io, "Symbol $(si.name)");

description(si :: SymbolInfo) = si.description;
group(si :: SymbolInfo) = si.group;
latex(si :: SymbolInfo) = si.latex;

"""
	$(SIGNATURES)

Make a latex `\\newcommand` from a symbol.

# Example
```
println(io, "% ", description(si));
println(io, newcommand(si));
```
"""
newcommand(si :: SymbolInfo) =
    "\\newcommand{\\$(si.name)}{$(latex(si))}";

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


text:
## Copyright (c) 2015, Júlio Hoffimann Mendes <juliohm@stanford.edu>
##
## Permission to use, copy, modify, and/or distribute this software for any
## purpose with or without fee is hereby granted, provided that the above
## copyright notice and this permission notice appear in all copies.
##
## THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
## WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
## ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
## ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
## OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

function imfilter_cpu{T<:Real,K<:Real,N}(img::AbstractArray{T,N}, kern::AbstractArray{K,N})
  imfilter(img, centered(kern), Inner(), Algorithm.FFT())
end


text:
using Pastebin
using Base.Test

# write your own tests here
@test 5 == 5


text:
@testset "general: single input" begin
    for x in (1.0, -1.0, 0.0, 0.5, 10.0, -17.1, 1.5 + 0.7im)
        test_scalar(SpecialFunctions.erf, x)
        test_scalar(SpecialFunctions.erfc, x)
        test_scalar(SpecialFunctions.erfi, x)

        test_scalar(SpecialFunctions.airyai, x)
        test_scalar(SpecialFunctions.airyaiprime, x)
        test_scalar(SpecialFunctions.airybi, x)
        test_scalar(SpecialFunctions.airybiprime, x)

        test_scalar(SpecialFunctions.erfcx, x)
        test_scalar(SpecialFunctions.dawson, x)

        if x isa Real
            test_scalar(SpecialFunctions.invdigamma, x)
        end

        if x isa Real && 0 < x < 1
            test_scalar(SpecialFunctions.erfinv, x)
            test_scalar(SpecialFunctions.erfcinv, x)
        end

        if x isa Real && x > 0 || x isa Complex
            test_scalar(SpecialFunctions.gamma, x)
            test_scalar(SpecialFunctions.digamma, x)
            test_scalar(SpecialFunctions.trigamma, x)
        end
    end
end

@testset "Bessel functions" begin
    for x in (1.5, 2.5, 10.5, -0.6, -2.6, -3.3, 1.6 + 1.6im, 1.6 - 1.6im, -4.6 + 1.6im)
        test_scalar(SpecialFunctions.besselj0, x)
        test_scalar(SpecialFunctions.besselj1, x)

        isreal(x) && x < 0 && continue

        test_scalar(SpecialFunctions.bessely0, x)
        test_scalar(SpecialFunctions.bessely1, x)

        for nu in (-1.5, 2.2, 4.0)
            test_frule(SpecialFunctions.besseli, nu, x)
            test_rrule(SpecialFunctions.besseli, nu, x)

            test_frule(SpecialFunctions.besselj, nu, x)
            test_rrule(SpecialFunctions.besselj, nu, x)

            test_frule(SpecialFunctions.besselk, nu, x)
            test_rrule(SpecialFunctions.besselk, nu, x)

            test_frule(SpecialFunctions.bessely, nu, x)
            test_rrule(SpecialFunctions.bessely, nu, x)

            # use complex numbers in `rrule` for FiniteDifferences
            test_frule(SpecialFunctions.hankelh1, nu, x)
            test_rrule(SpecialFunctions.hankelh1, nu, complex(x))

            # use complex numbers in `rrule` for FiniteDifferences
            test_frule(SpecialFunctions.hankelh2, nu, x)
            test_rrule(SpecialFunctions.hankelh2, nu, complex(x))
        end
    end
end

@testset "beta and logbeta" begin
    test_points = (1.5, 2.5, 10.5, 1.6 + 1.6im, 1.6 - 1.6im, 4.6 + 1.6im)
    for _x in test_points, _y in test_points
        # ensure all complex if any complex for FiniteDifferences
        x, y = promote(_x, _y)
        test_frule(SpecialFunctions.beta, x, y)
        test_rrule(SpecialFunctions.beta, x, y)

        if isdefined(SpecialFunctions, :lbeta)
            test_frule(SpecialFunctions.lbeta, x, y)
            test_rrule(SpecialFunctions.lbeta, x, y)
        end

        if isdefined(SpecialFunctions, :logbeta)
            test_frule(SpecialFunctions.logbeta, x, y)
            test_rrule(SpecialFunctions.logbeta, x, y)
        end
    end
end

@testset "log gamma and co" begin
    # It is important that we have negative numbers with both odd and even integer parts
    for x in (1.5, 2.5, 10.5, -0.6, -2.6, -3.3, 1.6 + 1.6im, 1.6 - 1.6im, -4.6 + 1.6im)
        for m in (0, 1, 2, 3)
            test_frule(SpecialFunctions.polygamma, m, x)
            test_rrule(SpecialFunctions.polygamma, m, x)
        end

        if isdefined(SpecialFunctions, :lgamma)
            test_scalar(SpecialFunctions.lgamma, x)
        end

        if isdefined(SpecialFunctions, :loggamma)
            isreal(x) && x < 0 && continue
            test_scalar(SpecialFunctions.loggamma, x)
        end

        if isdefined(SpecialFunctions, :logabsgamma)
            isreal(x) || continue
            test_frule(SpecialFunctions.logabsgamma, x)
            test_rrule(SpecialFunctions.logabsgamma, x; output_tangent=(randn(), randn()))
        end
    end
end


text:
# This file is a part of SimilaritySearch.jl
# License is Apache 2.0: https://www.apache.org/licenses/LICENSE-2.0.txt

include("testbits.jl")
include("testresults.jl")
include("testdistances.jl")
include("knr/testkvp.jl")
include("knr/testknr.jl")
include("graph/testsearchgraph.jl")


text:
@testset "GRclassic" begin
    b = 1
    M0 = 0.5
    d = GRclassic(b,M0)

    @test rate(d) == 1*log(10)
    @test location(d) == M0
    @test params(d) == (b, M0)

    @test  bvalue(d) == 1.
    @test  avalue(d, 100, 0.1) == 2.55

    @test  rand(d, 3) == [0.6547030177365674, 0.8281037053138567, 0.7333794310588824]
    @test  mean(d) == 1/rate(d) + M0

    @test pdf(d, 0.1) == 0.0
    @test round(pdf(d, 1.2), digits=2) == 0.46

    @test logpdf(d, 0.1) == -Inf
    @test round(logpdf(d,1.2), digits=2) == -0.78

    @test cdf(d, 0.1) == 0.0
    @test round(cdf(d,1.2), digits=2) == 0.8

    @test logcdf(d, 0.1) == -Inf
    @test round(logcdf(d,1.2), digits=2) == round(log(cdf(d,1.2)), digits=2)

    @test ccdf(d, 0.1) == 0.0
    @test round(ccdf(d,1.2), digits=2) == 0.2

    @test logccdf(d, 0.1) == -Inf
    @test round(logccdf(d,1.2), digits=2) == round(log(ccdf(d,1.2)), digits=2)

end


text:
export SpectrumArray, SpectrumDomain, unify_domains, tologfreq

# ----- SpectrumArray ---------------------------
const SpectrumDomain = Union{AbstractVector{<:Frequency}, AbstractRange{<:Frequency}}
const SpectrumDomainReal = Union{AbstractVector{<:Real}, AbstractRange{<:Real}}

struct SpectrumArray{T,F<:SpectrumDomainReal} <: AbstractSpectrumArray{T}
    data::Matrix{T} # non-interleaving frequencies x channels
    rate::Float64 # original sampling rate
    freqs::F # in Hz
    names::Vector{Symbol}

    function SpectrumArray{T,F}(data::Matrix{T}, rate::Float64, freqs::F, names::Vector{Symbol}) where {T,F}
        if length(freqs) != size(data, 1)
            throw(DimensionMismatch("data size $(size(data, 1)) does not match the number of frequencies $(length(freqs))"))
        end
        _check_channel_names(names)
        length(names) == size(data, 2) || throw(DimensionMismatch("the number of names ($(length(names))) does not match the number of channels ($(size(data, 2)))!"))
        length(unique(freqs)) == length(freqs) || throw(ArgumentError("non-unique freqs!"))
        new{T,F}(data, rate, freqs, copy(names))
    end
end

function SpectrumArray(X::AbstractMatrix{T}, rate::Frequency, freqs::SpectrumDomain, names::Union{Nothing,Vector{Symbol}}=nothing) where {T}
    freqs_ = toHz(freqs)
    F = typeof(freqs_)
    SpectrumArray{T,F}(X, toHz(rate), freqs_, isnothing(names) ? _default_channel_names(size(X, 2)) : names)
end

SpectrumArray(X::AbstractVector{T}, rate::Frequency, freqs::F, names::Union{Nothing,Vector{Symbol}}=nothing) where {T, F<:SpectrumDomain} =
    SpectrumArray(reshape(X, :, 1), rate, freqs, names)

domain(X::SpectrumArray) = X.freqs
_findno0freqs(X::SpectrumArray) = findall(!iszero, domain(X))
data_no0(X::SpectrumArray) = @view data(X)[_findno0freqs(X), :]
domain_no0(X::SpectrumArray) = @view domain(X)[_findno0freqs(X)]

function unify_domains(Xs::SpectrumArray...)
    cdom = intersect((Set(domain(X)) for X in Xs)...)
    [X[[d in cdom for d in domain(X)],:] for X in Xs]
end

function toindex(X::SpectrumArray{T}, t::Frequency) where T
    diffs = abs.(domain(X) .- toHz(t))
    findmin(diffs)[2]
end

function Base.similar(X::SpectrumArray, t::Type{T}, dims::Dims, freqs::SpectrumDomain) where T
    # tries to copy channel names
    # if there are fever names in the source array use default ones
    # TODO: move to abstracttypes.jl?
    # println("SIMILAR $(dims[2]) $(nchannels(x))")
    dims[1] != length(freqs) && throw(DimensionMismatch("the number of frequencies/frames ($(length(freqs))) does not match the target dimension ($(dims[1]))!"))
    ns = dims[2] ≤ nchannels(X) ? X.names[1:dims[2]] : _default_channel_names(dims[2])
    SpectrumArray(similar(data(X), t, dims), rate(X), freqs, ns)
end

function Base.similar(X::SpectrumArray, t::Type{T}, dims::Dims) where T
    dims[1] != nframes(X) && throw(DimensionMismatch("the number of frequencies/frames of source array ($(nframes(X))) does not match the target dimension ($(dims[1]))! You may want to use: similar(X, t, dims, freqs)."))
    similar(X, t, dims, domain(X))
end

# redefined so frequencies & channel names are treated
function Base.getindex(X::SpectrumArray{T,F}, I::R, J::S) where {T, F, R <: FrameIndex, S <: ChannelIndex}
    I2 = toframeidx(X, I)
    J2 = tochannelidx(X, J)
    freqs_ = domain(X)[I2]
    names_ = names(X)[J2]
    data_ = data(X)[I2, J2]
    SpectrumArray{T,F}(data_, rate(X), freqs_, names_)
end

Base.getindex(X::SpectrumArray{T}, I::R) where {T, R <: FrameIndex} = X[I, :]

function Base.hcat(X::SpectrumArray...)
    length(unique(rate.(X))) == 1 || throw(ArgumentError("hcat: non-unique rates!"))
    length(unique(nframes.(X))) == 1 || throw(DimensionMismatch("hcat: non-unique number of frames!"))
    length(unique(domain.(X))) == 1 || throw(ArgumentError("hcat: non-unique domains!"))
    newnames = _unique_channel_names(X...)
    data_ = hcat(map(data, X)...)
    rate_ = rate(X[1])
    domain_ = domain(X[1])
    return SpectrumArray{eltype(data_),typeof(domain_)}(data_, rate_, domain_, newnames) # eltype gives common supertype
end

function Base.vcat(X::SpectrumArray...)
    # union of the frequences must be unique or vcat should fail in array's constructor
    length(unique(rate.(X))) == 1 || throw(ArgumentError("vcat: non-unique rates!"))
    namelists = names.(X)
    length(unique(namelists)) == 1 || throw(ArgumentError("vcat: non-unique channel names!"))
    data_ = vcat(map(data, X)...)
    freqs_ = vcat(map(domain, X)...)
    return SpectrumArray{eltype(data_),typeof(freqs_)}(data_, rate(X[1]), freqs_, namelists[1])
end

function Base.show(io::IO, ::MIME"text/plain", X::SpectrumArray{T}) where T
    d = domain(X)
    clist = join([":$(n)" for n in names(X)], ", ")
    print(io, "SpectrumArray{$T}: $(nchannels(X)) channels: $(clist)\n $(nframes(X)) freqs $(first(d)) - $(last(d)) Hz, sampled at $(rate(X)) Hz:\n ")
    print(io, data(X))
end

function tologfreq(X::AbstractSpectrumArray, ppo::Real, extrapolation_bc=Line())
    data_ = data_no0(X)
    domain_ = domain_no0(X)
    l, u = extrema(domain_)
    nocts = log2(u/l)
    n = round(Int, (ppo-1) * nocts + 1)
    freqs = [2^x for x in range(log2(l), log2(u), length=n)]
    data = similar(data_, n, nchannels(X))
    for i in 1:nchannels(X)
        int = LinearInterpolation(domain_, data_[:, i]; extrapolation_bc=extrapolation_bc)
        data[:, i] = int(freqs)
    end
    SpectrumArray(data, rate(X), freqs)
end


text:
using LCMPolynomials
using TypedPolynomials
using Base.Test

@testset "LCMPolynomials" begin
    @testset "cubic spline segments" begin
        srand(1)
        for i in 1:1000
            x0 = randn()
            xd0 = randn()
            xf = randn()
            xdf = randn()
            dt = randn()
            p = cubic_spline(dt, x0, xf, xd0, xdf)
            @test isapprox(p(0), x0)
            @test isapprox(p(dt), xf)
            pd = differentiate(p)
            @test isapprox(pd(0), xd0)
            @test isapprox(pd(dt), xdf)
        end
    end

    @testset "cubic splines" begin
        srand(10)
        for i in 1:1000
            N = rand(2:10)
            dts = rand(N - 1) .+ 0.1
            ts = vcat(0, cumsum(dts))
            xs = randn(N)
            xds = randn(N)
            pp = cubic_spline(ts, xs, xds)
            ppd = differentiate.(pp)
            for i in 1:N-1
                @test isapprox(pp(ts[i]), xs[i])
                @test isapprox(ppd(ts[i]), xds[i])
            end
            @test isapprox(pp(ts[end] - 1e-12), xs[end], rtol=1e-6)
            @test isapprox(ppd(ts[end] - 1e-12), xds[end], rtol=1e-6)
            @test isapprox(LCMPolynomials.from_below(pp, ts[end]), xs[end])
            @test isapprox(LCMPolynomials.from_below(ppd, ts[end]), xds[end])
        end
    end

    @testset "LCM construction" begin
        N = rand(2:10)
        dts = rand(N - 1) .+ 0.1
        ts = vcat(0, cumsum(dts))
        xs = randn(N)
        xds = randn(N)
        pp = cubic_spline(ts, xs, xds)
        msg = piecewise_polynomial_t(pp)
        msg2 = piecewise_polynomial_t([pp, pp])
    end
end


text:
isTree(g::LG.AbstractGraph) = nv(g) == ne(g)+1 && is_connected(g)
isFloating(diforest::LG.SimpleDiGraph, i::Int) = i ∈ S.rootsOfForest(diforest)

export isTree, isFloating

import Base.parent
function parent(diforest::LG.SimpleDiGraph, i::Int)
    # Forests guarantee all vertices only have a single incoming edge.
    parents = LightGraphs.inneighbors(diforest, i)
    @assert length(parents) <= 1
    return isempty(parents) ? nothing : first(parents)
end

function children(diforest::LG.SimpleDiGraph, i::Int)
  # Forests guarantee all vertices only have a single incoming edge.
  children = LightGraphs.outneighbors(diforest, i)
  return children
end

export parent, children

# Construct directed graph with n vertices and no edges.
function no_edge_graph(n::Int)::LG.SimpleDiGraph
    g = LG.SimpleDiGraph()
    LG.add_vertices!(g, n)
    g
end

# Construct directed graph with n vertices and edges specfied as a list of (parent, child) tuples.
function graph_with_edges(n::Int, edges)::LG.SimpleDiGraph
    g = LG.SimpleDiGraph()
    LG.add_vertices!(g, n)
    for (i,j) in edges
        LG.add_edge!(g, i, j)
    end
    g
end

export no_edge_graph, graph_with_edges

function getDownstream(tree::LG.SimpleGraph, e::LG.Edge) :: Set{Int}
    nodes = Set{Int}()
    _getDownstream!(nodes, tree, e)
    nodes
end

function _getDownstream!(nodes::Set{Int}, tree::LG.SimpleGraph, e::LG.Edge)
    i, j = src(e), dst(e)
    if !((j in neighbors(tree, i)) && (i in neighbors(tree, j)))
        error("No edge (i, j)")
    end
    push!(nodes, j)
    for n in neighbors(tree, j)
        if n != i
        _getDownstream!(nodes, tree, LG.Edge(j, n))
        end
    end
end

# Delete the edge from i->j and add an edge  from i->k.
function replaceEdge(tree::LG.SimpleGraph, i::Int, j::Int, k::Int)
    @assert has_edge(tree, LG.Edge(i, j))
    @assert k in getDownstream(tree, LG.Edge(i, j))
    newTree = deepcopy(tree)
    LG.rem_edge!(newTree, i, j)
    LG.add_edge!(newTree, i, k)
    newTree
end

# Peform a BFS from a specified node, to assign directions to each of the edges.
# Then, remove that specified node from the directed graph and return what is left behind.
function decapitate(tree::LG.SimpleGraph; root::Union{Int,Nothing}=nothing)
    root = isnothing(root) ? nv(tree) : root
    diforest = bfs_tree(tree, root)
    rem_vertex!(diforest, root)
    diforest
end

# Add a new node to a directed forest. Then, for each existing root node of the forest, add
# an edge from the newly added node to that root. This turns the forest into a tree.
function recapitate(diforest::LG.SimpleDiGraph)
    forestRoots = S.rootsOfForest(diforest)
    tree = LG.SimpleGraph(diforest)
    add_vertex!(tree)
    root = nv(tree)
    for forestRoot in forestRoots
        LG.add_edge!(tree, root, forestRoot)
    end
    @assert ne(tree) == nv(tree) - 1
    tree
end

function edges(g::LG.SimpleDiGraph)
    collect(LG.edges(g))
end

export no_edge_graph, graph_with_edges, isTree, decapitate, uniform_diforest, isFloating, edges


text:
import StateSpaceReconstruction:
	DelaunayTriangulation

function point_representatives(pts, DT::DelaunayTriangulation)
end