\(\int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx\) [201]

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

Optimal result

Integrand size = 17, antiderivative size = 8 \[ \int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx=-x+2 \tan (x) \]

[Out]

-x+2*tan(x)

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 8, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.235, Rules used = {3250, 3254, 3852, 8} \[ \int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx=2 \tan (x)-x \]

[In]

Int[(1 + Sin[x]^2)/(1 - Sin[x]^2),x]

[Out]

-x + 2*Tan[x]

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3250

Int[((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)]^2)/((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[B*(x
/b), x] + Dist[(A*b - a*B)/b, Int[1/(a + b*Sin[e + f*x]^2), x], x] /; FreeQ[{a, b, e, f, A, B}, x]

Rule 3254

Int[(u_.)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2)^(p_), x_Symbol] :> Dist[a^p, Int[ActivateTrig[u*cos[e + f*x
]^(2*p)], x], x] /; FreeQ[{a, b, e, f, p}, x] && EqQ[a + b, 0] && IntegerQ[p]

Rule 3852

Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> Dist[-d^(-1), Subst[Int[ExpandIntegrand[(1 + x^2)^(n/2 - 1), x]
, x], x, Cot[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[n/2, 0]

Rubi steps \begin{align*} \text {integral}& = -x+2 \int \frac {1}{1-\sin ^2(x)} \, dx \\ & = -x+2 \int \sec ^2(x) \, dx \\ & = -x-2 \text {Subst}(\int 1 \, dx,x,-\tan (x)) \\ & = -x+2 \tan (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.01 (sec) , antiderivative size = 10, normalized size of antiderivative = 1.25 \[ \int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx=-\arctan (\tan (x))+2 \tan (x) \]

[In]

Integrate[(1 + Sin[x]^2)/(1 - Sin[x]^2),x]

[Out]

-ArcTan[Tan[x]] + 2*Tan[x]

Maple [A] (verified)

Time = 0.29 (sec) , antiderivative size = 9, normalized size of antiderivative = 1.12

method result size
parallelrisch \(-x +2 \tan \left (x \right )\) \(9\)
default \(2 \tan \left (x \right )-\arctan \left (\tan \left (x \right )\right )\) \(11\)
risch \(-x +\frac {4 i}{{\mathrm e}^{2 i x}+1}\) \(17\)
norman \(\frac {x +x \tan \left (\frac {x}{2}\right )^{2}-8 \tan \left (\frac {x}{2}\right )^{3}-4 \tan \left (\frac {x}{2}\right )^{5}-x \tan \left (\frac {x}{2}\right )^{4}-x \tan \left (\frac {x}{2}\right )^{6}-4 \tan \left (\frac {x}{2}\right )}{\left (1+\tan \left (\frac {x}{2}\right )^{2}\right )^{2} \left (\tan \left (\frac {x}{2}\right )^{2}-1\right )}\) \(72\)

[In]

int((sin(x)^2+1)/(1-sin(x)^2),x,method=_RETURNVERBOSE)

[Out]

-x+2*tan(x)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.88 \[ \int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx=-\frac {x \cos \left (x\right ) - 2 \, \sin \left (x\right )}{\cos \left (x\right )} \]

[In]

integrate((1+sin(x)^2)/(1-sin(x)^2),x, algorithm="fricas")

[Out]

-(x*cos(x) - 2*sin(x))/cos(x)

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 41 vs. \(2 (5) = 10\).

Time = 0.44 (sec) , antiderivative size = 41, normalized size of antiderivative = 5.12 \[ \int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx=- \frac {x \tan ^{2}{\left (\frac {x}{2} \right )}}{\tan ^{2}{\left (\frac {x}{2} \right )} - 1} + \frac {x}{\tan ^{2}{\left (\frac {x}{2} \right )} - 1} - \frac {4 \tan {\left (\frac {x}{2} \right )}}{\tan ^{2}{\left (\frac {x}{2} \right )} - 1} \]

[In]

integrate((1+sin(x)**2)/(1-sin(x)**2),x)

[Out]

-x*tan(x/2)**2/(tan(x/2)**2 - 1) + x/(tan(x/2)**2 - 1) - 4*tan(x/2)/(tan(x/2)**2 - 1)

Maxima [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 8, normalized size of antiderivative = 1.00 \[ \int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx=-x + 2 \, \tan \left (x\right ) \]

[In]

integrate((1+sin(x)^2)/(1-sin(x)^2),x, algorithm="maxima")

[Out]

-x + 2*tan(x)

Giac [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 8, normalized size of antiderivative = 1.00 \[ \int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx=-x + 2 \, \tan \left (x\right ) \]

[In]

integrate((1+sin(x)^2)/(1-sin(x)^2),x, algorithm="giac")

[Out]

-x + 2*tan(x)

Mupad [B] (verification not implemented)

Time = 27.28 (sec) , antiderivative size = 8, normalized size of antiderivative = 1.00 \[ \int \frac {1+\sin ^2(x)}{1-\sin ^2(x)} \, dx=2\,\mathrm {tan}\left (x\right )-x \]

[In]

int(-(sin(x)^2 + 1)/(sin(x)^2 - 1),x)

[Out]

2*tan(x) - x