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

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

Optimal result

Integrand size = 25, antiderivative size = 80 \[ \int \frac {\tan ^2(e+f x)}{\sqrt {a+b \sec ^2(e+f x)}} \, dx=-\frac {\arctan \left (\frac {\sqrt {a} \tan (e+f x)}{\sqrt {a+b+b \tan ^2(e+f x)}}\right )}{\sqrt {a} f}+\frac {\text {arctanh}\left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a+b+b \tan ^2(e+f x)}}\right )}{\sqrt {b} f} \] Output:

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

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 1.51 (sec) , antiderivative size = 296, normalized size of antiderivative = 3.70 \[ \int \frac {\tan ^2(e+f x)}{\sqrt {a+b \sec ^2(e+f x)}} \, dx=\frac {i \sqrt {4 b e^{2 i (e+f x)}+a \left (1+e^{2 i (e+f x)}\right )^2} \left (-2 \sqrt {a} \arctan \left (\frac {\sqrt {b} \left (-1+e^{2 i (e+f x)}\right )}{\sqrt {4 b e^{2 i (e+f x)}+a \left (1+e^{2 i (e+f x)}\right )^2}}\right )+\sqrt {b} \text {arctanh}\left (\frac {a+2 b+a e^{2 i (e+f x)}}{\sqrt {a} \sqrt {4 b e^{2 i (e+f x)}+a \left (1+e^{2 i (e+f x)}\right )^2}}\right )-\sqrt {b} \text {arctanh}\left (\frac {a+a e^{2 i (e+f x)}+2 b e^{2 i (e+f x)}}{\sqrt {a} \sqrt {4 b e^{2 i (e+f x)}+a \left (1+e^{2 i (e+f x)}\right )^2}}\right )\right )}{2 \sqrt {a} \sqrt {b} \left (1+e^{2 i (e+f x)}\right ) f \sqrt {a+b \sec ^2(e+f x)}} \] Input:

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

Output:

((I/2)*Sqrt[4*b*E^((2*I)*(e + f*x)) + a*(1 + E^((2*I)*(e + f*x)))^2]*(-2*S 
qrt[a]*ArcTan[(Sqrt[b]*(-1 + E^((2*I)*(e + f*x))))/Sqrt[4*b*E^((2*I)*(e + 
f*x)) + a*(1 + E^((2*I)*(e + f*x)))^2]] + Sqrt[b]*ArcTanh[(a + 2*b + a*E^( 
(2*I)*(e + f*x)))/(Sqrt[a]*Sqrt[4*b*E^((2*I)*(e + f*x)) + a*(1 + E^((2*I)* 
(e + f*x)))^2])] - Sqrt[b]*ArcTanh[(a + a*E^((2*I)*(e + f*x)) + 2*b*E^((2* 
I)*(e + f*x)))/(Sqrt[a]*Sqrt[4*b*E^((2*I)*(e + f*x)) + a*(1 + E^((2*I)*(e 
+ f*x)))^2])]))/(Sqrt[a]*Sqrt[b]*(1 + E^((2*I)*(e + f*x)))*f*Sqrt[a + b*Se 
c[e + f*x]^2])
 

Rubi [A] (verified)

Time = 0.34 (sec) , antiderivative size = 78, normalized size of antiderivative = 0.98, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.320, Rules used = {3042, 4629, 2075, 385, 224, 219, 291, 216}

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

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\tan (e+f x)^2}{\sqrt {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 ) \sqrt {a+b \left (\tan ^2(e+f x)+1\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 ) \sqrt {b \tan ^2(e+f x)+a+b}}d\tan (e+f x)}{f}\)

\(\Big \downarrow \) 385

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

\(\Big \downarrow \) 224

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

\(\Big \downarrow \) 219

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

\(\Big \downarrow \) 291

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

\(\Big \downarrow \) 216

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

Input:

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

Output:

(-(ArcTan[(Sqrt[a]*Tan[e + f*x])/Sqrt[a + b + b*Tan[e + f*x]^2]]/Sqrt[a]) 
+ ArcTanh[(Sqrt[b]*Tan[e + f*x])/Sqrt[a + b + b*Tan[e + f*x]^2]]/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 219
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))* 
ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x] /; FreeQ[{a, b}, x] && NegQ[a/b] && (Gt 
Q[a, 0] || LtQ[b, 0])
 

rule 224
Int[1/Sqrt[(a_) + (b_.)*(x_)^2], x_Symbol] :> Subst[Int[1/(1 - b*x^2), x], 
x, x/Sqrt[a + b*x^2]] /; FreeQ[{a, b}, x] &&  !GtQ[a, 0]
 

rule 291
Int[1/(Sqrt[(a_) + (b_.)*(x_)^2]*((c_) + (d_.)*(x_)^2)), x_Symbol] :> Subst 
[Int[1/(c - (b*c - a*d)*x^2), x], x, x/Sqrt[a + b*x^2]] /; FreeQ[{a, b, c, 
d}, x] && NeQ[b*c - a*d, 0]
 

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

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 [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(341\) vs. \(2(68)=136\).

Time = 2.19 (sec) , antiderivative size = 342, normalized size of antiderivative = 4.28

method result size
default \(\frac {\left (\ln \left (\frac {4 \sqrt {b}\, \sqrt {\frac {b +a \cos \left (f x +e \right )^{2}}{\left (1+\cos \left (f x +e \right )\right )^{2}}}\, \cos \left (f x +e \right )+4 \sqrt {b}\, \sqrt {\frac {b +a \cos \left (f x +e \right )^{2}}{\left (1+\cos \left (f x +e \right )\right )^{2}}}-4 \sin \left (f x +e \right ) a -4 a -4 b}{\sin \left (f x +e \right )+1}\right ) \sqrt {-a}+\ln \left (-\frac {4 \left (\sqrt {b}\, \sqrt {\frac {b +a \cos \left (f x +e \right )^{2}}{\left (1+\cos \left (f x +e \right )\right )^{2}}}\, \cos \left (f x +e \right )+\sqrt {b}\, \sqrt {\frac {b +a \cos \left (f x +e \right )^{2}}{\left (1+\cos \left (f x +e \right )\right )^{2}}}-\sin \left (f x +e \right ) a +a +b \right )}{\sin \left (f x +e \right )-1}\right ) \sqrt {-a}-2 \ln \left (4 \sqrt {-a}\, \sqrt {\frac {b +a \cos \left (f x +e \right )^{2}}{\left (1+\cos \left (f x +e \right )\right )^{2}}}\, \cos \left (f x +e \right )+4 \sqrt {-a}\, \sqrt {\frac {b +a \cos \left (f x +e \right )^{2}}{\left (1+\cos \left (f x +e \right )\right )^{2}}}-4 \sin \left (f x +e \right ) a \right ) \sqrt {b}\right ) \sqrt {\frac {b +a \cos \left (f x +e \right )^{2}}{\left (1+\cos \left (f x +e \right )\right )^{2}}}\, \left (\sec \left (f x +e \right )+1\right )}{2 f \sqrt {-a}\, \sqrt {b}\, \sqrt {a +b \sec \left (f x +e \right )^{2}}}\) \(342\)

Input:

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

Output:

1/2/f/(-a)^(1/2)/b^(1/2)*(ln(4*(b^(1/2)*((b+a*cos(f*x+e)^2)/(1+cos(f*x+e)) 
^2)^(1/2)*cos(f*x+e)+b^(1/2)*((b+a*cos(f*x+e)^2)/(1+cos(f*x+e))^2)^(1/2)-s 
in(f*x+e)*a-a-b)/(sin(f*x+e)+1))*(-a)^(1/2)+ln(-4*(b^(1/2)*((b+a*cos(f*x+e 
)^2)/(1+cos(f*x+e))^2)^(1/2)*cos(f*x+e)+b^(1/2)*((b+a*cos(f*x+e)^2)/(1+cos 
(f*x+e))^2)^(1/2)-sin(f*x+e)*a+a+b)/(sin(f*x+e)-1))*(-a)^(1/2)-2*ln(4*(-a) 
^(1/2)*((b+a*cos(f*x+e)^2)/(1+cos(f*x+e))^2)^(1/2)*cos(f*x+e)+4*(-a)^(1/2) 
*((b+a*cos(f*x+e)^2)/(1+cos(f*x+e))^2)^(1/2)-4*sin(f*x+e)*a)*b^(1/2))*((b+ 
a*cos(f*x+e)^2)/(1+cos(f*x+e))^2)^(1/2)/(a+b*sec(f*x+e)^2)^(1/2)*(sec(f*x+ 
e)+1)
 

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 239 vs. \(2 (68) = 136\).

Time = 0.33 (sec) , antiderivative size = 1259, normalized size of antiderivative = 15.74 \[ \int \frac {\tan ^2(e+f x)}{\sqrt {a+b \sec ^2(e+f x)}} \, dx=\text {Too large to display} \] Input:

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

Output:

[-1/8*(sqrt(-a)*b*log(128*a^4*cos(f*x + e)^8 - 256*(a^4 - a^3*b)*cos(f*x + 
 e)^6 + 32*(5*a^4 - 14*a^3*b + 5*a^2*b^2)*cos(f*x + e)^4 + a^4 - 28*a^3*b 
+ 70*a^2*b^2 - 28*a*b^3 + b^4 - 32*(a^4 - 7*a^3*b + 7*a^2*b^2 - a*b^3)*cos 
(f*x + e)^2 - 8*(16*a^3*cos(f*x + e)^7 - 24*(a^3 - a^2*b)*cos(f*x + e)^5 + 
 2*(5*a^3 - 14*a^2*b + 5*a*b^2)*cos(f*x + e)^3 - (a^3 - 7*a^2*b + 7*a*b^2 
- b^3)*cos(f*x + e))*sqrt(-a)*sqrt((a*cos(f*x + e)^2 + b)/cos(f*x + e)^2)* 
sin(f*x + e)) - 2*a*sqrt(b)*log(((a^2 - 6*a*b + b^2)*cos(f*x + e)^4 + 8*(a 
*b - b^2)*cos(f*x + e)^2 + 4*((a - b)*cos(f*x + e)^3 + 2*b*cos(f*x + e))*s 
qrt(b)*sqrt((a*cos(f*x + e)^2 + b)/cos(f*x + e)^2)*sin(f*x + e) + 8*b^2)/c 
os(f*x + e)^4))/(a*b*f), 1/8*(4*a*sqrt(-b)*arctan(-1/2*((a - b)*cos(f*x + 
e)^3 + 2*b*cos(f*x + e))*sqrt(-b)*sqrt((a*cos(f*x + e)^2 + b)/cos(f*x + e) 
^2)/((a*b*cos(f*x + e)^2 + b^2)*sin(f*x + e))) - sqrt(-a)*b*log(128*a^4*co 
s(f*x + e)^8 - 256*(a^4 - a^3*b)*cos(f*x + e)^6 + 32*(5*a^4 - 14*a^3*b + 5 
*a^2*b^2)*cos(f*x + e)^4 + a^4 - 28*a^3*b + 70*a^2*b^2 - 28*a*b^3 + b^4 - 
32*(a^4 - 7*a^3*b + 7*a^2*b^2 - a*b^3)*cos(f*x + e)^2 - 8*(16*a^3*cos(f*x 
+ e)^7 - 24*(a^3 - a^2*b)*cos(f*x + e)^5 + 2*(5*a^3 - 14*a^2*b + 5*a*b^2)* 
cos(f*x + e)^3 - (a^3 - 7*a^2*b + 7*a*b^2 - b^3)*cos(f*x + e))*sqrt(-a)*sq 
rt((a*cos(f*x + e)^2 + b)/cos(f*x + e)^2)*sin(f*x + e)))/(a*b*f), 1/4*(sqr 
t(a)*b*arctan(1/4*(8*a^2*cos(f*x + e)^5 - 8*(a^2 - a*b)*cos(f*x + e)^3 + ( 
a^2 - 6*a*b + b^2)*cos(f*x + e))*sqrt(a)*sqrt((a*cos(f*x + e)^2 + b)/co...
 

Sympy [F]

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

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

Output:

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

Maxima [F]

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

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

Output:

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

Giac [F]

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

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

Output:

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

Mupad [F(-1)]

Timed out. \[ \int \frac {\tan ^2(e+f x)}{\sqrt {a+b \sec ^2(e+f x)}} \, dx=\int \frac {{\mathrm {tan}\left (e+f\,x\right )}^2}{\sqrt {a+\frac {b}{{\cos \left (e+f\,x\right )}^2}}} \,d x \] Input:

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

Output:

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

Reduce [F]

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

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

Output:

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