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

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [A] (warning: unable to verify)
Fricas [B] (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 = 28, antiderivative size = 116 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=2 a^2 (c-i d)^2 x-\frac {2 i a^2 (c-i d)^2 \log (\cos (e+f x))}{f}-\frac {a^2 (c-i d)^2 \tan (e+f x)}{f}+\frac {c d (a+i a \tan (e+f x))^2}{f}-\frac {i d^2 (a+i a \tan (e+f x))^3}{3 a f} \] Output:

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

Mathematica [A] (verified)

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

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

Output:

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

Rubi [A] (verified)

Time = 0.55 (sec) , antiderivative size = 100, normalized size of antiderivative = 0.86, number of steps used = 8, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3042, 4026, 3042, 4010, 3042, 3958, 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+i a \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4026

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4010

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3958

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3956

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

Input:

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

Output:

(c*d*(a + I*a*Tan[e + f*x])^2)/f - ((I/3)*d^2*(a + I*a*Tan[e + f*x])^3)/(a 
*f) + (c - I*d)^2*(2*a^2*x - ((2*I)*a^2*Log[Cos[e + f*x]])/f - (a^2*Tan[e 
+ f*x])/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 3958
Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2) 
*x, x] + (Simp[b^2*(Tan[c + d*x]/d), x] + Simp[2*a*b   Int[Tan[c + d*x], x] 
, x]) /; FreeQ[{a, b, c, d}, x]
 

rule 4010
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] + Simp 
[(b*c + a*d)/b   Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[{a, b, c, d, e 
, f, m}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] &&  !LtQ[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.19 (sec) , antiderivative size = 135, normalized size of antiderivative = 1.16

method result size
derivativedivides \(\frac {a^{2} \left (i d^{2} \tan \left (f x +e \right )^{2}-\frac {d^{2} \tan \left (f x +e \right )^{3}}{3}+4 i \tan \left (f x +e \right ) c d -c d \tan \left (f x +e \right )^{2}-c^{2} \tan \left (f x +e \right )+2 d^{2} \tan \left (f x +e \right )+\frac {\left (2 i c^{2}-2 i d^{2}+4 c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (-4 i c d +2 c^{2}-2 d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(135\)
default \(\frac {a^{2} \left (i d^{2} \tan \left (f x +e \right )^{2}-\frac {d^{2} \tan \left (f x +e \right )^{3}}{3}+4 i \tan \left (f x +e \right ) c d -c d \tan \left (f x +e \right )^{2}-c^{2} \tan \left (f x +e \right )+2 d^{2} \tan \left (f x +e \right )+\frac {\left (2 i c^{2}-2 i d^{2}+4 c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (-4 i c d +2 c^{2}-2 d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(135\)
norman \(\left (-4 i a^{2} c d +2 a^{2} c^{2}-2 a^{2} d^{2}\right ) x -\frac {\left (-i a^{2} d^{2}+a^{2} c d \right ) \tan \left (f x +e \right )^{2}}{f}-\frac {\left (-4 i a^{2} c d +a^{2} c^{2}-2 a^{2} d^{2}\right ) \tan \left (f x +e \right )}{f}-\frac {a^{2} d^{2} \tan \left (f x +e \right )^{3}}{3 f}+\frac {i a^{2} \left (-2 i c d +c^{2}-d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{f}\) \(146\)
parts \(a^{2} c^{2} x +\frac {\left (2 i a^{2} c^{2}+2 a^{2} c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}+\frac {\left (2 i a^{2} d^{2}-2 a^{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 (4 i a^{2} c d -a^{2} c^{2}+a^{2} d^{2}\right ) \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}-\frac {a^{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}\) \(169\)
parallelrisch \(\frac {-12 i x \,a^{2} c d f +3 i \tan \left (f x +e \right )^{2} a^{2} d^{2}-\tan \left (f x +e \right )^{3} a^{2} d^{2}+3 i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c^{2}-3 i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} d^{2}+12 i \tan \left (f x +e \right ) a^{2} c d +6 x \,a^{2} c^{2} f -6 x \,a^{2} d^{2} f -3 \tan \left (f x +e \right )^{2} a^{2} c d +6 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c d -3 \tan \left (f x +e \right ) a^{2} c^{2}+6 \tan \left (f x +e \right ) a^{2} d^{2}}{3 f}\) \(185\)
risch \(\frac {8 i a^{2} c d e}{f}-\frac {4 a^{2} c^{2} e}{f}+\frac {4 a^{2} d^{2} e}{f}-\frac {2 i a^{2} \left (3 c^{2} {\mathrm e}^{4 i \left (f x +e \right )}-15 d^{2} {\mathrm e}^{4 i \left (f x +e \right )}-18 i c d \,{\mathrm e}^{4 i \left (f x +e \right )}+6 c^{2} {\mathrm e}^{2 i \left (f x +e \right )}-18 d^{2} {\mathrm e}^{2 i \left (f x +e \right )}-30 i c d \,{\mathrm e}^{2 i \left (f x +e \right )}+3 c^{2}-7 d^{2}-12 i c d \right )}{3 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{3}}-\frac {4 a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) c d}{f}-\frac {2 i a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) c^{2}}{f}+\frac {2 i a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) d^{2}}{f}\) \(230\)

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 277 vs. \(2 (100) = 200\).

Time = 0.09 (sec) , antiderivative size = 277, normalized size of antiderivative = 2.39 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=-\frac {2 \, {\left (3 i \, a^{2} c^{2} + 12 \, a^{2} c d - 7 i \, a^{2} d^{2} + 3 \, {\left (i \, a^{2} c^{2} + 6 \, a^{2} c d - 5 i \, a^{2} d^{2}\right )} e^{\left (4 i \, f x + 4 i \, e\right )} + 6 \, {\left (i \, a^{2} c^{2} + 5 \, a^{2} c d - 3 i \, a^{2} d^{2}\right )} e^{\left (2 i \, f x + 2 i \, e\right )} + 3 \, {\left (i \, a^{2} c^{2} + 2 \, a^{2} c d - i \, a^{2} d^{2} + {\left (i \, a^{2} c^{2} + 2 \, a^{2} c d - i \, a^{2} d^{2}\right )} e^{\left (6 i \, f x + 6 i \, e\right )} + 3 \, {\left (i \, a^{2} c^{2} + 2 \, a^{2} c d - i \, a^{2} d^{2}\right )} e^{\left (4 i \, f x + 4 i \, e\right )} + 3 \, {\left (i \, a^{2} c^{2} + 2 \, a^{2} c d - i \, a^{2} d^{2}\right )} e^{\left (2 i \, f x + 2 i \, e\right )}\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right )\right )}}{3 \, {\left (f e^{\left (6 i \, f x + 6 i \, e\right )} + 3 \, f e^{\left (4 i \, f x + 4 i \, e\right )} + 3 \, f e^{\left (2 i \, f x + 2 i \, e\right )} + f\right )}} \] Input:

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

Output:

-2/3*(3*I*a^2*c^2 + 12*a^2*c*d - 7*I*a^2*d^2 + 3*(I*a^2*c^2 + 6*a^2*c*d - 
5*I*a^2*d^2)*e^(4*I*f*x + 4*I*e) + 6*(I*a^2*c^2 + 5*a^2*c*d - 3*I*a^2*d^2) 
*e^(2*I*f*x + 2*I*e) + 3*(I*a^2*c^2 + 2*a^2*c*d - I*a^2*d^2 + (I*a^2*c^2 + 
 2*a^2*c*d - I*a^2*d^2)*e^(6*I*f*x + 6*I*e) + 3*(I*a^2*c^2 + 2*a^2*c*d - I 
*a^2*d^2)*e^(4*I*f*x + 4*I*e) + 3*(I*a^2*c^2 + 2*a^2*c*d - I*a^2*d^2)*e^(2 
*I*f*x + 2*I*e))*log(e^(2*I*f*x + 2*I*e) + 1))/(f*e^(6*I*f*x + 6*I*e) + 3* 
f*e^(4*I*f*x + 4*I*e) + 3*f*e^(2*I*f*x + 2*I*e) + f)
 

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 236 vs. \(2 (97) = 194\).

Time = 0.45 (sec) , antiderivative size = 236, normalized size of antiderivative = 2.03 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx=- \frac {2 i a^{2} \left (c - i d\right )^{2} \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{f} + \frac {- 6 i a^{2} c^{2} - 24 a^{2} c d + 14 i a^{2} d^{2} + \left (- 12 i a^{2} c^{2} e^{2 i e} - 60 a^{2} c d e^{2 i e} + 36 i a^{2} d^{2} e^{2 i e}\right ) e^{2 i f x} + \left (- 6 i a^{2} c^{2} e^{4 i e} - 36 a^{2} c d e^{4 i e} + 30 i a^{2} d^{2} e^{4 i e}\right ) e^{4 i f x}}{3 f e^{6 i e} e^{6 i f x} + 9 f e^{4 i e} e^{4 i f x} + 9 f e^{2 i e} e^{2 i f x} + 3 f} \] Input:

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

Output:

-2*I*a**2*(c - I*d)**2*log(exp(2*I*f*x) + exp(-2*I*e))/f + (-6*I*a**2*c**2 
 - 24*a**2*c*d + 14*I*a**2*d**2 + (-12*I*a**2*c**2*exp(2*I*e) - 60*a**2*c* 
d*exp(2*I*e) + 36*I*a**2*d**2*exp(2*I*e))*exp(2*I*f*x) + (-6*I*a**2*c**2*e 
xp(4*I*e) - 36*a**2*c*d*exp(4*I*e) + 30*I*a**2*d**2*exp(4*I*e))*exp(4*I*f* 
x))/(3*f*exp(6*I*e)*exp(6*I*f*x) + 9*f*exp(4*I*e)*exp(4*I*f*x) + 9*f*exp(2 
*I*e)*exp(2*I*f*x) + 3*f)
 

Maxima [A] (verification not implemented)

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

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

Output:

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

Giac [A] (verification not implemented)

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

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

Output:

-2*(-I*a^2*c^2 - 2*a^2*c*d + I*a^2*d^2)*log(tan(f*x + e) + I)/f - 1/3*(a^2 
*d^2*f^2*tan(f*x + e)^3 + 3*a^2*c*d*f^2*tan(f*x + e)^2 - 3*I*a^2*d^2*f^2*t 
an(f*x + e)^2 + 3*a^2*c^2*f^2*tan(f*x + e) - 12*I*a^2*c*d*f^2*tan(f*x + e) 
 - 6*a^2*d^2*f^2*tan(f*x + e))/f^3
 

Mupad [B] (verification not implemented)

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

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

Output:

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

Reduce [B] (verification not implemented)

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

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

Output:

(a**2*(3*log(tan(e + f*x)**2 + 1)*c**2*i + 6*log(tan(e + f*x)**2 + 1)*c*d 
- 3*log(tan(e + f*x)**2 + 1)*d**2*i - tan(e + f*x)**3*d**2 - 3*tan(e + f*x 
)**2*c*d + 3*tan(e + f*x)**2*d**2*i - 3*tan(e + f*x)*c**2 + 12*tan(e + f*x 
)*c*d*i + 6*tan(e + f*x)*d**2 + 6*c**2*f*x - 12*c*d*f*i*x - 6*d**2*f*x))/( 
3*f)