\(\int \cot ^2(c+d x) (a+b \tan (c+d x))^3 (B \tan (c+d x)+C \tan ^2(c+d x)) \, dx\) [19]

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

Optimal result

Integrand size = 40, antiderivative size = 117 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\left (3 a^2 b B-b^3 B+a^3 C-3 a b^2 C\right ) x-\frac {b \left (3 a b B+3 a^2 C-b^2 C\right ) \log (\cos (c+d x))}{d}+\frac {a^3 B \log (\sin (c+d x))}{d}+\frac {b^2 (b B+2 a C) \tan (c+d x)}{d}+\frac {b C (a+b \tan (c+d x))^2}{2 d} \] Output:

(3*B*a^2*b-B*b^3+C*a^3-3*C*a*b^2)*x-b*(3*B*a*b+3*C*a^2-C*b^2)*ln(cos(d*x+c 
))/d+a^3*B*ln(sin(d*x+c))/d+b^2*(B*b+2*C*a)*tan(d*x+c)/d+1/2*b*C*(a+b*tan( 
d*x+c))^2/d
                                                                                    
                                                                                    
 

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.33 (sec) , antiderivative size = 113, normalized size of antiderivative = 0.97 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {-(a+i b)^3 (B+i C) \log (i-\tan (c+d x))+2 a^3 B \log (\tan (c+d x))-(a-i b)^3 (B-i C) \log (i+\tan (c+d x))+2 b^2 (b B+3 a C) \tan (c+d x)+b^3 C \tan ^2(c+d x)}{2 d} \] Input:

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

Output:

(-((a + I*b)^3*(B + I*C)*Log[I - Tan[c + d*x]]) + 2*a^3*B*Log[Tan[c + d*x] 
] - (a - I*b)^3*(B - I*C)*Log[I + Tan[c + d*x]] + 2*b^2*(b*B + 3*a*C)*Tan[ 
c + d*x] + b^3*C*Tan[c + d*x]^2)/(2*d)
 

Rubi [A] (verified)

Time = 1.43 (sec) , antiderivative size = 119, normalized size of antiderivative = 1.02, number of steps used = 13, number of rules used = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.325, Rules used = {3042, 4115, 3042, 4090, 27, 3042, 4120, 25, 3042, 4107, 3042, 25, 3956}

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 \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan (c+d x)^2\right )}{\tan (c+d x)^2}dx\)

\(\Big \downarrow \) 4115

\(\displaystyle \int \cot (c+d x) (a+b \tan (c+d x))^3 (B+C \tan (c+d x))dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4090

\(\displaystyle \frac {1}{2} \int 2 \cot (c+d x) (a+b \tan (c+d x)) \left (B a^2+b (b B+2 a C) \tan ^2(c+d x)+\left (C a^2+2 b B a-b^2 C\right ) \tan (c+d x)\right )dx+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 27

\(\displaystyle \int \cot (c+d x) (a+b \tan (c+d x)) \left (B a^2+b (b B+2 a C) \tan ^2(c+d x)+\left (C a^2+2 b B a-b^2 C\right ) \tan (c+d x)\right )dx+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(a+b \tan (c+d x)) \left (B a^2+b (b B+2 a C) \tan (c+d x)^2+\left (C a^2+2 b B a-b^2 C\right ) \tan (c+d x)\right )}{\tan (c+d x)}dx+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 4120

\(\displaystyle -\int -\cot (c+d x) \left (B a^3+b \left (3 C a^2+3 b B a-b^2 C\right ) \tan ^2(c+d x)+\left (C a^3+3 b B a^2-3 b^2 C a-b^3 B\right ) \tan (c+d x)\right )dx+\frac {b^2 (2 a C+b B) \tan (c+d x)}{d}+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 25

\(\displaystyle \int \cot (c+d x) \left (B a^3+b \left (3 C a^2+3 b B a-b^2 C\right ) \tan ^2(c+d x)+\left (C a^3+3 b B a^2-3 b^2 C a-b^3 B\right ) \tan (c+d x)\right )dx+\frac {b^2 (2 a C+b B) \tan (c+d x)}{d}+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {B a^3+b \left (3 C a^2+3 b B a-b^2 C\right ) \tan (c+d x)^2+\left (C a^3+3 b B a^2-3 b^2 C a-b^3 B\right ) \tan (c+d x)}{\tan (c+d x)}dx+\frac {b^2 (2 a C+b B) \tan (c+d x)}{d}+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 4107

\(\displaystyle a^3 B \int \cot (c+d x)dx+b \left (3 a^2 C+3 a b B-b^2 C\right ) \int \tan (c+d x)dx+x \left (a^3 C+3 a^2 b B-3 a b^2 C-b^3 B\right )+\frac {b^2 (2 a C+b B) \tan (c+d x)}{d}+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle a^3 B \int -\tan \left (c+d x+\frac {\pi }{2}\right )dx+b \left (3 a^2 C+3 a b B-b^2 C\right ) \int \tan (c+d x)dx+x \left (a^3 C+3 a^2 b B-3 a b^2 C-b^3 B\right )+\frac {b^2 (2 a C+b B) \tan (c+d x)}{d}+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 25

\(\displaystyle a^3 (-B) \int \tan \left (\frac {1}{2} (2 c+\pi )+d x\right )dx+b \left (3 a^2 C+3 a b B-b^2 C\right ) \int \tan (c+d x)dx+x \left (a^3 C+3 a^2 b B-3 a b^2 C-b^3 B\right )+\frac {b^2 (2 a C+b B) \tan (c+d x)}{d}+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

\(\Big \downarrow \) 3956

\(\displaystyle \frac {a^3 B \log (-\sin (c+d x))}{d}-\frac {b \left (3 a^2 C+3 a b B-b^2 C\right ) \log (\cos (c+d x))}{d}+x \left (a^3 C+3 a^2 b B-3 a b^2 C-b^3 B\right )+\frac {b^2 (2 a C+b B) \tan (c+d x)}{d}+\frac {b C (a+b \tan (c+d x))^2}{2 d}\)

Input:

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

Output:

(3*a^2*b*B - b^3*B + a^3*C - 3*a*b^2*C)*x - (b*(3*a*b*B + 3*a^2*C - b^2*C) 
*Log[Cos[c + d*x]])/d + (a^3*B*Log[-Sin[c + d*x]])/d + (b^2*(b*B + 2*a*C)* 
Tan[c + d*x])/d + (b*C*(a + b*Tan[c + d*x])^2)/(2*d)
 

Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

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

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4090
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + 
 (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Si 
mp[b*B*(a + b*Tan[e + f*x])^(m - 1)*((c + d*Tan[e + f*x])^(n + 1)/(d*f*(m + 
 n))), x] + Simp[1/(d*(m + n))   Int[(a + b*Tan[e + f*x])^(m - 2)*(c + d*Ta 
n[e + f*x])^n*Simp[a^2*A*d*(m + n) - b*B*(b*c*(m - 1) + a*d*(n + 1)) + d*(m 
 + n)*(2*a*A*b + B*(a^2 - b^2))*Tan[e + f*x] - (b*B*(b*c - a*d)*(m - 1) - b 
*(A*b + a*B)*d*(m + n))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, 
 f, A, B, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2 
, 0] && GtQ[m, 1] && (IntegerQ[m] || IntegersQ[2*m, 2*n]) &&  !(IGtQ[n, 1] 
&& ( !IntegerQ[m] || (EqQ[c, 0] && NeQ[a, 0])))
 

rule 4107
Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2 
)/tan[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[B*x, x] + (Simp[A   Int[1/Tan[ 
e + f*x], x], x] + Simp[C   Int[Tan[e + f*x], x], x]) /; FreeQ[{e, f, A, B, 
 C}, x] && NeQ[A, C]
 

rule 4115
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) 
+ (f_.)*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_ 
.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[1/b^2   Int[(a + b*Tan[e + f*x])^(m 
+ 1)*(c + d*Tan[e + f*x])^n*(b*B - a*C + b*C*Tan[e + f*x]), x], x] /; FreeQ 
[{a, b, c, d, e, f, A, B, C, m, n}, x] && NeQ[b*c - a*d, 0] && EqQ[A*b^2 - 
a*b*B + a^2*C, 0]
 

rule 4120
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f 
_.)*(x_)]^2), x_Symbol] :> Simp[b*C*Tan[e + f*x]*((c + d*Tan[e + f*x])^(n + 
 1)/(d*f*(n + 2))), x] - Simp[1/(d*(n + 2))   Int[(c + d*Tan[e + f*x])^n*Si 
mp[b*c*C - a*A*d*(n + 2) - (A*b + a*B - b*C)*d*(n + 2)*Tan[e + f*x] - (a*C* 
d*(n + 2) - b*(c*C - B*d*(n + 2)))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[c^2 + d^2, 0] && 
  !LtQ[n, -1]
 
Maple [A] (verified)

Time = 0.21 (sec) , antiderivative size = 121, normalized size of antiderivative = 1.03

method result size
parallelrisch \(\frac {\left (-B \,a^{3}+3 B a \,b^{2}+3 C \,a^{2} b -C \,b^{3}\right ) \ln \left (\sec \left (d x +c \right )^{2}\right )+2 B \,a^{3} \ln \left (\tan \left (d x +c \right )\right )+C \,b^{3} \tan \left (d x +c \right )^{2}+\left (2 B \,b^{3}+6 C a \,b^{2}\right ) \tan \left (d x +c \right )+6 x \left (B \,a^{2} b -\frac {1}{3} B \,b^{3}+\frac {1}{3} C \,a^{3}-C a \,b^{2}\right ) d}{2 d}\) \(121\)
derivativedivides \(\frac {\frac {C \,b^{3} \tan \left (d x +c \right )^{2}}{2}+B \,b^{3} \tan \left (d x +c \right )+3 C a \,b^{2} \tan \left (d x +c \right )+\frac {\left (-B \,a^{3}+3 B a \,b^{2}+3 C \,a^{2} b -C \,b^{3}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (3 B \,a^{2} b -B \,b^{3}+C \,a^{3}-3 C a \,b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )+B \,a^{3} \ln \left (\tan \left (d x +c \right )\right )}{d}\) \(130\)
default \(\frac {\frac {C \,b^{3} \tan \left (d x +c \right )^{2}}{2}+B \,b^{3} \tan \left (d x +c \right )+3 C a \,b^{2} \tan \left (d x +c \right )+\frac {\left (-B \,a^{3}+3 B a \,b^{2}+3 C \,a^{2} b -C \,b^{3}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (3 B \,a^{2} b -B \,b^{3}+C \,a^{3}-3 C a \,b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )+B \,a^{3} \ln \left (\tan \left (d x +c \right )\right )}{d}\) \(130\)
norman \(\frac {\left (3 B \,a^{2} b -B \,b^{3}+C \,a^{3}-3 C a \,b^{2}\right ) x \tan \left (d x +c \right )+\frac {b^{2} \left (B b +3 C a \right ) \tan \left (d x +c \right )^{2}}{d}+\frac {C \,b^{3} \tan \left (d x +c \right )^{3}}{2 d}}{\tan \left (d x +c \right )}+\frac {B \,a^{3} \ln \left (\tan \left (d x +c \right )\right )}{d}-\frac {\left (B \,a^{3}-3 B a \,b^{2}-3 C \,a^{2} b +C \,b^{3}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d}\) \(142\)
risch \(-i B \,a^{3} x +3 i B a \,b^{2} x +\frac {2 i b^{2} \left (B b \,{\mathrm e}^{2 i \left (d x +c \right )}+3 C a \,{\mathrm e}^{2 i \left (d x +c \right )}-i C b \,{\mathrm e}^{2 i \left (d x +c \right )}+B b +3 C a \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}+3 i C \,a^{2} b x +3 B \,a^{2} b x -B \,b^{3} x +C \,a^{3} x -3 C a \,b^{2} x -\frac {2 i B \,a^{3} c}{d}+\frac {6 i C \,a^{2} b c}{d}-\frac {2 i C \,b^{3} c}{d}-i C \,b^{3} x +\frac {6 i B a \,b^{2} c}{d}-\frac {3 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B a \,b^{2}}{d}-\frac {3 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) C \,a^{2} b}{d}+\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) C \,b^{3}}{d}+\frac {B \,a^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}{d}\) \(264\)

Input:

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

Output:

1/2*((-B*a^3+3*B*a*b^2+3*C*a^2*b-C*b^3)*ln(sec(d*x+c)^2)+2*B*a^3*ln(tan(d* 
x+c))+C*b^3*tan(d*x+c)^2+(2*B*b^3+6*C*a*b^2)*tan(d*x+c)+6*x*(B*a^2*b-1/3*B 
*b^3+1/3*C*a^3-C*a*b^2)*d)/d
 

Fricas [A] (verification not implemented)

Time = 0.09 (sec) , antiderivative size = 133, normalized size of antiderivative = 1.14 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {C b^{3} \tan \left (d x + c\right )^{2} + B a^{3} \log \left (\frac {\tan \left (d x + c\right )^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) + 2 \, {\left (C a^{3} + 3 \, B a^{2} b - 3 \, C a b^{2} - B b^{3}\right )} d x - {\left (3 \, C a^{2} b + 3 \, B a b^{2} - C b^{3}\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 2 \, {\left (3 \, C a b^{2} + B b^{3}\right )} \tan \left (d x + c\right )}{2 \, d} \] Input:

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

Output:

1/2*(C*b^3*tan(d*x + c)^2 + B*a^3*log(tan(d*x + c)^2/(tan(d*x + c)^2 + 1)) 
 + 2*(C*a^3 + 3*B*a^2*b - 3*C*a*b^2 - B*b^3)*d*x - (3*C*a^2*b + 3*B*a*b^2 
- C*b^3)*log(1/(tan(d*x + c)^2 + 1)) + 2*(3*C*a*b^2 + B*b^3)*tan(d*x + c)) 
/d
 

Sympy [A] (verification not implemented)

Time = 0.93 (sec) , antiderivative size = 211, normalized size of antiderivative = 1.80 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\begin {cases} - \frac {B a^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {B a^{3} \log {\left (\tan {\left (c + d x \right )} \right )}}{d} + 3 B a^{2} b x + \frac {3 B a b^{2} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - B b^{3} x + \frac {B b^{3} \tan {\left (c + d x \right )}}{d} + C a^{3} x + \frac {3 C a^{2} b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 3 C a b^{2} x + \frac {3 C a b^{2} \tan {\left (c + d x \right )}}{d} - \frac {C b^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {C b^{3} \tan ^{2}{\left (c + d x \right )}}{2 d} & \text {for}\: d \neq 0 \\x \left (a + b \tan {\left (c \right )}\right )^{3} \left (B \tan {\left (c \right )} + C \tan ^{2}{\left (c \right )}\right ) \cot ^{2}{\left (c \right )} & \text {otherwise} \end {cases} \] Input:

integrate(cot(d*x+c)**2*(a+b*tan(d*x+c))**3*(B*tan(d*x+c)+C*tan(d*x+c)**2) 
,x)
 

Output:

Piecewise((-B*a**3*log(tan(c + d*x)**2 + 1)/(2*d) + B*a**3*log(tan(c + d*x 
))/d + 3*B*a**2*b*x + 3*B*a*b**2*log(tan(c + d*x)**2 + 1)/(2*d) - B*b**3*x 
 + B*b**3*tan(c + d*x)/d + C*a**3*x + 3*C*a**2*b*log(tan(c + d*x)**2 + 1)/ 
(2*d) - 3*C*a*b**2*x + 3*C*a*b**2*tan(c + d*x)/d - C*b**3*log(tan(c + d*x) 
**2 + 1)/(2*d) + C*b**3*tan(c + d*x)**2/(2*d), Ne(d, 0)), (x*(a + b*tan(c) 
)**3*(B*tan(c) + C*tan(c)**2)*cot(c)**2, True))
 

Maxima [A] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 124, normalized size of antiderivative = 1.06 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {C b^{3} \tan \left (d x + c\right )^{2} + 2 \, B a^{3} \log \left (\tan \left (d x + c\right )\right ) + 2 \, {\left (C a^{3} + 3 \, B a^{2} b - 3 \, C a b^{2} - B b^{3}\right )} {\left (d x + c\right )} - {\left (B a^{3} - 3 \, C a^{2} b - 3 \, B a b^{2} + C b^{3}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 2 \, {\left (3 \, C a b^{2} + B b^{3}\right )} \tan \left (d x + c\right )}{2 \, d} \] Input:

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

Output:

1/2*(C*b^3*tan(d*x + c)^2 + 2*B*a^3*log(tan(d*x + c)) + 2*(C*a^3 + 3*B*a^2 
*b - 3*C*a*b^2 - B*b^3)*(d*x + c) - (B*a^3 - 3*C*a^2*b - 3*B*a*b^2 + C*b^3 
)*log(tan(d*x + c)^2 + 1) + 2*(3*C*a*b^2 + B*b^3)*tan(d*x + c))/d
 

Giac [A] (verification not implemented)

Time = 0.70 (sec) , antiderivative size = 140, normalized size of antiderivative = 1.20 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {B a^{3} \log \left ({\left | \tan \left (d x + c\right ) \right |}\right )}{d} + \frac {{\left (C a^{3} + 3 \, B a^{2} b - 3 \, C a b^{2} - B b^{3}\right )} {\left (d x + c\right )}}{d} - \frac {{\left (B a^{3} - 3 \, C a^{2} b - 3 \, B a b^{2} + C b^{3}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{2 \, d} + \frac {C b^{3} d \tan \left (d x + c\right )^{2} + 6 \, C a b^{2} d \tan \left (d x + c\right ) + 2 \, B b^{3} d \tan \left (d x + c\right )}{2 \, d^{2}} \] Input:

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

Output:

B*a^3*log(abs(tan(d*x + c)))/d + (C*a^3 + 3*B*a^2*b - 3*C*a*b^2 - B*b^3)*( 
d*x + c)/d - 1/2*(B*a^3 - 3*C*a^2*b - 3*B*a*b^2 + C*b^3)*log(tan(d*x + c)^ 
2 + 1)/d + 1/2*(C*b^3*d*tan(d*x + c)^2 + 6*C*a*b^2*d*tan(d*x + c) + 2*B*b^ 
3*d*tan(d*x + c))/d^2
 

Mupad [B] (verification not implemented)

Time = 5.62 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.01 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (B\,b^3+3\,C\,a\,b^2\right )}{d}+\frac {B\,a^3\,\ln \left (\mathrm {tan}\left (c+d\,x\right )\right )}{d}+\frac {C\,b^3\,{\mathrm {tan}\left (c+d\,x\right )}^2}{2\,d}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B-C\,1{}\mathrm {i}\right )\,{\left (b+a\,1{}\mathrm {i}\right )}^3\,1{}\mathrm {i}}{2\,d}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (B+C\,1{}\mathrm {i}\right )\,{\left (-b+a\,1{}\mathrm {i}\right )}^3\,1{}\mathrm {i}}{2\,d} \] Input:

int(cot(c + d*x)^2*(B*tan(c + d*x) + C*tan(c + d*x)^2)*(a + b*tan(c + d*x) 
)^3,x)
 

Output:

(tan(c + d*x)*(B*b^3 + 3*C*a*b^2))/d + (B*a^3*log(tan(c + d*x)))/d - (log( 
tan(c + d*x) + 1i)*(B - C*1i)*(a*1i + b)^3*1i)/(2*d) - (log(tan(c + d*x) - 
 1i)*(B + C*1i)*(a*1i - b)^3*1i)/(2*d) + (C*b^3*tan(c + d*x)^2)/(2*d)
 

Reduce [B] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 670, normalized size of antiderivative = 5.73 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx =\text {Too large to display} \] Input:

int(cot(d*x+c)^2*(a+b*tan(d*x+c))^3*(B*tan(d*x+c)+C*tan(d*x+c)^2),x)
 

Output:

( - 6*cos(c + d*x)*sin(c + d*x)*a*b**2*c - 2*cos(c + d*x)*sin(c + d*x)*b** 
4 - 2*log(tan((c + d*x)/2)**2 + 1)*sin(c + d*x)**2*a**3*b + 6*log(tan((c + 
 d*x)/2)**2 + 1)*sin(c + d*x)**2*a**2*b*c + 6*log(tan((c + d*x)/2)**2 + 1) 
*sin(c + d*x)**2*a*b**3 - 2*log(tan((c + d*x)/2)**2 + 1)*sin(c + d*x)**2*b 
**3*c + 2*log(tan((c + d*x)/2)**2 + 1)*a**3*b - 6*log(tan((c + d*x)/2)**2 
+ 1)*a**2*b*c - 6*log(tan((c + d*x)/2)**2 + 1)*a*b**3 + 2*log(tan((c + d*x 
)/2)**2 + 1)*b**3*c - 6*log(tan((c + d*x)/2) - 1)*sin(c + d*x)**2*a**2*b*c 
 - 6*log(tan((c + d*x)/2) - 1)*sin(c + d*x)**2*a*b**3 + 2*log(tan((c + d*x 
)/2) - 1)*sin(c + d*x)**2*b**3*c + 6*log(tan((c + d*x)/2) - 1)*a**2*b*c + 
6*log(tan((c + d*x)/2) - 1)*a*b**3 - 2*log(tan((c + d*x)/2) - 1)*b**3*c - 
6*log(tan((c + d*x)/2) + 1)*sin(c + d*x)**2*a**2*b*c - 6*log(tan((c + d*x) 
/2) + 1)*sin(c + d*x)**2*a*b**3 + 2*log(tan((c + d*x)/2) + 1)*sin(c + d*x) 
**2*b**3*c + 6*log(tan((c + d*x)/2) + 1)*a**2*b*c + 6*log(tan((c + d*x)/2) 
 + 1)*a*b**3 - 2*log(tan((c + d*x)/2) + 1)*b**3*c + 2*log(tan((c + d*x)/2) 
)*sin(c + d*x)**2*a**3*b - 2*log(tan((c + d*x)/2))*a**3*b + 2*sin(c + d*x) 
**2*a**3*c*d*x + 6*sin(c + d*x)**2*a**2*b**2*d*x - 6*sin(c + d*x)**2*a*b** 
2*c*d*x - 2*sin(c + d*x)**2*b**4*d*x - sin(c + d*x)**2*b**3*c - 2*a**3*c*d 
*x - 6*a**2*b**2*d*x + 6*a*b**2*c*d*x + 2*b**4*d*x)/(2*d*(sin(c + d*x)**2 
- 1))