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

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

Optimal result

Integrand size = 25, antiderivative size = 126 \[ \int \frac {(a+b \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx=-\frac {(b (c-d)-a (c+d)) (a (c-d)+b (c+d)) x}{\left (c^2+d^2\right )^2}-\frac {2 (b c-a d) (a c+b d) \log (c \cos (e+f x)+d \sin (e+f x))}{\left (c^2+d^2\right )^2 f}-\frac {(b c-a d)^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))} \] Output:

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

Mathematica [C] (verified)

Result contains complex when optimal does not.

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

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

Output:

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

Rubi [A] (verified)

Time = 0.64 (sec) , antiderivative size = 137, normalized size of antiderivative = 1.09, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.240, Rules used = {3042, 4025, 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+b \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4025

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4014

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4013

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

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)/(c^2 + d^2) - (2*(b*c 
 - a*d)*(a*c + b*d)*Log[c*Cos[e + f*x] + d*Sin[e + f*x]])/((c^2 + d^2)*f)) 
/(c^2 + d^2) - (b*c - a*d)^2/(d*(c^2 + d^2)*f*(c + d*Tan[e + f*x]))
 

Defintions of rubi rules used

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.15 (sec) , antiderivative size = 200, normalized size of antiderivative = 1.59

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

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 294 vs. \(2 (125) = 250\).

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

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

Output:

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

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.96 (sec) , antiderivative size = 4258, normalized size of antiderivative = 33.79 \[ \int \frac {(a+b \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx=\text {Too large to display} \] Input:

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

Output:

Piecewise((zoo*x*(a + b*tan(e))**2/tan(e)**2, Eq(c, 0) & Eq(d, 0) & Eq(f, 
0)), ((a**2*x + a*b*log(tan(e + f*x)**2 + 1)/f - b**2*x + b**2*tan(e + f*x 
)/f)/c**2, Eq(d, 0)), (-a**2*f*x*tan(e + f*x)**2/(4*d**2*f*tan(e + f*x)**2 
 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*I*a**2*f*x*tan(e + f*x)/(4*d**2 
*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + a**2*f*x/(4*d** 
2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) - a**2*tan(e + f 
*x)/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*I* 
a**2/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*I 
*a*b*f*x*tan(e + f*x)**2/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f* 
x) - 4*d**2*f) + 4*a*b*f*x*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 - 8*I*d* 
*2*f*tan(e + f*x) - 4*d**2*f) - 2*I*a*b*f*x/(4*d**2*f*tan(e + f*x)**2 - 8* 
I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*I*a*b*tan(e + f*x)/(4*d**2*f*tan(e + 
 f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + b**2*f*x*tan(e + f*x)**2/ 
(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) - 2*I*b**2 
*f*x*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4* 
d**2*f) - b**2*f*x/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4 
*d**2*f) - 3*b**2*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan( 
e + f*x) - 4*d**2*f) + 2*I*b**2/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan 
(e + f*x) - 4*d**2*f), Eq(c, -I*d)), (-a**2*f*x*tan(e + f*x)**2/(4*d**2*f* 
tan(e + f*x)**2 + 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) - 2*I*a**2*f*x*ta...
 

Maxima [A] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 229, normalized size of antiderivative = 1.82 \[ \int \frac {(a+b \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx=\frac {\frac {{\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 )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac {2 \, {\left (a b c^{2} - a b d^{2} - {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac {{\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 )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac {b^{2} c^{2} - 2 \, a b 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+b*tan(f*x+e))^2/(c+d*tan(f*x+e))^2,x, algorithm="maxima")
 

Output:

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

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 276 vs. \(2 (125) = 250\).

Time = 0.20 (sec) , antiderivative size = 276, normalized size of antiderivative = 2.19 \[ \int \frac {(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 )}}{c^{4} f + 2 \, c^{2} d^{2} f + d^{4} 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 )}{c^{4} f + 2 \, c^{2} d^{2} f + d^{4} f} - \frac {2 \, {\left (a b c^{2} d - a^{2} c d^{2} + b^{2} c d^{2} - a b d^{3}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{4} d f + 2 \, c^{2} d^{3} f + d^{5} f} - \frac {b^{2} c^{4} - 2 \, a b c^{3} d + a^{2} c^{2} d^{2} + b^{2} c^{2} d^{2} - 2 \, a b c d^{3} + a^{2} d^{4}}{{\left (c^{2} + d^{2}\right )}^{2} {\left (d \tan \left (f x + e\right ) + c\right )} d f} \] 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)/(c^4*f + 2*c 
^2*d^2*f + d^4*f) + (a*b*c^2 - a^2*c*d + b^2*c*d - a*b*d^2)*log(tan(f*x + 
e)^2 + 1)/(c^4*f + 2*c^2*d^2*f + d^4*f) - 2*(a*b*c^2*d - a^2*c*d^2 + b^2*c 
*d^2 - a*b*d^3)*log(abs(d*tan(f*x + e) + c))/(c^4*d*f + 2*c^2*d^3*f + d^5* 
f) - (b^2*c^4 - 2*a*b*c^3*d + a^2*c^2*d^2 + b^2*c^2*d^2 - 2*a*b*c*d^3 + a^ 
2*d^4)/((c^2 + d^2)^2*(d*tan(f*x + e) + c)*d*f)
 

Mupad [B] (verification not implemented)

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

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

Output:

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

Reduce [B] (verification not implemented)

Time = 0.24 (sec) , antiderivative size = 652, normalized size of antiderivative = 5.17 \[ \int \frac {(a+b \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx =\text {Too large to display} \] Input:

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

Output:

( - log(tan(e + f*x)**2 + 1)*tan(e + f*x)*a**2*c**2*d**2 + log(tan(e + f*x 
)**2 + 1)*tan(e + f*x)*a*b*c**3*d - log(tan(e + f*x)**2 + 1)*tan(e + f*x)* 
a*b*c*d**3 + log(tan(e + f*x)**2 + 1)*tan(e + f*x)*b**2*c**2*d**2 - log(ta 
n(e + f*x)**2 + 1)*a**2*c**3*d + log(tan(e + f*x)**2 + 1)*a*b*c**4 - log(t 
an(e + f*x)**2 + 1)*a*b*c**2*d**2 + log(tan(e + f*x)**2 + 1)*b**2*c**3*d + 
 2*log(tan(e + f*x)*d + c)*tan(e + f*x)*a**2*c**2*d**2 - 2*log(tan(e + f*x 
)*d + c)*tan(e + f*x)*a*b*c**3*d + 2*log(tan(e + f*x)*d + c)*tan(e + f*x)* 
a*b*c*d**3 - 2*log(tan(e + f*x)*d + c)*tan(e + f*x)*b**2*c**2*d**2 + 2*log 
(tan(e + f*x)*d + c)*a**2*c**3*d - 2*log(tan(e + f*x)*d + c)*a*b*c**4 + 2* 
log(tan(e + f*x)*d + c)*a*b*c**2*d**2 - 2*log(tan(e + f*x)*d + c)*b**2*c** 
3*d + tan(e + f*x)*a**2*c**3*d*f*x + tan(e + f*x)*a**2*c**2*d**2 - tan(e + 
 f*x)*a**2*c*d**3*f*x + tan(e + f*x)*a**2*d**4 - 2*tan(e + f*x)*a*b*c**3*d 
 + 4*tan(e + f*x)*a*b*c**2*d**2*f*x - 2*tan(e + f*x)*a*b*c*d**3 + tan(e + 
f*x)*b**2*c**4 - tan(e + f*x)*b**2*c**3*d*f*x + tan(e + f*x)*b**2*c**2*d** 
2 + tan(e + f*x)*b**2*c*d**3*f*x + a**2*c**4*f*x - a**2*c**2*d**2*f*x + 4* 
a*b*c**3*d*f*x - b**2*c**4*f*x + b**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))