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

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (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+\cos ^2(x)}{1-\cos ^2(x)} \, dx=-x-2 \cot (x) \]

[Out]

-x-2*cot(x)

Rubi [A] (verified)

Time = 0.03 (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+\cos ^2(x)}{1-\cos ^2(x)} \, dx=-x-2 \cot (x) \]

[In]

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

[Out]

-x - 2*Cot[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-\cos ^2(x)} \, dx \\ & = -x+2 \int \csc ^2(x) \, dx \\ & = -x-2 \text {Subst}(\int 1 \, dx,x,\cot (x)) \\ & = -x-2 \cot (x) \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.01 (sec) , antiderivative size = 23, normalized size of antiderivative = 2.88 \[ \int \frac {1+\cos ^2(x)}{1-\cos ^2(x)} \, dx=-\cot (x)-\cot (x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(x)\right ) \]

[In]

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

[Out]

-Cot[x] - Cot[x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[x]^2]

Maple [A] (verified)

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

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

[In]

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

[Out]

-x-2*cot(x)

Fricas [A] (verification not implemented)

none

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

[In]

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

[Out]

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

Sympy [A] (verification not implemented)

Time = 0.35 (sec) , antiderivative size = 12, normalized size of antiderivative = 1.50 \[ \int \frac {1+\cos ^2(x)}{1-\cos ^2(x)} \, dx=- x + \tan {\left (\frac {x}{2} \right )} - \frac {1}{\tan {\left (\frac {x}{2} \right )}} \]

[In]

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

[Out]

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

Maxima [A] (verification not implemented)

none

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

[In]

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

[Out]

-x - 2/tan(x)

Giac [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 16, normalized size of antiderivative = 2.00 \[ \int \frac {1+\cos ^2(x)}{1-\cos ^2(x)} \, dx=-x - \frac {1}{\tan \left (\frac {1}{2} \, x\right )} + \tan \left (\frac {1}{2} \, x\right ) \]

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

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

[In]

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

[Out]

- x - 2*cot(x)