\(\int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx\) [1198]

Optimal result
Mathematica [C] (verified)
Rubi [A] (verified)
Maple [A] (warning: unable to verify)
Fricas [A] (verification not implemented)
Sympy [B] (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 = 25, antiderivative size = 131 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=(a c-b c-a d-b d) (a c+b c+a d-b d) x-\frac {2 (b c+a d) (a c-b d) \log (\cos (e+f x))}{f}+\frac {b \left (2 a c d+b \left (c^2-d^2\right )\right ) \tan (e+f x)}{f}+\frac {c d (a+b \tan (e+f x))^2}{f}+\frac {d^2 (a+b \tan (e+f x))^3}{3 b f} \] Output:

(a*c-a*d-b*c-b*d)*(a*c+a*d+b*c-b*d)*x-2*(a*d+b*c)*(a*c-b*d)*ln(cos(f*x+e)) 
/f+b*(2*a*c*d+b*(c^2-d^2))*tan(f*x+e)/f+c*d*(a+b*tan(f*x+e))^2/f+1/3*d^2*( 
a+b*tan(f*x+e))^3/b/f
 

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.79 (sec) , antiderivative size = 185, normalized size of antiderivative = 1.41 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=\frac {2 d^2 (a+b \tan (e+f x))^3+3 \left (2 a c d+b \left (-c^2+d^2\right )\right ) \left (i \left ((a+i b)^2 \log (i-\tan (e+f x))-(a-i b)^2 \log (i+\tan (e+f x))\right )-2 b^2 \tan (e+f x)\right )+6 c d \left ((i a-b)^3 \log (i-\tan (e+f x))-(i a+b)^3 \log (i+\tan (e+f x))+6 a b^2 \tan (e+f x)+b^3 \tan ^2(e+f x)\right )}{6 b f} \] Input:

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

Output:

(2*d^2*(a + b*Tan[e + f*x])^3 + 3*(2*a*c*d + b*(-c^2 + d^2))*(I*((a + I*b) 
^2*Log[I - Tan[e + f*x]] - (a - I*b)^2*Log[I + Tan[e + f*x]]) - 2*b^2*Tan[ 
e + f*x]) + 6*c*d*((I*a - b)^3*Log[I - Tan[e + f*x]] - (I*a + b)^3*Log[I + 
 Tan[e + f*x]] + 6*a*b^2*Tan[e + f*x] + b^3*Tan[e + f*x]^2))/(6*b*f)
 

Rubi [A] (verified)

Time = 0.62 (sec) , antiderivative size = 131, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.320, Rules used = {3042, 4026, 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 (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2dx\)

\(\Big \downarrow \) 4026

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4011

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4008

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3956

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

Input:

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

Output:

(a*c - b*c - a*d - b*d)*(a*c + b*c + a*d - b*d)*x - (2*(b*c + a*d)*(a*c - 
b*d)*Log[Cos[e + f*x]])/f + (b*(2*a*c*d + b*(c^2 - d^2))*Tan[e + f*x])/f + 
 (c*d*(a + b*Tan[e + f*x])^2)/f + (d^2*(a + b*Tan[e + f*x])^3)/(3*b*f)
 

Defintions of rubi rules used

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 4026
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)])^2, x_Symbol] :> Simp[d^2*((a + b*Tan[e + f*x])^(m + 1)/(b*f*( 
m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Simp[c^2 - d^2 + 2*c*d*Tan[e + f* 
x], x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[b*c - a*d, 0] &&  !LeQ 
[m, -1] &&  !(EqQ[m, 2] && EqQ[a, 0])
 
Maple [A] (warning: unable to verify)

Time = 0.14 (sec) , antiderivative size = 161, normalized size of antiderivative = 1.23

method result size
parts \(a^{2} c^{2} x +\frac {\left (2 a b \,d^{2}+2 b^{2} c d \right ) \left (\frac {\tan \left (f x +e \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}+\frac {\left (2 a^{2} c d +2 a b \,c^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}+\frac {\left (a^{2} d^{2}+4 a b c d +b^{2} c^{2}\right ) \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {b^{2} d^{2} \left (\frac {\tan \left (f x +e \right )^{3}}{3}-\tan \left (f x +e \right )+\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(161\)
norman \(\left (a^{2} c^{2}-a^{2} d^{2}-4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) x +\frac {\left (a^{2} d^{2}+4 a b c d +b^{2} c^{2}-b^{2} d^{2}\right ) \tan \left (f x +e \right )}{f}+\frac {b d \left (a d +b c \right ) \tan \left (f x +e \right )^{2}}{f}+\frac {b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3 f}+\frac {\left (a^{2} c d +a b \,c^{2}-a b \,d^{2}-b^{2} c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{f}\) \(162\)
derivativedivides \(\frac {\frac {b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+a b \,d^{2} \tan \left (f x +e \right )^{2}+b^{2} c d \tan \left (f x +e \right )^{2}+\tan \left (f x +e \right ) a^{2} d^{2}+4 \tan \left (f x +e \right ) a b c d +\tan \left (f x +e \right ) b^{2} c^{2}-\tan \left (f x +e \right ) b^{2} d^{2}+\frac {\left (2 a^{2} c d +2 a b \,c^{2}-2 a b \,d^{2}-2 b^{2} c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (a^{2} c^{2}-a^{2} d^{2}-4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(189\)
default \(\frac {\frac {b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+a b \,d^{2} \tan \left (f x +e \right )^{2}+b^{2} c d \tan \left (f x +e \right )^{2}+\tan \left (f x +e \right ) a^{2} d^{2}+4 \tan \left (f x +e \right ) a b c d +\tan \left (f x +e \right ) b^{2} c^{2}-\tan \left (f x +e \right ) b^{2} d^{2}+\frac {\left (2 a^{2} c d +2 a b \,c^{2}-2 a b \,d^{2}-2 b^{2} c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (a^{2} c^{2}-a^{2} d^{2}-4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(189\)
parallelrisch \(\frac {b^{2} d^{2} \tan \left (f x +e \right )^{3}+3 a^{2} c^{2} f x -3 x \,a^{2} d^{2} f -12 a b c d f x -3 b^{2} c^{2} f x +3 b^{2} d^{2} f x +3 a b \,d^{2} \tan \left (f x +e \right )^{2}+3 b^{2} c d \tan \left (f x +e \right )^{2}+3 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c d +3 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b \,c^{2}-3 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b \,d^{2}-3 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{2} c d +3 \tan \left (f x +e \right ) a^{2} d^{2}+12 \tan \left (f x +e \right ) a b c d +3 \tan \left (f x +e \right ) b^{2} c^{2}-3 \tan \left (f x +e \right ) b^{2} d^{2}}{3 f}\) \(226\)
risch \(-2 i a b \,d^{2} x +\frac {4 i a^{2} c d e}{f}+\frac {2 i \left (-6 i a b \,d^{2} {\mathrm e}^{4 i \left (f x +e \right )}-6 i b^{2} c d \,{\mathrm e}^{2 i \left (f x +e \right )}+3 a^{2} d^{2} {\mathrm e}^{4 i \left (f x +e \right )}+12 a b c d \,{\mathrm e}^{4 i \left (f x +e \right )}+3 b^{2} c^{2} {\mathrm e}^{4 i \left (f x +e \right )}-6 b^{2} d^{2} {\mathrm e}^{4 i \left (f x +e \right )}-6 i b^{2} c d \,{\mathrm e}^{4 i \left (f x +e \right )}-6 i a b \,d^{2} {\mathrm e}^{2 i \left (f x +e \right )}+6 a^{2} d^{2} {\mathrm e}^{2 i \left (f x +e \right )}+24 a b c d \,{\mathrm e}^{2 i \left (f x +e \right )}+6 b^{2} c^{2} {\mathrm e}^{2 i \left (f x +e \right )}-6 b^{2} d^{2} {\mathrm e}^{2 i \left (f x +e \right )}+3 a^{2} d^{2}+12 a b c d +3 b^{2} c^{2}-4 b^{2} d^{2}\right )}{3 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{3}}-\frac {4 i a b \,d^{2} e}{f}+a^{2} c^{2} x -a^{2} d^{2} x -4 a b c d x -b^{2} c^{2} x +b^{2} d^{2} x +\frac {4 i a b \,c^{2} e}{f}-2 i b^{2} c d x -\frac {4 i b^{2} c d e}{f}+2 i a b \,c^{2} x +2 i a^{2} c d x -\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) a^{2} c d}{f}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) a b \,c^{2}}{f}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) a b \,d^{2}}{f}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) b^{2} c d}{f}\) \(465\)

Input:

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

Output:

a^2*c^2*x+(2*a*b*d^2+2*b^2*c*d)/f*(1/2*tan(f*x+e)^2-1/2*ln(1+tan(f*x+e)^2) 
)+1/2*(2*a^2*c*d+2*a*b*c^2)/f*ln(1+tan(f*x+e)^2)+(a^2*d^2+4*a*b*c*d+b^2*c^ 
2)/f*(tan(f*x+e)-arctan(tan(f*x+e)))+b^2*d^2/f*(1/3*tan(f*x+e)^3-tan(f*x+e 
)+arctan(tan(f*x+e)))
 

Fricas [A] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 158, normalized size of antiderivative = 1.21 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=\frac {b^{2} d^{2} \tan \left (f x + e\right )^{3} - 3 \, {\left (4 \, a b c d - {\left (a^{2} - b^{2}\right )} c^{2} + {\left (a^{2} - b^{2}\right )} d^{2}\right )} f x + 3 \, {\left (b^{2} c d + a b d^{2}\right )} \tan \left (f x + e\right )^{2} - 3 \, {\left (a b c^{2} - a b d^{2} + {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 3 \, {\left (b^{2} c^{2} + 4 \, a b c d + {\left (a^{2} - b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )}{3 \, f} \] Input:

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

Output:

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

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 258 vs. \(2 (117) = 234\).

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

integrate((a+b*tan(f*x+e))**2*(c+d*tan(f*x+e))**2,x)
 

Output:

Piecewise((a**2*c**2*x + a**2*c*d*log(tan(e + f*x)**2 + 1)/f - a**2*d**2*x 
 + a**2*d**2*tan(e + f*x)/f + a*b*c**2*log(tan(e + f*x)**2 + 1)/f - 4*a*b* 
c*d*x + 4*a*b*c*d*tan(e + f*x)/f - a*b*d**2*log(tan(e + f*x)**2 + 1)/f + a 
*b*d**2*tan(e + f*x)**2/f - b**2*c**2*x + b**2*c**2*tan(e + f*x)/f - b**2* 
c*d*log(tan(e + f*x)**2 + 1)/f + b**2*c*d*tan(e + f*x)**2/f + b**2*d**2*x 
+ b**2*d**2*tan(e + f*x)**3/(3*f) - b**2*d**2*tan(e + f*x)/f, Ne(f, 0)), ( 
x*(a + b*tan(e))**2*(c + d*tan(e))**2, True))
 

Maxima [A] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 159, normalized size of antiderivative = 1.21 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=\frac {b^{2} d^{2} \tan \left (f x + e\right )^{3} + 3 \, {\left (b^{2} c d + a b d^{2}\right )} \tan \left (f x + e\right )^{2} - 3 \, {\left (4 \, a b c d - {\left (a^{2} - b^{2}\right )} c^{2} + {\left (a^{2} - b^{2}\right )} d^{2}\right )} {\left (f x + e\right )} + 3 \, {\left (a b c^{2} - a b d^{2} + {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 3 \, {\left (b^{2} c^{2} + 4 \, a b c d + {\left (a^{2} - b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )}{3 \, f} \] Input:

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.33 (sec) , antiderivative size = 215, normalized size of antiderivative = 1.64 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=\frac {{\left (a^{2} c^{2} - b^{2} c^{2} - 4 \, a b c d - a^{2} d^{2} + b^{2} d^{2}\right )} {\left (f x + e\right )}}{f} + \frac {{\left (a b c^{2} + a^{2} c d - b^{2} c d - a b d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{f} + \frac {b^{2} d^{2} f^{2} \tan \left (f x + e\right )^{3} + 3 \, b^{2} c d f^{2} \tan \left (f x + e\right )^{2} + 3 \, a b d^{2} f^{2} \tan \left (f x + e\right )^{2} + 3 \, b^{2} c^{2} f^{2} \tan \left (f x + e\right ) + 12 \, a b c d f^{2} \tan \left (f x + e\right ) + 3 \, a^{2} d^{2} f^{2} \tan \left (f x + e\right ) - 3 \, b^{2} d^{2} f^{2} \tan \left (f x + e\right )}{3 \, f^{3}} \] Input:

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

Output:

(a^2*c^2 - b^2*c^2 - 4*a*b*c*d - a^2*d^2 + b^2*d^2)*(f*x + e)/f + (a*b*c^2 
 + a^2*c*d - b^2*c*d - a*b*d^2)*log(tan(f*x + e)^2 + 1)/f + 1/3*(b^2*d^2*f 
^2*tan(f*x + e)^3 + 3*b^2*c*d*f^2*tan(f*x + e)^2 + 3*a*b*d^2*f^2*tan(f*x + 
 e)^2 + 3*b^2*c^2*f^2*tan(f*x + e) + 12*a*b*c*d*f^2*tan(f*x + e) + 3*a^2*d 
^2*f^2*tan(f*x + e) - 3*b^2*d^2*f^2*tan(f*x + e))/f^3
 

Mupad [B] (verification not implemented)

Time = 2.33 (sec) , antiderivative size = 230, normalized size of antiderivative = 1.76 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (a^2\,d^2+4\,a\,b\,c\,d+b^2\,c^2-b^2\,d^2\right )}{f}+\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (a^2\,c\,d+a\,b\,c^2-a\,b\,d^2-b^2\,c\,d\right )}{f}-\frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (a\,c+a\,d+b\,c-b\,d\right )\,\left (a\,d-a\,c+b\,c+b\,d\right )}{-a^2\,c^2+a^2\,d^2+4\,a\,b\,c\,d+b^2\,c^2-b^2\,d^2}\right )\,\left (a\,c+a\,d+b\,c-b\,d\right )\,\left (a\,d-a\,c+b\,c+b\,d\right )}{f}+\frac {b^2\,d^2\,{\mathrm {tan}\left (e+f\,x\right )}^3}{3\,f}+\frac {b\,d\,{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (a\,d+b\,c\right )}{f} \] Input:

int((a + b*tan(e + f*x))^2*(c + d*tan(e + f*x))^2,x)
 

Output:

(tan(e + f*x)*(a^2*d^2 + b^2*c^2 - b^2*d^2 + 4*a*b*c*d))/f + (log(tan(e + 
f*x)^2 + 1)*(a*b*c^2 - a*b*d^2 + a^2*c*d - b^2*c*d))/f - (atan((tan(e + f* 
x)*(a*c + a*d + b*c - b*d)*(a*d - a*c + b*c + b*d))/(a^2*d^2 - a^2*c^2 + b 
^2*c^2 - b^2*d^2 + 4*a*b*c*d))*(a*c + a*d + b*c - b*d)*(a*d - a*c + b*c + 
b*d))/f + (b^2*d^2*tan(e + f*x)^3)/(3*f) + (b*d*tan(e + f*x)^2*(a*d + b*c) 
)/f
 

Reduce [B] (verification not implemented)

Time = 0.23 (sec) , antiderivative size = 225, normalized size of antiderivative = 1.72 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=\frac {3 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a^{2} c d +3 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a b \,c^{2}-3 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a b \,d^{2}-3 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b^{2} c d +\tan \left (f x +e \right )^{3} b^{2} d^{2}+3 \tan \left (f x +e \right )^{2} a b \,d^{2}+3 \tan \left (f x +e \right )^{2} b^{2} c d +3 \tan \left (f x +e \right ) a^{2} d^{2}+12 \tan \left (f x +e \right ) a b c d +3 \tan \left (f x +e \right ) b^{2} c^{2}-3 \tan \left (f x +e \right ) b^{2} d^{2}+3 a^{2} c^{2} f x -3 a^{2} d^{2} f x -12 a b c d f x -3 b^{2} c^{2} f x +3 b^{2} d^{2} f x}{3 f} \] Input:

int((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))^2,x)
 

Output:

(3*log(tan(e + f*x)**2 + 1)*a**2*c*d + 3*log(tan(e + f*x)**2 + 1)*a*b*c**2 
 - 3*log(tan(e + f*x)**2 + 1)*a*b*d**2 - 3*log(tan(e + f*x)**2 + 1)*b**2*c 
*d + tan(e + f*x)**3*b**2*d**2 + 3*tan(e + f*x)**2*a*b*d**2 + 3*tan(e + f* 
x)**2*b**2*c*d + 3*tan(e + f*x)*a**2*d**2 + 12*tan(e + f*x)*a*b*c*d + 3*ta 
n(e + f*x)*b**2*c**2 - 3*tan(e + f*x)*b**2*d**2 + 3*a**2*c**2*f*x - 3*a**2 
*d**2*f*x - 12*a*b*c*d*f*x - 3*b**2*c**2*f*x + 3*b**2*d**2*f*x)/(3*f)