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

Optimal result
Mathematica [C] (warning: unable to verify)
Rubi [A] (verified)
Maple [A] (verified)
Fricas [A] (verification not implemented)
Sympy [F]
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 = 46 \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=-\frac {x}{a}+\frac {\sqrt {a+b} \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a+b}}\right )}{a \sqrt {b} f} \] Output:

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

Mathematica [C] (warning: unable to verify)

Result contains complex when optimal does not.

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

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

Output:

-1/2*((a + 2*b + a*Cos[2*(e + f*x)])*Sec[e + f*x]^2*(Sqrt[a + b]*f*x*Sqrt[ 
b*(Cos[e] - I*Sin[e])^4] + (a + b)*ArcTan[(Sec[f*x]*(Cos[2*e] - I*Sin[2*e] 
)*(-((a + 2*b)*Sin[f*x]) + a*Sin[2*e + f*x]))/(2*Sqrt[a + b]*Sqrt[b*(Cos[e 
] - I*Sin[e])^4])]*(Cos[2*e] - I*Sin[2*e])))/(a*Sqrt[a + b]*f*(a + b*Sec[e 
 + f*x]^2)*Sqrt[b*(Cos[e] - I*Sin[e])^4])
 

Rubi [A] (verified)

Time = 0.30 (sec) , antiderivative size = 53, normalized size of antiderivative = 1.15, number of steps used = 7, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.261, Rules used = {3042, 4629, 2075, 383, 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)}{a+b \sec ^2(e+f x)} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4629

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

\(\Big \downarrow \) 2075

\(\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+b\right )}d\tan (e+f x)}{f}\)

\(\Big \downarrow \) 383

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

\(\Big \downarrow \) 216

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

\(\Big \downarrow \) 218

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

Input:

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

Output:

(-(ArcTan[Tan[e + f*x]]/a) + (Sqrt[a + b]*ArcTan[(Sqrt[b]*Tan[e + f*x])/Sq 
rt[a + b]])/(a*Sqrt[b]))/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 383
Int[((e_.)*(x_))^(m_.)/(((a_) + (b_.)*(x_)^2)*((c_) + (d_.)*(x_)^2)), x_Sym 
bol] :> Simp[(-a)*(e^2/(b*c - a*d))   Int[(e*x)^(m - 2)/(a + b*x^2), x], x] 
 + Simp[c*(e^2/(b*c - a*d))   Int[(e*x)^(m - 2)/(c + d*x^2), x], x] /; Free 
Q[{a, b, c, d, e, m}, x] && NeQ[b*c - a*d, 0] && LeQ[2, m, 3]
 

rule 2075
Int[(u_)^(p_.)*(v_)^(q_.)*((e_.)*(x_))^(m_.), x_Symbol] :> Int[(e*x)^m*Expa 
ndToSum[u, x]^p*ExpandToSum[v, x]^q, x] /; FreeQ[{e, m, p, q}, x] && Binomi 
alQ[{u, v}, x] && EqQ[BinomialDegree[u, x] - BinomialDegree[v, x], 0] &&  ! 
BinomialMatchQ[{u, v}, x]
 

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

rule 4629
Int[((a_) + (b_.)*sec[(e_.) + (f_.)*(x_)]^(n_))^(p_.)*((d_.)*tan[(e_.) + (f 
_.)*(x_)])^(m_), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Sim 
p[ff/f   Subst[Int[(d*ff*x)^m*((a + b*(1 + ff^2*x^2)^(n/2))^p/(1 + ff^2*x^2 
)), x], x, Tan[e + f*x]/ff], x]] /; FreeQ[{a, b, d, e, f, m, p}, x] && Inte 
gerQ[n/2] && (IntegerQ[m/2] || EqQ[n, 2])
 
Maple [A] (verified)

Time = 0.69 (sec) , antiderivative size = 48, normalized size of antiderivative = 1.04

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

Input:

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

Output:

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

Fricas [A] (verification not implemented)

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

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

Output:

[-1/4*(4*f*x - sqrt(-(a + b)/b)*log(((a^2 + 8*a*b + 8*b^2)*cos(f*x + e)^4 
- 2*(3*a*b + 4*b^2)*cos(f*x + e)^2 - 4*((a*b + 2*b^2)*cos(f*x + e)^3 - b^2 
*cos(f*x + e))*sqrt(-(a + b)/b)*sin(f*x + e) + b^2)/(a^2*cos(f*x + e)^4 + 
2*a*b*cos(f*x + e)^2 + b^2)))/(a*f), -1/2*(2*f*x + sqrt((a + b)/b)*arctan( 
1/2*((a + 2*b)*cos(f*x + e)^2 - b)*sqrt((a + b)/b)/((a + b)*cos(f*x + e)*s 
in(f*x + e))))/(a*f)]
 

Sympy [F]

\[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=\int \frac {\tan ^{2}{\left (e + f x \right )}}{a + b \sec ^{2}{\left (e + f x \right )}}\, dx \] Input:

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

Output:

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

Maxima [A] (verification not implemented)

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

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

Output:

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

Giac [A] (verification not implemented)

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

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

Output:

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

Mupad [B] (verification not implemented)

Time = 15.64 (sec) , antiderivative size = 126, normalized size of antiderivative = 2.74 \[ \int \frac {\tan ^2(e+f x)}{a+b \sec ^2(e+f x)} \, dx=-\frac {\mathrm {atan}\left (\frac {2\,a\,b^2\,\mathrm {tan}\left (e+f\,x\right )}{2\,a^2\,b+2\,a\,b^2}+\frac {2\,a^2\,b\,\mathrm {tan}\left (e+f\,x\right )}{2\,a^2\,b+2\,a\,b^2}\right )}{a\,f}-\frac {\mathrm {atanh}\left (\frac {2\,a\,b^2\,\mathrm {tan}\left (e+f\,x\right )\,\sqrt {-b^2-a\,b}}{2\,a^2\,b^2+2\,a\,b^3}\right )\,\sqrt {-b\,\left (a+b\right )}}{a\,b\,f} \] Input:

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

Output:

- atan((2*a*b^2*tan(e + f*x))/(2*a*b^2 + 2*a^2*b) + (2*a^2*b*tan(e + f*x)) 
/(2*a*b^2 + 2*a^2*b))/(a*f) - (atanh((2*a*b^2*tan(e + f*x)*(- a*b - b^2)^( 
1/2))/(2*a*b^3 + 2*a^2*b^2))*(-b*(a + b))^(1/2))/(a*b*f)
 

Reduce [B] (verification not implemented)

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

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

Output:

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