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

Optimal result
Mathematica [C] (verified)
Rubi [A] (verified)
Maple [A] (warning: unable to verify)
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 = 38, antiderivative size = 148 \[ \int \tan (c+d x) (a+b \tan (c+d x))^2 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=-\left (\left (a^2 B-b^2 B-2 a b C\right ) x\right )+\frac {\left (2 a b B+a^2 C-b^2 C\right ) \log (\cos (c+d x))}{d}-\frac {b (b B+a C) \tan (c+d x)}{d}-\frac {C (a+b \tan (c+d x))^2}{2 d}+\frac {(4 b B-a C) (a+b \tan (c+d x))^3}{12 b^2 d}+\frac {C \tan (c+d x) (a+b \tan (c+d x))^3}{4 b d} \] Output:

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

Mathematica [C] (verified)

Result contains complex when optimal does not.

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

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

Output:

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

Rubi [A] (verified)

Time = 1.54 (sec) , antiderivative size = 160, normalized size of antiderivative = 1.08, number of steps used = 13, number of rules used = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.342, Rules used = {3042, 4115, 3042, 4090, 25, 3042, 4113, 3042, 4011, 3042, 4008, 3042, 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 \tan (c+d x) (a+b \tan (c+d x))^2 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4115

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4090

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

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4113

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4011

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4008

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3956

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

Input:

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

Output:

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

Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], 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 4008
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)]), x_Symbol] :> Simp[(a*c - b*d)*x, x] + (Simp[b*d*(Tan[e + f*x]/f), 
x] + Simp[(b*c + a*d)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, c, d, e, 
f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]
 

rule 4011
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)]), x_Symbol] :> Simp[d*((a + b*Tan[e + f*x])^m/(f*m)), x] + Int 
[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x], x] 
, x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 
 0] && GtQ[m, 0]
 

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 4113
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) 
+ (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*((a + 
 b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Si 
mp[A - C + B*Tan[e + f*x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] && 
NeQ[A*b^2 - a*b*B + a^2*C, 0] &&  !LeQ[m, -1]
 

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]
 
Maple [A] (warning: unable to verify)

Time = 0.10 (sec) , antiderivative size = 148, normalized size of antiderivative = 1.00

method result size
parts \(\frac {\left (B \,b^{2}+2 C a b \right ) \left (\frac {\tan \left (d x +c \right )^{3}}{3}-\tan \left (d x +c \right )+\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {\left (2 B a b +C \,a^{2}\right ) \left (\frac {\tan \left (d x +c \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}\right )}{d}+\frac {B \,a^{2} \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {C \,b^{2} \left (\frac {\tan \left (d x +c \right )^{4}}{4}-\frac {\tan \left (d x +c \right )^{2}}{2}+\frac {\ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}\right )}{d}\) \(148\)
norman \(\left (-B \,a^{2}+B \,b^{2}+2 C a b \right ) x +\frac {\left (B \,a^{2}-B \,b^{2}-2 C a b \right ) \tan \left (d x +c \right )}{d}+\frac {\left (2 B a b +C \,a^{2}-C \,b^{2}\right ) \tan \left (d x +c \right )^{2}}{2 d}+\frac {C \,b^{2} \tan \left (d x +c \right )^{4}}{4 d}+\frac {b \left (B b +2 C a \right ) \tan \left (d x +c \right )^{3}}{3 d}-\frac {\left (2 B a b +C \,a^{2}-C \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d}\) \(150\)
derivativedivides \(\frac {\frac {C \,b^{2} \tan \left (d x +c \right )^{4}}{4}+\frac {B \,b^{2} \tan \left (d x +c \right )^{3}}{3}+\frac {2 C a b \tan \left (d x +c \right )^{3}}{3}+B a b \tan \left (d x +c \right )^{2}+\frac {C \,a^{2} \tan \left (d x +c \right )^{2}}{2}-\frac {C \,b^{2} \tan \left (d x +c \right )^{2}}{2}+B \,a^{2} \tan \left (d x +c \right )-B \,b^{2} \tan \left (d x +c \right )-2 C a b \tan \left (d x +c \right )+\frac {\left (-2 B a b -C \,a^{2}+C \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (-B \,a^{2}+B \,b^{2}+2 C a b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(176\)
default \(\frac {\frac {C \,b^{2} \tan \left (d x +c \right )^{4}}{4}+\frac {B \,b^{2} \tan \left (d x +c \right )^{3}}{3}+\frac {2 C a b \tan \left (d x +c \right )^{3}}{3}+B a b \tan \left (d x +c \right )^{2}+\frac {C \,a^{2} \tan \left (d x +c \right )^{2}}{2}-\frac {C \,b^{2} \tan \left (d x +c \right )^{2}}{2}+B \,a^{2} \tan \left (d x +c \right )-B \,b^{2} \tan \left (d x +c \right )-2 C a b \tan \left (d x +c \right )+\frac {\left (-2 B a b -C \,a^{2}+C \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (-B \,a^{2}+B \,b^{2}+2 C a b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(176\)
parallelrisch \(-\frac {-3 C \,b^{2} \tan \left (d x +c \right )^{4}-4 B \,b^{2} \tan \left (d x +c \right )^{3}-8 C a b \tan \left (d x +c \right )^{3}+12 B \,a^{2} d x -12 B \,b^{2} d x -12 B a b \tan \left (d x +c \right )^{2}-24 C a b d x -6 C \,a^{2} \tan \left (d x +c \right )^{2}+6 C \,b^{2} \tan \left (d x +c \right )^{2}+12 B \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a b -12 B \,a^{2} \tan \left (d x +c \right )+12 B \,b^{2} \tan \left (d x +c \right )+6 C \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a^{2}-6 C \ln \left (1+\tan \left (d x +c \right )^{2}\right ) b^{2}+24 C a b \tan \left (d x +c \right )}{12 d}\) \(197\)
risch \(-B \,a^{2} x +B \,b^{2} x +2 C a b x -i C \,a^{2} x +\frac {2 i \left (6 i C \,b^{2} {\mathrm e}^{6 i \left (d x +c \right )}-6 i B a b \,{\mathrm e}^{2 i \left (d x +c \right )}+6 i C \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+3 B \,a^{2} {\mathrm e}^{6 i \left (d x +c \right )}-6 B \,b^{2} {\mathrm e}^{6 i \left (d x +c \right )}-12 C a b \,{\mathrm e}^{6 i \left (d x +c \right )}+6 i C \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-6 i C \,a^{2} {\mathrm e}^{4 i \left (d x +c \right )}-3 i C \,a^{2} {\mathrm e}^{6 i \left (d x +c \right )}+9 B \,a^{2} {\mathrm e}^{4 i \left (d x +c \right )}-12 B \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-24 C a b \,{\mathrm e}^{4 i \left (d x +c \right )}-6 i B a b \,{\mathrm e}^{6 i \left (d x +c \right )}-3 i C \,a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-12 i B a b \,{\mathrm e}^{4 i \left (d x +c \right )}+9 B \,a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-10 B \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-20 C a b \,{\mathrm e}^{2 i \left (d x +c \right )}+3 B \,a^{2}-4 B \,b^{2}-8 C a b \right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{4}}-2 i B a b x -\frac {4 i B a b c}{d}+\frac {2 i C \,b^{2} c}{d}+i C \,b^{2} x -\frac {2 i C \,a^{2} c}{d}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B a b}{d}+\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) C \,a^{2}}{d}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) C \,b^{2}}{d}\) \(447\)

Input:

int(tan(d*x+c)*(a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x,method=_ 
RETURNVERBOSE)
 

Output:

(B*b^2+2*C*a*b)/d*(1/3*tan(d*x+c)^3-tan(d*x+c)+arctan(tan(d*x+c)))+(2*B*a* 
b+C*a^2)/d*(1/2*tan(d*x+c)^2-1/2*ln(1+tan(d*x+c)^2))+B*a^2/d*(tan(d*x+c)-a 
rctan(tan(d*x+c)))+C*b^2/d*(1/4*tan(d*x+c)^4-1/2*tan(d*x+c)^2+1/2*ln(1+tan 
(d*x+c)^2))
 

Fricas [A] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 146, normalized size of antiderivative = 0.99 \[ \int \tan (c+d x) (a+b \tan (c+d x))^2 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {3 \, C b^{2} \tan \left (d x + c\right )^{4} + 4 \, {\left (2 \, C a b + B b^{2}\right )} \tan \left (d x + c\right )^{3} - 12 \, {\left (B a^{2} - 2 \, C a b - B b^{2}\right )} d x + 6 \, {\left (C a^{2} + 2 \, B a b - C b^{2}\right )} \tan \left (d x + c\right )^{2} + 6 \, {\left (C a^{2} + 2 \, B a b - C b^{2}\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 12 \, {\left (B a^{2} - 2 \, C a b - B b^{2}\right )} \tan \left (d x + c\right )}{12 \, d} \] Input:

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

Output:

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

Sympy [A] (verification not implemented)

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

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

Output:

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

Maxima [A] (verification not implemented)

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

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.66 (sec) , antiderivative size = 211, normalized size of antiderivative = 1.43 \[ \int \tan (c+d x) (a+b \tan (c+d x))^2 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=-\frac {{\left (B a^{2} - 2 \, C a b - B b^{2}\right )} {\left (d x + c\right )}}{d} - \frac {{\left (C a^{2} + 2 \, B a b - C b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{2 \, d} + \frac {3 \, C b^{2} d^{3} \tan \left (d x + c\right )^{4} + 8 \, C a b d^{3} \tan \left (d x + c\right )^{3} + 4 \, B b^{2} d^{3} \tan \left (d x + c\right )^{3} + 6 \, C a^{2} d^{3} \tan \left (d x + c\right )^{2} + 12 \, B a b d^{3} \tan \left (d x + c\right )^{2} - 6 \, C b^{2} d^{3} \tan \left (d x + c\right )^{2} + 12 \, B a^{2} d^{3} \tan \left (d x + c\right ) - 24 \, C a b d^{3} \tan \left (d x + c\right ) - 12 \, B b^{2} d^{3} \tan \left (d x + c\right )}{12 \, d^{4}} \] Input:

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

Output:

-(B*a^2 - 2*C*a*b - B*b^2)*(d*x + c)/d - 1/2*(C*a^2 + 2*B*a*b - C*b^2)*log 
(tan(d*x + c)^2 + 1)/d + 1/12*(3*C*b^2*d^3*tan(d*x + c)^4 + 8*C*a*b*d^3*ta 
n(d*x + c)^3 + 4*B*b^2*d^3*tan(d*x + c)^3 + 6*C*a^2*d^3*tan(d*x + c)^2 + 1 
2*B*a*b*d^3*tan(d*x + c)^2 - 6*C*b^2*d^3*tan(d*x + c)^2 + 12*B*a^2*d^3*tan 
(d*x + c) - 24*C*a*b*d^3*tan(d*x + c) - 12*B*b^2*d^3*tan(d*x + c))/d^4
 

Mupad [B] (verification not implemented)

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

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

Output:

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

Reduce [B] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 195, normalized size of antiderivative = 1.32 \[ \int \tan (c+d x) (a+b \tan (c+d x))^2 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {-6 \,\mathrm {log}\left (\tan \left (d x +c \right )^{2}+1\right ) a^{2} c -12 \,\mathrm {log}\left (\tan \left (d x +c \right )^{2}+1\right ) a \,b^{2}+6 \,\mathrm {log}\left (\tan \left (d x +c \right )^{2}+1\right ) b^{2} c +3 \tan \left (d x +c \right )^{4} b^{2} c +8 \tan \left (d x +c \right )^{3} a b c +4 \tan \left (d x +c \right )^{3} b^{3}+6 \tan \left (d x +c \right )^{2} a^{2} c +12 \tan \left (d x +c \right )^{2} a \,b^{2}-6 \tan \left (d x +c \right )^{2} b^{2} c +12 \tan \left (d x +c \right ) a^{2} b -24 \tan \left (d x +c \right ) a b c -12 \tan \left (d x +c \right ) b^{3}-12 a^{2} b d x +24 a b c d x +12 b^{3} d x}{12 d} \] Input:

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

Output:

( - 6*log(tan(c + d*x)**2 + 1)*a**2*c - 12*log(tan(c + d*x)**2 + 1)*a*b**2 
 + 6*log(tan(c + d*x)**2 + 1)*b**2*c + 3*tan(c + d*x)**4*b**2*c + 8*tan(c 
+ d*x)**3*a*b*c + 4*tan(c + d*x)**3*b**3 + 6*tan(c + d*x)**2*a**2*c + 12*t 
an(c + d*x)**2*a*b**2 - 6*tan(c + d*x)**2*b**2*c + 12*tan(c + d*x)*a**2*b 
- 24*tan(c + d*x)*a*b*c - 12*tan(c + d*x)*b**3 - 12*a**2*b*d*x + 24*a*b*c* 
d*x + 12*b**3*d*x)/(12*d)