3.245 \(\int \frac{1}{1-\cos (x)+\sin (x)} \, dx\)

Optimal. Leaf size=11 \[ -\log \left (\cot \left (\frac{x}{2}\right )+1\right ) \]

[Out]

-Log[1 + Cot[x/2]]

________________________________________________________________________________________

Rubi [A]  time = 0.0107476, antiderivative size = 11, normalized size of antiderivative = 1., number of steps used = 2, number of rules used = 2, integrand size = 10, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.2, Rules used = {3121, 31} \[ -\log \left (\cot \left (\frac{x}{2}\right )+1\right ) \]

Antiderivative was successfully verified.

[In]

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

[Out]

-Log[1 + Cot[x/2]]

Rule 3121

Int[(cos[(d_.) + (e_.)*(x_)]*(b_.) + (a_) + (c_.)*sin[(d_.) + (e_.)*(x_)])^(-1), x_Symbol] :> Module[{f = Free
Factors[Cot[(d + e*x)/2], x]}, -Dist[f/e, Subst[Int[1/(a + c*f*x), x], x, Cot[(d + e*x)/2]/f], x]] /; FreeQ[{a
, b, c, d, e}, x] && EqQ[a + b, 0]

Rule 31

Int[((a_) + (b_.)*(x_))^(-1), x_Symbol] :> Simp[Log[RemoveContent[a + b*x, x]]/b, x] /; FreeQ[{a, b}, x]

Rubi steps

\begin{align*} \int \frac{1}{1-\cos (x)+\sin (x)} \, dx &=-\operatorname{Subst}\left (\int \frac{1}{1+x} \, dx,x,\cot \left (\frac{x}{2}\right )\right )\\ &=-\log \left (1+\cot \left (\frac{x}{2}\right )\right )\\ \end{align*}

Mathematica [B]  time = 0.0143862, size = 24, normalized size = 2.18 \[ \log \left (\sin \left (\frac{x}{2}\right )\right )-\log \left (\sin \left (\frac{x}{2}\right )+\cos \left (\frac{x}{2}\right )\right ) \]

Antiderivative was successfully verified.

[In]

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

[Out]

Log[Sin[x/2]] - Log[Cos[x/2] + Sin[x/2]]

________________________________________________________________________________________

Maple [A]  time = 0.027, size = 16, normalized size = 1.5 \begin{align*} \ln \left ( \tan \left ({\frac{x}{2}} \right ) \right ) -\ln \left ( 1+\tan \left ({\frac{x}{2}} \right ) \right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(1/(1-cos(x)+sin(x)),x)

[Out]

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

________________________________________________________________________________________

Maxima [B]  time = 0.9437, size = 34, normalized size = 3.09 \begin{align*} -\log \left (\frac{\sin \left (x\right )}{\cos \left (x\right ) + 1} + 1\right ) + \log \left (\frac{\sin \left (x\right )}{\cos \left (x\right ) + 1}\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-log(sin(x)/(cos(x) + 1) + 1) + log(sin(x)/(cos(x) + 1))

________________________________________________________________________________________

Fricas [A]  time = 2.25173, size = 68, normalized size = 6.18 \begin{align*} \frac{1}{2} \, \log \left (-\frac{1}{2} \, \cos \left (x\right ) + \frac{1}{2}\right ) - \frac{1}{2} \, \log \left (\sin \left (x\right ) + 1\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [A]  time = 0.237113, size = 14, normalized size = 1.27 \begin{align*} - \log{\left (\tan{\left (\frac{x}{2} \right )} + 1 \right )} + \log{\left (\tan{\left (\frac{x}{2} \right )} \right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(1-cos(x)+sin(x)),x)

[Out]

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

________________________________________________________________________________________

Giac [A]  time = 1.09904, size = 23, normalized size = 2.09 \begin{align*} -\log \left ({\left | \tan \left (\frac{1}{2} \, x\right ) + 1 \right |}\right ) + \log \left ({\left | \tan \left (\frac{1}{2} \, x\right ) \right |}\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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