\(\int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx\) [711]

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

Optimal result

Integrand size = 15, antiderivative size = 14 \[ \int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx=\text {arctanh}\left (\frac {\tan (x)}{\sqrt {-4+\tan ^2(x)}}\right ) \]

[Out]

arctanh(tan(x)/(-4+tan(x)^2)^(1/2))

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 14, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {3756, 223, 212} \[ \int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx=\text {arctanh}\left (\frac {\tan (x)}{\sqrt {\tan ^2(x)-4}}\right ) \]

[In]

Int[Sec[x]^2/Sqrt[-4 + Tan[x]^2],x]

[Out]

ArcTanh[Tan[x]/Sqrt[-4 + Tan[x]^2]]

Rule 212

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] && (GtQ[a, 0] || LtQ[b, 0])

Rule 223

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 3756

Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol] :> With[
{ff = FreeFactors[Tan[e + f*x], x]}, Dist[ff/(c^(m - 1)*f), Subst[Int[(c^2 + ff^2*x^2)^(m/2 - 1)*(a + b*(ff*x)
^n)^p, x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, e, f, n, p}, x] && IntegerQ[m/2] && (IntegersQ[n, p
] || IGtQ[m, 0] || IGtQ[p, 0] || EqQ[n^2, 4] || EqQ[n^2, 16])

Rubi steps \begin{align*} \text {integral}& = \text {Subst}\left (\int \frac {1}{\sqrt {-4+x^2}} \, dx,x,\tan (x)\right ) \\ & = \text {Subst}\left (\int \frac {1}{1-x^2} \, dx,x,\frac {\tan (x)}{\sqrt {-4+\tan ^2(x)}}\right ) \\ & = \text {arctanh}\left (\frac {\tan (x)}{\sqrt {-4+\tan ^2(x)}}\right ) \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(46\) vs. \(2(14)=28\).

Time = 0.04 (sec) , antiderivative size = 46, normalized size of antiderivative = 3.29 \[ \int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx=\frac {\arctan \left (\frac {\sin (x)}{\sqrt {4-5 \sin ^2(x)}}\right ) \sqrt {3+5 \cos (2 x)} \sec (x)}{\sqrt {2} \sqrt {-4+\tan ^2(x)}} \]

[In]

Integrate[Sec[x]^2/Sqrt[-4 + Tan[x]^2],x]

[Out]

(ArcTan[Sin[x]/Sqrt[4 - 5*Sin[x]^2]]*Sqrt[3 + 5*Cos[2*x]]*Sec[x])/(Sqrt[2]*Sqrt[-4 + Tan[x]^2])

Maple [A] (verified)

Time = 0.88 (sec) , antiderivative size = 13, normalized size of antiderivative = 0.93

method result size
derivativedivides \(\ln \left (\tan \left (x \right )+\sqrt {-4+\tan \left (x \right )^{2}}\right )\) \(13\)
default \(\ln \left (\tan \left (x \right )+\sqrt {-4+\tan \left (x \right )^{2}}\right )\) \(13\)

[In]

int(sec(x)^2/(-4+tan(x)^2)^(1/2),x,method=_RETURNVERBOSE)

[Out]

ln(tan(x)+(-4+tan(x)^2)^(1/2))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 67 vs. \(2 (12) = 24\).

Time = 0.26 (sec) , antiderivative size = 67, normalized size of antiderivative = 4.79 \[ \int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx=\frac {1}{4} \, \log \left (\frac {1}{2} \, \sqrt {-\frac {5 \, \cos \left (x\right )^{2} - 1}{\cos \left (x\right )^{2}}} \cos \left (x\right ) \sin \left (x\right ) - \frac {3}{2} \, \cos \left (x\right )^{2} + \frac {1}{2}\right ) - \frac {1}{4} \, \log \left (-\frac {1}{2} \, \sqrt {-\frac {5 \, \cos \left (x\right )^{2} - 1}{\cos \left (x\right )^{2}}} \cos \left (x\right ) \sin \left (x\right ) - \frac {3}{2} \, \cos \left (x\right )^{2} + \frac {1}{2}\right ) \]

[In]

integrate(sec(x)^2/(-4+tan(x)^2)^(1/2),x, algorithm="fricas")

[Out]

1/4*log(1/2*sqrt(-(5*cos(x)^2 - 1)/cos(x)^2)*cos(x)*sin(x) - 3/2*cos(x)^2 + 1/2) - 1/4*log(-1/2*sqrt(-(5*cos(x
)^2 - 1)/cos(x)^2)*cos(x)*sin(x) - 3/2*cos(x)^2 + 1/2)

Sympy [F]

\[ \int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx=\int \frac {\sec ^{2}{\left (x \right )}}{\sqrt {\left (\tan {\left (x \right )} - 2\right ) \left (\tan {\left (x \right )} + 2\right )}}\, dx \]

[In]

integrate(sec(x)**2/(-4+tan(x)**2)**(1/2),x)

[Out]

Integral(sec(x)**2/sqrt((tan(x) - 2)*(tan(x) + 2)), x)

Maxima [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 16, normalized size of antiderivative = 1.14 \[ \int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx=\log \left (2 \, \sqrt {\tan \left (x\right )^{2} - 4} + 2 \, \tan \left (x\right )\right ) \]

[In]

integrate(sec(x)^2/(-4+tan(x)^2)^(1/2),x, algorithm="maxima")

[Out]

log(2*sqrt(tan(x)^2 - 4) + 2*tan(x))

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.21 \[ \int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx=-\log \left ({\left | \sqrt {\tan \left (x\right )^{2} - 4} - \tan \left (x\right ) \right |}\right ) \]

[In]

integrate(sec(x)^2/(-4+tan(x)^2)^(1/2),x, algorithm="giac")

[Out]

-log(abs(sqrt(tan(x)^2 - 4) - tan(x)))

Mupad [F(-1)]

Timed out. \[ \int \frac {\sec ^2(x)}{\sqrt {-4+\tan ^2(x)}} \, dx=\int \frac {1}{{\cos \left (x\right )}^2\,\sqrt {{\mathrm {tan}\left (x\right )}^2-4}} \,d x \]

[In]

int(1/(cos(x)^2*(tan(x)^2 - 4)^(1/2)),x)

[Out]

int(1/(cos(x)^2*(tan(x)^2 - 4)^(1/2)), x)