\(\int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx\) [28]

Optimal result
Mathematica [B] (verified)
Rubi [A] (verified)
Maple [A] (verified)
Fricas [B] (verification not implemented)
Sympy [F]
Maxima [A] (verification not implemented)
Giac [A] (verification not implemented)
Mupad [B] (verification not implemented)
Reduce [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 95 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a^2 \text {arctanh}(\cos (c+d x))}{2 d}-\frac {b^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}-\frac {2 a b \csc (c+d x)}{d}-\frac {a^2 \cot (c+d x) \csc (c+d x)}{2 d}+\frac {b^2 \sec (c+d x)}{d} \] Output:

-1/2*a^2*arctanh(cos(d*x+c))/d-b^2*arctanh(cos(d*x+c))/d+2*a*b*arctanh(sin 
(d*x+c))/d-2*a*b*csc(d*x+c)/d-1/2*a^2*cot(d*x+c)*csc(d*x+c)/d+b^2*sec(d*x+ 
c)/d
 

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(250\) vs. \(2(95)=190\).

Time = 1.62 (sec) , antiderivative size = 250, normalized size of antiderivative = 2.63 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {8 b^2-8 a b \cot \left (\frac {1}{2} (c+d x)\right )-a^2 \csc ^2\left (\frac {1}{2} (c+d x)\right )-4 \left (a^2+2 b^2\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )-16 a b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+4 \left (a^2+2 b^2\right ) \log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )+16 a b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+a^2 \sec ^2\left (\frac {1}{2} (c+d x)\right )+\frac {8 b^2 \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )}-\frac {8 b^2 \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )}-8 a b \tan \left (\frac {1}{2} (c+d x)\right )}{8 d} \] Input:

Integrate[Csc[c + d*x]^3*(a + b*Tan[c + d*x])^2,x]
 

Output:

(8*b^2 - 8*a*b*Cot[(c + d*x)/2] - a^2*Csc[(c + d*x)/2]^2 - 4*(a^2 + 2*b^2) 
*Log[Cos[(c + d*x)/2]] - 16*a*b*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + 
 4*(a^2 + 2*b^2)*Log[Sin[(c + d*x)/2]] + 16*a*b*Log[Cos[(c + d*x)/2] + Sin 
[(c + d*x)/2]] + a^2*Sec[(c + d*x)/2]^2 + (8*b^2*Sin[(c + d*x)/2])/(Cos[(c 
 + d*x)/2] - Sin[(c + d*x)/2]) - (8*b^2*Sin[(c + d*x)/2])/(Cos[(c + d*x)/2 
] + Sin[(c + d*x)/2]) - 8*a*b*Tan[(c + d*x)/2])/(8*d)
 

Rubi [A] (verified)

Time = 0.33 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3042, 4000, 2009}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(a+b \tan (c+d x))^2}{\sin (c+d x)^3}dx\)

\(\Big \downarrow \) 4000

\(\displaystyle \int \left (a^2 \csc ^3(c+d x)+2 a b \csc ^2(c+d x) \sec (c+d x)+b^2 \csc (c+d x) \sec ^2(c+d x)\right )dx\)

\(\Big \downarrow \) 2009

\(\displaystyle -\frac {a^2 \text {arctanh}(\cos (c+d x))}{2 d}-\frac {a^2 \cot (c+d x) \csc (c+d x)}{2 d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}-\frac {2 a b \csc (c+d x)}{d}-\frac {b^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {b^2 \sec (c+d x)}{d}\)

Input:

Int[Csc[c + d*x]^3*(a + b*Tan[c + d*x])^2,x]
 

Output:

-1/2*(a^2*ArcTanh[Cos[c + d*x]])/d - (b^2*ArcTanh[Cos[c + d*x]])/d + (2*a* 
b*ArcTanh[Sin[c + d*x]])/d - (2*a*b*Csc[c + d*x])/d - (a^2*Cot[c + d*x]*Cs 
c[c + d*x])/(2*d) + (b^2*Sec[c + d*x])/d
 

Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4000
Int[sin[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n 
_.), x_Symbol] :> Int[Expand[Sin[e + f*x]^m*(a + b*Tan[e + f*x])^n, x], x] 
/; FreeQ[{a, b, e, f}, x] && IntegerQ[(m - 1)/2] && IGtQ[n, 0]
 
Maple [A] (verified)

Time = 3.32 (sec) , antiderivative size = 101, normalized size of antiderivative = 1.06

method result size
derivativedivides \(\frac {b^{2} \left (\frac {1}{\cos \left (d x +c \right )}+\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )\right )+2 a b \left (-\frac {1}{\sin \left (d x +c \right )}+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+a^{2} \left (-\frac {\cot \left (d x +c \right ) \csc \left (d x +c \right )}{2}+\frac {\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )}{2}\right )}{d}\) \(101\)
default \(\frac {b^{2} \left (\frac {1}{\cos \left (d x +c \right )}+\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )\right )+2 a b \left (-\frac {1}{\sin \left (d x +c \right )}+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+a^{2} \left (-\frac {\cot \left (d x +c \right ) \csc \left (d x +c \right )}{2}+\frac {\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )}{2}\right )}{d}\) \(101\)
risch \(\frac {{\mathrm e}^{i \left (d x +c \right )} \left (a^{2} {\mathrm e}^{4 i \left (d x +c \right )}+2 b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-4 i a b \,{\mathrm e}^{4 i \left (d x +c \right )}+2 a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-4 b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+a^{2}+2 b^{2}+4 i a b \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )^{2} \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}+\frac {2 a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{d}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{2 d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right ) b^{2}}{d}-\frac {2 a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}{2 d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right ) b^{2}}{d}\) \(257\)

Input:

int(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)
 

Output:

1/d*(b^2*(1/cos(d*x+c)+ln(csc(d*x+c)-cot(d*x+c)))+2*a*b*(-1/sin(d*x+c)+ln( 
sec(d*x+c)+tan(d*x+c)))+a^2*(-1/2*cot(d*x+c)*csc(d*x+c)+1/2*ln(csc(d*x+c)- 
cot(d*x+c))))
 

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 230 vs. \(2 (91) = 182\).

Time = 0.12 (sec) , antiderivative size = 230, normalized size of antiderivative = 2.42 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {8 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + 2 \, {\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 4 \, b^{2} - {\left ({\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )^{3} - {\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )\right )} \log \left (\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) + {\left ({\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )^{3} - {\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )\right )} \log \left (-\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) + 4 \, {\left (a b \cos \left (d x + c\right )^{3} - a b \cos \left (d x + c\right )\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) - 4 \, {\left (a b \cos \left (d x + c\right )^{3} - a b \cos \left (d x + c\right )\right )} \log \left (-\sin \left (d x + c\right ) + 1\right )}{4 \, {\left (d \cos \left (d x + c\right )^{3} - d \cos \left (d x + c\right )\right )}} \] Input:

integrate(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="fricas")
 

Output:

1/4*(8*a*b*cos(d*x + c)*sin(d*x + c) + 2*(a^2 + 2*b^2)*cos(d*x + c)^2 - 4* 
b^2 - ((a^2 + 2*b^2)*cos(d*x + c)^3 - (a^2 + 2*b^2)*cos(d*x + c))*log(1/2* 
cos(d*x + c) + 1/2) + ((a^2 + 2*b^2)*cos(d*x + c)^3 - (a^2 + 2*b^2)*cos(d* 
x + c))*log(-1/2*cos(d*x + c) + 1/2) + 4*(a*b*cos(d*x + c)^3 - a*b*cos(d*x 
 + c))*log(sin(d*x + c) + 1) - 4*(a*b*cos(d*x + c)^3 - a*b*cos(d*x + c))*l 
og(-sin(d*x + c) + 1))/(d*cos(d*x + c)^3 - d*cos(d*x + c))
 

Sympy [F]

\[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{2} \csc ^{3}{\left (c + d x \right )}\, dx \] Input:

integrate(csc(d*x+c)**3*(a+b*tan(d*x+c))**2,x)
 

Output:

Integral((a + b*tan(c + d*x))**2*csc(c + d*x)**3, x)
 

Maxima [A] (verification not implemented)

Time = 0.04 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.28 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^{2} {\left (\frac {2 \, \cos \left (d x + c\right )}{\cos \left (d x + c\right )^{2} - 1} - \log \left (\cos \left (d x + c\right ) + 1\right ) + \log \left (\cos \left (d x + c\right ) - 1\right )\right )} + 2 \, b^{2} {\left (\frac {2}{\cos \left (d x + c\right )} - \log \left (\cos \left (d x + c\right ) + 1\right ) + \log \left (\cos \left (d x + c\right ) - 1\right )\right )} - 4 \, a b {\left (\frac {2}{\sin \left (d x + c\right )} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )}}{4 \, d} \] Input:

integrate(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="maxima")
 

Output:

1/4*(a^2*(2*cos(d*x + c)/(cos(d*x + c)^2 - 1) - log(cos(d*x + c) + 1) + lo 
g(cos(d*x + c) - 1)) + 2*b^2*(2/cos(d*x + c) - log(cos(d*x + c) + 1) + log 
(cos(d*x + c) - 1)) - 4*a*b*(2/sin(d*x + c) - log(sin(d*x + c) + 1) + log( 
sin(d*x + c) - 1)))/d
 

Giac [A] (verification not implemented)

Time = 0.24 (sec) , antiderivative size = 172, normalized size of antiderivative = 1.81 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 16 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 16 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) - 8 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 4 \, {\left (a^{2} + 2 \, b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) \right |}\right ) - \frac {16 \, b^{2}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1} - \frac {6 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 12 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 8 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + a^{2}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2}}}{8 \, d} \] Input:

integrate(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="giac")
 

Output:

1/8*(a^2*tan(1/2*d*x + 1/2*c)^2 + 16*a*b*log(abs(tan(1/2*d*x + 1/2*c) + 1) 
) - 16*a*b*log(abs(tan(1/2*d*x + 1/2*c) - 1)) - 8*a*b*tan(1/2*d*x + 1/2*c) 
 + 4*(a^2 + 2*b^2)*log(abs(tan(1/2*d*x + 1/2*c))) - 16*b^2/(tan(1/2*d*x + 
1/2*c)^2 - 1) - (6*a^2*tan(1/2*d*x + 1/2*c)^2 + 12*b^2*tan(1/2*d*x + 1/2*c 
)^2 + 8*a*b*tan(1/2*d*x + 1/2*c) + a^2)/tan(1/2*d*x + 1/2*c)^2)/d
 

Mupad [B] (verification not implemented)

Time = 0.92 (sec) , antiderivative size = 292, normalized size of antiderivative = 3.07 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{8\,d}+\frac {\ln \left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )\,\left (\frac {a^2}{2}+b^2\right )}{d}+\frac {{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\,\left (\frac {a^2}{2}+8\,b^2\right )-\frac {a^2}{2}+4\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3-4\,a\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d\,\left (4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4\right )}+\frac {4\,a\,b\,\mathrm {atanh}\left (\frac {8\,a\,b^3\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{4\,a^3\,b-16\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,a^2\,b^2+8\,a\,b^3}-\frac {16\,a^2\,b^2}{4\,a^3\,b-16\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,a^2\,b^2+8\,a\,b^3}+\frac {4\,a^3\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{4\,a^3\,b-16\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,a^2\,b^2+8\,a\,b^3}\right )}{d}-\frac {a\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d} \] Input:

int((a + b*tan(c + d*x))^2/sin(c + d*x)^3,x)
 

Output:

(a^2*tan(c/2 + (d*x)/2)^2)/(8*d) + (log(tan(c/2 + (d*x)/2))*(a^2/2 + b^2)) 
/d + (tan(c/2 + (d*x)/2)^2*(a^2/2 + 8*b^2) - a^2/2 + 4*a*b*tan(c/2 + (d*x) 
/2)^3 - 4*a*b*tan(c/2 + (d*x)/2))/(d*(4*tan(c/2 + (d*x)/2)^2 - 4*tan(c/2 + 
 (d*x)/2)^4)) + (4*a*b*atanh((8*a*b^3*tan(c/2 + (d*x)/2))/(8*a*b^3 + 4*a^3 
*b - 16*a^2*b^2*tan(c/2 + (d*x)/2)) - (16*a^2*b^2)/(8*a*b^3 + 4*a^3*b - 16 
*a^2*b^2*tan(c/2 + (d*x)/2)) + (4*a^3*b*tan(c/2 + (d*x)/2))/(8*a*b^3 + 4*a 
^3*b - 16*a^2*b^2*tan(c/2 + (d*x)/2))))/d - (a*b*tan(c/2 + (d*x)/2))/d
 

Reduce [B] (verification not implemented)

Time = 0.22 (sec) , antiderivative size = 225, normalized size of antiderivative = 2.37 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {-16 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) \sin \left (d x +c \right )^{2} a b +16 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) \sin \left (d x +c \right )^{2} a b +4 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right ) \sin \left (d x +c \right )^{2} a^{2}+8 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right ) \sin \left (d x +c \right )^{2} b^{2}-\cos \left (d x +c \right ) \sin \left (d x +c \right )^{2} a^{2}-8 \cos \left (d x +c \right ) \sin \left (d x +c \right )^{2} b^{2}-16 \cos \left (d x +c \right ) \sin \left (d x +c \right ) a b +4 \sin \left (d x +c \right )^{2} a^{2}+8 \sin \left (d x +c \right )^{2} b^{2}-4 a^{2}}{8 \cos \left (d x +c \right ) \sin \left (d x +c \right )^{2} d} \] Input:

int(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x)
 

Output:

( - 16*cos(c + d*x)*log(tan((c + d*x)/2) - 1)*sin(c + d*x)**2*a*b + 16*cos 
(c + d*x)*log(tan((c + d*x)/2) + 1)*sin(c + d*x)**2*a*b + 4*cos(c + d*x)*l 
og(tan((c + d*x)/2))*sin(c + d*x)**2*a**2 + 8*cos(c + d*x)*log(tan((c + d* 
x)/2))*sin(c + d*x)**2*b**2 - cos(c + d*x)*sin(c + d*x)**2*a**2 - 8*cos(c 
+ d*x)*sin(c + d*x)**2*b**2 - 16*cos(c + d*x)*sin(c + d*x)*a*b + 4*sin(c + 
 d*x)**2*a**2 + 8*sin(c + d*x)**2*b**2 - 4*a**2)/(8*cos(c + d*x)*sin(c + d 
*x)**2*d)