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

Optimal. Leaf size=8 \[ -x-2 \cot (x) \]

[Out]

-x-2*cot(x)

________________________________________________________________________________________

Rubi [A]
time = 0.03, antiderivative size = 8, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 17, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.235, Rules used = {3250, 3254, 3852, 8} \begin {gather*} -x-2 \cot (x) \end {gather*}

Antiderivative was successfully verified.

[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*} \int \frac {1+\cos ^2(x)}{1-\cos ^2(x)} \, dx &=-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 [A]
time = 0.01, size = 8, normalized size = 1.00 \begin {gather*} -x-2 \cot (x) \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

-x - 2*Cot[x]

________________________________________________________________________________________

Maple [A]
time = 0.04, size = 13, normalized size = 1.62

method result size
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 )-2 x \left (\tan ^{3}\left (\frac {x}{2}\right )\right )-x \left (\tan ^{5}\left (\frac {x}{2}\right )\right )}{\left (1+\tan ^{2}\left (\frac {x}{2}\right )\right )^{2} \tan \left (\frac {x}{2}\right )}\) \(65\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-2/tan(x)-arctan(tan(x))

________________________________________________________________________________________

Maxima [A]
time = 1.65, size = 10, normalized size = 1.25 \begin {gather*} -x - \frac {2}{\tan \left (x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-x - 2/tan(x)

________________________________________________________________________________________

Fricas [A]
time = 0.77, size = 15, normalized size = 1.88 \begin {gather*} -\frac {x \sin \left (x\right ) + 2 \, \cos \left (x\right )}{\sin \left (x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [A]
time = 0.38, size = 12, normalized size = 1.50 \begin {gather*} - x + \tan {\left (\frac {x}{2} \right )} - \frac {1}{\tan {\left (\frac {x}{2} \right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Giac [A]
time = 1.10, size = 16, normalized size = 2.00 \begin {gather*} -x - \frac {1}{\tan \left (\frac {1}{2} \, x\right )} + \tan \left (\frac {1}{2} \, x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[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]
time = 0.21, size = 8, normalized size = 1.00 \begin {gather*} -x-2\,\mathrm {cot}\left (x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

- x - 2*cot(x)

________________________________________________________________________________________