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

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [A] (verified)
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 = 23, antiderivative size = 90 \[ \int \frac {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx=-\frac {x}{(a-b)^2}+\frac {(a+b) \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a}}\right )}{2 \sqrt {a} (a-b)^2 \sqrt {b} f}+\frac {\tan (e+f x)}{2 (a-b) f \left (a+b \tan ^2(e+f x)\right )} \] Output:

-x/(a-b)^2+1/2*(a+b)*arctan(b^(1/2)*tan(f*x+e)/a^(1/2))/a^(1/2)/(a-b)^2/b^ 
(1/2)/f+1/2*tan(f*x+e)/(a-b)/f/(a+b*tan(f*x+e)^2)
 

Mathematica [A] (verified)

Time = 0.36 (sec) , antiderivative size = 87, normalized size of antiderivative = 0.97 \[ \int \frac {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx=\frac {-2 (e+f x)+\frac {(a+b) \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a}}\right )}{\sqrt {a} \sqrt {b}}+\frac {(a-b) \sin (2 (e+f x))}{a+b+(a-b) \cos (2 (e+f x))}}{2 (a-b)^2 f} \] Input:

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

Output:

(-2*(e + f*x) + ((a + b)*ArcTan[(Sqrt[b]*Tan[e + f*x])/Sqrt[a]])/(Sqrt[a]* 
Sqrt[b]) + ((a - b)*Sin[2*(e + f*x)])/(a + b + (a - b)*Cos[2*(e + f*x)]))/ 
(2*(a - b)^2*f)
 

Rubi [A] (verified)

Time = 0.45 (sec) , antiderivative size = 104, normalized size of antiderivative = 1.16, number of steps used = 7, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.261, Rules used = {3042, 4153, 373, 397, 216, 218}

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 {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4153

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

\(\Big \downarrow \) 373

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

\(\Big \downarrow \) 397

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

\(\Big \downarrow \) 216

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

\(\Big \downarrow \) 218

\(\displaystyle \frac {\frac {\tan (e+f x)}{2 (a-b) \left (a+b \tan ^2(e+f x)\right )}-\frac {\frac {2 \arctan (\tan (e+f x))}{a-b}-\frac {(a+b) \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a}}\right )}{\sqrt {a} \sqrt {b} (a-b)}}{2 (a-b)}}{f}\)

Input:

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

Output:

(-1/2*((2*ArcTan[Tan[e + f*x]])/(a - b) - ((a + b)*ArcTan[(Sqrt[b]*Tan[e + 
 f*x])/Sqrt[a]])/(Sqrt[a]*(a - b)*Sqrt[b]))/(a - b) + Tan[e + f*x]/(2*(a - 
 b)*(a + b*Tan[e + f*x]^2)))/f
 

Defintions of rubi rules used

rule 216
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*A 
rcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /; FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a 
, 0] || GtQ[b, 0])
 

rule 218
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/R 
t[a/b, 2]], x] /; FreeQ[{a, b}, x] && PosQ[a/b]
 

rule 373
Int[((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^2)^(p_)*((c_) + (d_.)*(x_)^2)^(q_ 
), x_Symbol] :> Simp[e*(e*x)^(m - 1)*(a + b*x^2)^(p + 1)*((c + d*x^2)^(q + 
1)/(2*(b*c - a*d)*(p + 1))), x] - Simp[e^2/(2*(b*c - a*d)*(p + 1))   Int[(e 
*x)^(m - 2)*(a + b*x^2)^(p + 1)*(c + d*x^2)^q*Simp[c*(m - 1) + d*(m + 2*p + 
 2*q + 3)*x^2, x], x], x] /; FreeQ[{a, b, c, d, e, q}, x] && NeQ[b*c - a*d, 
 0] && LtQ[p, -1] && GtQ[m, 1] && LeQ[m, 3] && IntBinomialQ[a, b, c, d, e, 
m, 2, p, q, x]
 

rule 397
Int[((e_) + (f_.)*(x_)^2)/(((a_) + (b_.)*(x_)^2)*((c_) + (d_.)*(x_)^2)), x_ 
Symbol] :> Simp[(b*e - a*f)/(b*c - a*d)   Int[1/(a + b*x^2), x], x] - Simp[ 
(d*e - c*f)/(b*c - a*d)   Int[1/(c + d*x^2), x], x] /; FreeQ[{a, b, c, d, e 
, f}, x]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4153
Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + 
(f_.)*(x_)])^(n_))^(p_.), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x], 
 x]}, Simp[c*(ff/f)   Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2 + f 
f^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, 
n, p}, x] && (IGtQ[p, 0] || EqQ[n, 2] || EqQ[n, 4] || (IntegerQ[p] && Ratio 
nalQ[n]))
 
Maple [A] (verified)

Time = 0.82 (sec) , antiderivative size = 83, normalized size of antiderivative = 0.92

method result size
derivativedivides \(\frac {-\frac {\arctan \left (\tan \left (f x +e \right )\right )}{\left (a -b \right )^{2}}+\frac {\frac {\left (\frac {a}{2}-\frac {b}{2}\right ) \tan \left (f x +e \right )}{a +b \tan \left (f x +e \right )^{2}}+\frac {\left (a +b \right ) \arctan \left (\frac {b \tan \left (f x +e \right )}{\sqrt {a b}}\right )}{2 \sqrt {a b}}}{\left (a -b \right )^{2}}}{f}\) \(83\)
default \(\frac {-\frac {\arctan \left (\tan \left (f x +e \right )\right )}{\left (a -b \right )^{2}}+\frac {\frac {\left (\frac {a}{2}-\frac {b}{2}\right ) \tan \left (f x +e \right )}{a +b \tan \left (f x +e \right )^{2}}+\frac {\left (a +b \right ) \arctan \left (\frac {b \tan \left (f x +e \right )}{\sqrt {a b}}\right )}{2 \sqrt {a b}}}{\left (a -b \right )^{2}}}{f}\) \(83\)
risch \(-\frac {x}{a^{2}-2 a b +b^{2}}+\frac {i \left (a \,{\mathrm e}^{2 i \left (f x +e \right )}+b \,{\mathrm e}^{2 i \left (f x +e \right )}+a -b \right )}{f \left (a -b \right )^{2} \left (a \,{\mathrm e}^{4 i \left (f x +e \right )}-b \,{\mathrm e}^{4 i \left (f x +e \right )}+2 a \,{\mathrm e}^{2 i \left (f x +e \right )}+2 b \,{\mathrm e}^{2 i \left (f x +e \right )}+a -b \right )}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+\frac {-2 i a b +\sqrt {-a b}\, a +\sqrt {-a b}\, b}{\left (a -b \right ) \sqrt {-a b}}\right ) a}{4 \sqrt {-a b}\, \left (a -b \right )^{2} f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+\frac {-2 i a b +\sqrt {-a b}\, a +\sqrt {-a b}\, b}{\left (a -b \right ) \sqrt {-a b}}\right ) b}{4 \sqrt {-a b}\, \left (a -b \right )^{2} f}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+\frac {2 i a b +\sqrt {-a b}\, a +\sqrt {-a b}\, b}{\left (a -b \right ) \sqrt {-a b}}\right ) a}{4 \sqrt {-a b}\, \left (a -b \right )^{2} f}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+\frac {2 i a b +\sqrt {-a b}\, a +\sqrt {-a b}\, b}{\left (a -b \right ) \sqrt {-a b}}\right ) b}{4 \sqrt {-a b}\, \left (a -b \right )^{2} f}\) \(376\)

Input:

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

Output:

1/f*(-1/(a-b)^2*arctan(tan(f*x+e))+1/(a-b)^2*((1/2*a-1/2*b)*tan(f*x+e)/(a+ 
b*tan(f*x+e)^2)+1/2*(a+b)/(a*b)^(1/2)*arctan(b*tan(f*x+e)/(a*b)^(1/2))))
 

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 170 vs. \(2 (78) = 156\).

Time = 0.12 (sec) , antiderivative size = 393, normalized size of antiderivative = 4.37 \[ \int \frac {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx=\left [-\frac {8 \, a b^{2} f x \tan \left (f x + e\right )^{2} + 8 \, a^{2} b f x + {\left ({\left (a b + b^{2}\right )} \tan \left (f x + e\right )^{2} + a^{2} + a b\right )} \sqrt {-a b} \log \left (\frac {b^{2} \tan \left (f x + e\right )^{4} - 6 \, a b \tan \left (f x + e\right )^{2} + a^{2} - 4 \, {\left (b \tan \left (f x + e\right )^{3} - a \tan \left (f x + e\right )\right )} \sqrt {-a b}}{b^{2} \tan \left (f x + e\right )^{4} + 2 \, a b \tan \left (f x + e\right )^{2} + a^{2}}\right ) - 4 \, {\left (a^{2} b - a b^{2}\right )} \tan \left (f x + e\right )}{8 \, {\left ({\left (a^{3} b^{2} - 2 \, a^{2} b^{3} + a b^{4}\right )} f \tan \left (f x + e\right )^{2} + {\left (a^{4} b - 2 \, a^{3} b^{2} + a^{2} b^{3}\right )} f\right )}}, -\frac {4 \, a b^{2} f x \tan \left (f x + e\right )^{2} + 4 \, a^{2} b f x - {\left ({\left (a b + b^{2}\right )} \tan \left (f x + e\right )^{2} + a^{2} + a b\right )} \sqrt {a b} \arctan \left (\frac {{\left (b \tan \left (f x + e\right )^{2} - a\right )} \sqrt {a b}}{2 \, a b \tan \left (f x + e\right )}\right ) - 2 \, {\left (a^{2} b - a b^{2}\right )} \tan \left (f x + e\right )}{4 \, {\left ({\left (a^{3} b^{2} - 2 \, a^{2} b^{3} + a b^{4}\right )} f \tan \left (f x + e\right )^{2} + {\left (a^{4} b - 2 \, a^{3} b^{2} + a^{2} b^{3}\right )} f\right )}}\right ] \] Input:

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

Output:

[-1/8*(8*a*b^2*f*x*tan(f*x + e)^2 + 8*a^2*b*f*x + ((a*b + b^2)*tan(f*x + e 
)^2 + a^2 + a*b)*sqrt(-a*b)*log((b^2*tan(f*x + e)^4 - 6*a*b*tan(f*x + e)^2 
 + a^2 - 4*(b*tan(f*x + e)^3 - a*tan(f*x + e))*sqrt(-a*b))/(b^2*tan(f*x + 
e)^4 + 2*a*b*tan(f*x + e)^2 + a^2)) - 4*(a^2*b - a*b^2)*tan(f*x + e))/((a^ 
3*b^2 - 2*a^2*b^3 + a*b^4)*f*tan(f*x + e)^2 + (a^4*b - 2*a^3*b^2 + a^2*b^3 
)*f), -1/4*(4*a*b^2*f*x*tan(f*x + e)^2 + 4*a^2*b*f*x - ((a*b + b^2)*tan(f* 
x + e)^2 + a^2 + a*b)*sqrt(a*b)*arctan(1/2*(b*tan(f*x + e)^2 - a)*sqrt(a*b 
)/(a*b*tan(f*x + e))) - 2*(a^2*b - a*b^2)*tan(f*x + e))/((a^3*b^2 - 2*a^2* 
b^3 + a*b^4)*f*tan(f*x + e)^2 + (a^4*b - 2*a^3*b^2 + a^2*b^3)*f)]
 

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 2113 vs. \(2 (73) = 146\).

Time = 10.72 (sec) , antiderivative size = 2113, normalized size of antiderivative = 23.48 \[ \int \frac {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx=\text {Too large to display} \] Input:

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

Output:

Piecewise((zoo*x/tan(e)**2, Eq(a, 0) & Eq(b, 0) & Eq(f, 0)), ((-x + tan(e 
+ f*x)/f)/a**2, Eq(b, 0)), ((-x - 1/(f*tan(e + f*x)))/b**2, Eq(a, 0)), (f* 
x*tan(e + f*x)**4/(8*b**2*f*tan(e + f*x)**4 + 16*b**2*f*tan(e + f*x)**2 + 
8*b**2*f) + 2*f*x*tan(e + f*x)**2/(8*b**2*f*tan(e + f*x)**4 + 16*b**2*f*ta 
n(e + f*x)**2 + 8*b**2*f) + f*x/(8*b**2*f*tan(e + f*x)**4 + 16*b**2*f*tan( 
e + f*x)**2 + 8*b**2*f) + tan(e + f*x)**3/(8*b**2*f*tan(e + f*x)**4 + 16*b 
**2*f*tan(e + f*x)**2 + 8*b**2*f) - tan(e + f*x)/(8*b**2*f*tan(e + f*x)**4 
 + 16*b**2*f*tan(e + f*x)**2 + 8*b**2*f), Eq(a, b)), (x*tan(e)**2/(a + b*t 
an(e)**2)**2, Eq(f, 0)), (a**2*log(-sqrt(-a/b) + tan(e + f*x))/(4*a**3*b*f 
*sqrt(-a/b) + 4*a**2*b**2*f*sqrt(-a/b)*tan(e + f*x)**2 - 8*a**2*b**2*f*sqr 
t(-a/b) - 8*a*b**3*f*sqrt(-a/b)*tan(e + f*x)**2 + 4*a*b**3*f*sqrt(-a/b) + 
4*b**4*f*sqrt(-a/b)*tan(e + f*x)**2) - a**2*log(sqrt(-a/b) + tan(e + f*x)) 
/(4*a**3*b*f*sqrt(-a/b) + 4*a**2*b**2*f*sqrt(-a/b)*tan(e + f*x)**2 - 8*a** 
2*b**2*f*sqrt(-a/b) - 8*a*b**3*f*sqrt(-a/b)*tan(e + f*x)**2 + 4*a*b**3*f*s 
qrt(-a/b) + 4*b**4*f*sqrt(-a/b)*tan(e + f*x)**2) - 4*a*b*f*x*sqrt(-a/b)/(4 
*a**3*b*f*sqrt(-a/b) + 4*a**2*b**2*f*sqrt(-a/b)*tan(e + f*x)**2 - 8*a**2*b 
**2*f*sqrt(-a/b) - 8*a*b**3*f*sqrt(-a/b)*tan(e + f*x)**2 + 4*a*b**3*f*sqrt 
(-a/b) + 4*b**4*f*sqrt(-a/b)*tan(e + f*x)**2) + 2*a*b*sqrt(-a/b)*tan(e + f 
*x)/(4*a**3*b*f*sqrt(-a/b) + 4*a**2*b**2*f*sqrt(-a/b)*tan(e + f*x)**2 - 8* 
a**2*b**2*f*sqrt(-a/b) - 8*a*b**3*f*sqrt(-a/b)*tan(e + f*x)**2 + 4*a*b*...
 

Maxima [A] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 97, normalized size of antiderivative = 1.08 \[ \int \frac {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx=\frac {\frac {{\left (a + b\right )} \arctan \left (\frac {b \tan \left (f x + e\right )}{\sqrt {a b}}\right )}{{\left (a^{2} - 2 \, a b + b^{2}\right )} \sqrt {a b}} - \frac {2 \, {\left (f x + e\right )}}{a^{2} - 2 \, a b + b^{2}} + \frac {\tan \left (f x + e\right )}{{\left (a b - b^{2}\right )} \tan \left (f x + e\right )^{2} + a^{2} - a b}}{2 \, f} \] Input:

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

Output:

1/2*((a + b)*arctan(b*tan(f*x + e)/sqrt(a*b))/((a^2 - 2*a*b + b^2)*sqrt(a* 
b)) - 2*(f*x + e)/(a^2 - 2*a*b + b^2) + tan(f*x + e)/((a*b - b^2)*tan(f*x 
+ e)^2 + a^2 - a*b))/f
 

Giac [A] (verification not implemented)

Time = 0.57 (sec) , antiderivative size = 100, normalized size of antiderivative = 1.11 \[ \int \frac {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx=\frac {{\left (a + b\right )} \arctan \left (\frac {b \tan \left (f x + e\right )}{\sqrt {a b}}\right )}{2 \, {\left (a^{2} f - 2 \, a b f + b^{2} f\right )} \sqrt {a b}} - \frac {f x + e}{a^{2} f - 2 \, a b f + b^{2} f} + \frac {\tan \left (f x + e\right )}{2 \, {\left (b \tan \left (f x + e\right )^{2} + a\right )} {\left (a f - b f\right )}} \] Input:

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

Output:

1/2*(a + b)*arctan(b*tan(f*x + e)/sqrt(a*b))/((a^2*f - 2*a*b*f + b^2*f)*sq 
rt(a*b)) - (f*x + e)/(a^2*f - 2*a*b*f + b^2*f) + 1/2*tan(f*x + e)/((b*tan( 
f*x + e)^2 + a)*(a*f - b*f))
 

Mupad [B] (verification not implemented)

Time = 8.91 (sec) , antiderivative size = 2136, normalized size of antiderivative = 23.73 \[ \int \frac {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx=\text {Too large to display} \] Input:

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

Output:

tan(e + f*x)/(2*f*(a + b*tan(e + f*x)^2)*(a - b)) - (2*atan((((((2*b^6 - 8 
*a*b^5 + 12*a^2*b^4 - 8*a^3*b^3 + 2*a^4*b^2)*1i)/(3*a*b^2 - 3*a^2*b + a^3 
- b^3) - (tan(e + f*x)*(16*b^7 - 48*a*b^6 + 32*a^2*b^5 + 32*a^3*b^4 - 48*a 
^4*b^3 + 16*a^5*b^2))/(2*(a^2 - 2*a*b + b^2)*(2*a^2 - 4*a*b + 2*b^2)))/(2* 
a^2 - 4*a*b + 2*b^2) + (tan(e + f*x)*(2*a*b^2 + a^2*b + 5*b^3))/(2*(a^2 - 
2*a*b + b^2)))/(2*a^2 - 4*a*b + 2*b^2) - ((((2*b^6 - 8*a*b^5 + 12*a^2*b^4 
- 8*a^3*b^3 + 2*a^4*b^2)*1i)/(3*a*b^2 - 3*a^2*b + a^3 - b^3) + (tan(e + f* 
x)*(16*b^7 - 48*a*b^6 + 32*a^2*b^5 + 32*a^3*b^4 - 48*a^4*b^3 + 16*a^5*b^2) 
)/(2*(a^2 - 2*a*b + b^2)*(2*a^2 - 4*a*b + 2*b^2)))/(2*a^2 - 4*a*b + 2*b^2) 
 - (tan(e + f*x)*(2*a*b^2 + a^2*b + 5*b^3))/(2*(a^2 - 2*a*b + b^2)))/(2*a^ 
2 - 4*a*b + 2*b^2))/((((((2*b^6 - 8*a*b^5 + 12*a^2*b^4 - 8*a^3*b^3 + 2*a^4 
*b^2)*1i)/(3*a*b^2 - 3*a^2*b + a^3 - b^3) - (tan(e + f*x)*(16*b^7 - 48*a*b 
^6 + 32*a^2*b^5 + 32*a^3*b^4 - 48*a^4*b^3 + 16*a^5*b^2))/(2*(a^2 - 2*a*b + 
 b^2)*(2*a^2 - 4*a*b + 2*b^2)))*1i)/(2*a^2 - 4*a*b + 2*b^2) + (tan(e + f*x 
)*(2*a*b^2 + a^2*b + 5*b^3)*1i)/(2*(a^2 - 2*a*b + b^2)))/(2*a^2 - 4*a*b + 
2*b^2) + (((((2*b^6 - 8*a*b^5 + 12*a^2*b^4 - 8*a^3*b^3 + 2*a^4*b^2)*1i)/(3 
*a*b^2 - 3*a^2*b + a^3 - b^3) + (tan(e + f*x)*(16*b^7 - 48*a*b^6 + 32*a^2* 
b^5 + 32*a^3*b^4 - 48*a^4*b^3 + 16*a^5*b^2))/(2*(a^2 - 2*a*b + b^2)*(2*a^2 
 - 4*a*b + 2*b^2)))*1i)/(2*a^2 - 4*a*b + 2*b^2) - (tan(e + f*x)*(2*a*b^2 + 
 a^2*b + 5*b^3)*1i)/(2*(a^2 - 2*a*b + b^2)))/(2*a^2 - 4*a*b + 2*b^2) + ...
 

Reduce [B] (verification not implemented)

Time = 0.25 (sec) , antiderivative size = 229, normalized size of antiderivative = 2.54 \[ \int \frac {\tan ^2(e+f x)}{\left (a+b \tan ^2(e+f x)\right )^2} \, dx=\frac {\sqrt {b}\, \sqrt {a}\, \mathit {atan} \left (\frac {\tan \left (f x +e \right ) b}{\sqrt {b}\, \sqrt {a}}\right ) \tan \left (f x +e \right )^{2} a b +\sqrt {b}\, \sqrt {a}\, \mathit {atan} \left (\frac {\tan \left (f x +e \right ) b}{\sqrt {b}\, \sqrt {a}}\right ) \tan \left (f x +e \right )^{2} b^{2}+\sqrt {b}\, \sqrt {a}\, \mathit {atan} \left (\frac {\tan \left (f x +e \right ) b}{\sqrt {b}\, \sqrt {a}}\right ) a^{2}+\sqrt {b}\, \sqrt {a}\, \mathit {atan} \left (\frac {\tan \left (f x +e \right ) b}{\sqrt {b}\, \sqrt {a}}\right ) a b -2 \tan \left (f x +e \right )^{2} a \,b^{2} f x +\tan \left (f x +e \right ) a^{2} b -\tan \left (f x +e \right ) a \,b^{2}-2 a^{2} b f x}{2 a b f \left (\tan \left (f x +e \right )^{2} a^{2} b -2 \tan \left (f x +e \right )^{2} a \,b^{2}+\tan \left (f x +e \right )^{2} b^{3}+a^{3}-2 a^{2} b +a \,b^{2}\right )} \] Input:

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

Output:

(sqrt(b)*sqrt(a)*atan((tan(e + f*x)*b)/(sqrt(b)*sqrt(a)))*tan(e + f*x)**2* 
a*b + sqrt(b)*sqrt(a)*atan((tan(e + f*x)*b)/(sqrt(b)*sqrt(a)))*tan(e + f*x 
)**2*b**2 + sqrt(b)*sqrt(a)*atan((tan(e + f*x)*b)/(sqrt(b)*sqrt(a)))*a**2 
+ sqrt(b)*sqrt(a)*atan((tan(e + f*x)*b)/(sqrt(b)*sqrt(a)))*a*b - 2*tan(e + 
 f*x)**2*a*b**2*f*x + tan(e + f*x)*a**2*b - tan(e + f*x)*a*b**2 - 2*a**2*b 
*f*x)/(2*a*b*f*(tan(e + f*x)**2*a**2*b - 2*tan(e + f*x)**2*a*b**2 + tan(e 
+ f*x)**2*b**3 + a**3 - 2*a**2*b + a*b**2))