\(\int \frac {(a+i a \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx\) [1090]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [A] (verified)
Fricas [A] (verification not implemented)
Sympy [B] (verification not implemented)
Maxima [B] (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 = 93 \[ \int \frac {(a+i a \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx=\frac {2 a^2 x}{(c-i d)^2}-\frac {2 i a^2 \log (c \cos (e+f x)+d \sin (e+f x))}{(c-i d)^2 f}+\frac {a^2 (i c-d)}{d (i c+d) f (c+d \tan (e+f x))} \] Output:

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

Mathematica [A] (verified)

Time = 0.83 (sec) , antiderivative size = 169, normalized size of antiderivative = 1.82 \[ \int \frac {(a+i a \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx=-\frac {a^2 \left (c d-i d^2+2 c (-i c+d) \log (i+\tan (e+f x))+2 i c^2 \log (c+d \tan (e+f x))-2 c d \log (c+d \tan (e+f x))+\left (c^2+i c d+2 d^2+2 d (-i c+d) \log (i+\tan (e+f x))+2 i (c+i d) d \log (c+d \tan (e+f x))\right ) \tan (e+f x)\right )}{(c-i d)^2 (c+i d) f (c+d \tan (e+f x))} \] Input:

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

Output:

-((a^2*(c*d - I*d^2 + 2*c*((-I)*c + d)*Log[I + Tan[e + f*x]] + (2*I)*c^2*L 
og[c + d*Tan[e + f*x]] - 2*c*d*Log[c + d*Tan[e + f*x]] + (c^2 + I*c*d + 2* 
d^2 + 2*d*((-I)*c + d)*Log[I + Tan[e + f*x]] + (2*I)*(c + I*d)*d*Log[c + d 
*Tan[e + f*x]])*Tan[e + f*x]))/((c - I*d)^2*(c + I*d)*f*(c + d*Tan[e + f*x 
])))
 

Rubi [A] (verified)

Time = 0.59 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.27, number of steps used = 7, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3042, 4025, 27, 3042, 4014, 3042, 4013}

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 \frac {(a+i a \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4025

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4014

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4013

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

Input:

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

Output:

(2*((a^2*(c + I*d)*x)/(c - I*d) - (a^2*(I*c - d)*Log[c*Cos[e + f*x] + d*Si 
n[e + f*x]])/((c - I*d)*f)))/(c^2 + d^2) + (a^2*(I*c - d))/(d*(I*c + d)*f* 
(c + d*Tan[e + f*x]))
 

Defintions of rubi rules used

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 4013
Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)* 
(x_)]), x_Symbol] :> Simp[(c/(b*f))*Log[RemoveContent[a*Cos[e + f*x] + b*Si 
n[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] && EqQ[a*c + b*d, 0]
 

rule 4014
Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_. 
)*(x_)]), x_Symbol] :> Simp[(a*c + b*d)*(x/(a^2 + b^2)), x] + Simp[(b*c - a 
*d)/(a^2 + b^2)   Int[(b - a*Tan[e + f*x])/(a + b*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] && N 
eQ[a*c + b*d, 0]
 

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

Time = 0.23 (sec) , antiderivative size = 153, normalized size of antiderivative = 1.65

method result size
derivativedivides \(\frac {a^{2} \left (-\frac {-2 i c d -c^{2}+d^{2}}{\left (c^{2}+d^{2}\right ) d \left (c +d \tan \left (f x +e \right )\right )}-\frac {2 \left (i c^{2}-i d^{2}-2 c d \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}+\frac {\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 )}{\left (c^{2}+d^{2}\right )^{2}}\right )}{f}\) \(153\)
default \(\frac {a^{2} \left (-\frac {-2 i c d -c^{2}+d^{2}}{\left (c^{2}+d^{2}\right ) d \left (c +d \tan \left (f x +e \right )\right )}-\frac {2 \left (i c^{2}-i d^{2}-2 c d \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}+\frac {\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 )}{\left (c^{2}+d^{2}\right )^{2}}\right )}{f}\) \(153\)
norman \(\frac {\frac {2 a^{2} c x}{\left (-i d +c \right )^{2}}-\frac {2 a^{2} d x \tan \left (f x +e \right )}{\left (i c +d \right )^{2}}-\frac {\left (i a^{2} d +a^{2} c \right ) \tan \left (f x +e \right )}{f \left (-i d +c \right ) c}}{c +d \tan \left (f x +e \right )}+\frac {i a^{2} \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{f \left (-2 i c d +c^{2}-d^{2}\right )}-\frac {2 i a^{2} \ln \left (c +d \tan \left (f x +e \right )\right )}{f \left (-2 i c d +c^{2}-d^{2}\right )}\) \(159\)
risch \(-\frac {4 a^{2} x}{2 i c d -c^{2}+d^{2}}-\frac {4 i a^{2} x}{i c^{2}-i d^{2}+2 c d}-\frac {4 i a^{2} e}{f \left (i c^{2}-i d^{2}+2 c d \right )}+\frac {2 a^{2} d}{f \left (-i d +c \right )^{2} \left (-i d \,{\mathrm e}^{2 i \left (f x +e \right )}+{\mathrm e}^{2 i \left (f x +e \right )} c +i d +c \right )}-\frac {2 i a^{2} c}{f \left (-i d +c \right )^{2} \left (-i d \,{\mathrm e}^{2 i \left (f x +e \right )}+{\mathrm e}^{2 i \left (f x +e \right )} c +i d +c \right )}+\frac {2 a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right )}{f \left (i c^{2}-i d^{2}+2 c d \right )}\) \(234\)
parallelrisch \(\frac {-2 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c^{2} d^{2}+4 \ln \left (c +d \tan \left (f x +e \right )\right ) a^{2} c^{2} d^{2}-2 i \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{2} c^{2} d^{2}+4 i x \tan \left (f x +e \right ) a^{2} c \,d^{3} f +2 i a^{2} c^{3} d +a^{2} c^{4}-i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c \,d^{3}+2 i \ln \left (c +d \tan \left (f x +e \right )\right ) a^{2} c \,d^{3}+4 i x \,a^{2} c^{2} d^{2} f +2 x \tan \left (f x +e \right ) a^{2} c^{2} d^{2} f -a^{2} d^{4}+2 i a^{2} c \,d^{3}-2 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) a^{2} c \,d^{3}+4 \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{2} c \,d^{3}-2 i \ln \left (c +d \tan \left (f x +e \right )\right ) a^{2} c^{3} d +i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) a^{2} c^{2} d^{2}-i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) a^{2} d^{4}+i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c^{3} d +2 i \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{2} d^{4}-2 x \tan \left (f x +e \right ) a^{2} d^{4} f +2 x \,a^{2} c^{3} d f -2 x \,a^{2} c \,d^{3} f}{f d \left (c^{2}+d^{2}\right )^{2} \left (c +d \tan \left (f x +e \right )\right )}\) \(444\)

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*(-(-2*I*c*d-c^2+d^2)/(c^2+d^2)/d/(c+d*tan(f*x+e))-2*(I*c^2-I*d^2-2 
*c*d)/(c^2+d^2)^2*ln(c+d*tan(f*x+e))+1/(c^2+d^2)^2*(1/2*(2*I*c^2-2*I*d^2-4 
*c*d)*ln(1+tan(f*x+e)^2)+(4*I*c*d+2*c^2-2*d^2)*arctan(tan(f*x+e))))
 

Fricas [A] (verification not implemented)

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

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

Output:

-2*(a^2*c + I*a^2*d + (a^2*c + I*a^2*d + (a^2*c - I*a^2*d)*e^(2*I*f*x + 2* 
I*e))*log(((I*c + d)*e^(2*I*f*x + 2*I*e) + I*c - d)/(I*c + d)))/((-I*c^3 - 
 3*c^2*d + 3*I*c*d^2 + d^3)*f*e^(2*I*f*x + 2*I*e) + (-I*c^3 - c^2*d - I*c* 
d^2 - d^3)*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. 156 vs. \(2 (73) = 146\).

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

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

Output:

-2*I*a**2*log((c + I*d)/(c*exp(2*I*e) - I*d*exp(2*I*e)) + exp(2*I*f*x))/(f 
*(c - I*d)**2) + (-2*I*a**2*c + 2*a**2*d)/(c**3*f - I*c**2*d*f + c*d**2*f 
- I*d**3*f + (c**3*f*exp(2*I*e) - 3*I*c**2*d*f*exp(2*I*e) - 3*c*d**2*f*exp 
(2*I*e) + I*d**3*f*exp(2*I*e))*exp(2*I*f*x))
 

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 214 vs. \(2 (83) = 166\).

Time = 0.13 (sec) , antiderivative size = 214, normalized size of antiderivative = 2.30 \[ \int \frac {(a+i a \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx=\frac {\frac {2 \, {\left (a^{2} c^{2} + 2 i \, a^{2} c d - a^{2} d^{2}\right )} {\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac {2 \, {\left (i \, a^{2} c^{2} - 2 \, a^{2} c d - i \, a^{2} d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac {{\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 )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac {a^{2} c^{2} + 2 i \, a^{2} c d - a^{2} d^{2}}{c^{3} d + c d^{3} + {\left (c^{2} d^{2} + d^{4}\right )} \tan \left (f x + e\right )}}{f} \] Input:

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

Output:

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

Giac [A] (verification not implemented)

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

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

Output:

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

Mupad [B] (verification not implemented)

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

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

Output:

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

Reduce [B] (verification not implemented)

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

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

Output:

(a**2*(log(tan(e + f*x)**2 + 1)*tan(e + f*x)*c**3*d*i - 2*log(tan(e + f*x) 
**2 + 1)*tan(e + f*x)*c**2*d**2 - log(tan(e + f*x)**2 + 1)*tan(e + f*x)*c* 
d**3*i + log(tan(e + f*x)**2 + 1)*c**4*i - 2*log(tan(e + f*x)**2 + 1)*c**3 
*d - log(tan(e + f*x)**2 + 1)*c**2*d**2*i - 2*log(tan(e + f*x)*d + c)*tan( 
e + f*x)*c**3*d*i + 4*log(tan(e + f*x)*d + c)*tan(e + f*x)*c**2*d**2 + 2*l 
og(tan(e + f*x)*d + c)*tan(e + f*x)*c*d**3*i - 2*log(tan(e + f*x)*d + c)*c 
**4*i + 4*log(tan(e + f*x)*d + c)*c**3*d + 2*log(tan(e + f*x)*d + c)*c**2* 
d**2*i - tan(e + f*x)*c**4 + 2*tan(e + f*x)*c**3*d*f*x - 2*tan(e + f*x)*c* 
*3*d*i + 4*tan(e + f*x)*c**2*d**2*f*i*x - 2*tan(e + f*x)*c*d**3*f*x - 2*ta 
n(e + f*x)*c*d**3*i + tan(e + f*x)*d**4 + 2*c**4*f*x + 4*c**3*d*f*i*x - 2* 
c**2*d**2*f*x))/(c*f*(tan(e + f*x)*c**4*d + 2*tan(e + f*x)*c**2*d**3 + tan 
(e + f*x)*d**5 + c**5 + 2*c**3*d**2 + c*d**4))