\(\int \frac {1}{1-\cos (x)+\sin (x)} \, dx\) [245]

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

Optimal result

Integrand size = 10, antiderivative size = 11 \[ \int \frac {1}{1-\cos (x)+\sin (x)} \, dx=-\log \left (1+\cot \left (\frac {x}{2}\right )\right ) \]

[Out]

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

Rubi [A] (verified)

Time = 0.01 (sec) , antiderivative size = 11, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {3200, 31} \[ \int \frac {1}{1-\cos (x)+\sin (x)} \, dx=-\log \left (\cot \left (\frac {x}{2}\right )+1\right ) \]

[In]

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

[Out]

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

Rule 31

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

Rule 3200

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]

Rubi steps \begin{align*} \text {integral}& = -\text {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] (verified)

Leaf count is larger than twice the leaf count of optimal. \(24\) vs. \(2(11)=22\).

Time = 0.03 (sec) , antiderivative size = 24, normalized size of antiderivative = 2.18 \[ \int \frac {1}{1-\cos (x)+\sin (x)} \, dx=\log \left (\sin \left (\frac {x}{2}\right )\right )-\log \left (\cos \left (\frac {x}{2}\right )+\sin \left (\frac {x}{2}\right )\right ) \]

[In]

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

[Out]

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

Maple [A] (verified)

Time = 0.23 (sec) , antiderivative size = 16, normalized size of antiderivative = 1.45

method result size
default \(\ln \left (\tan \left (\frac {x}{2}\right )\right )-\ln \left (1+\tan \left (\frac {x}{2}\right )\right )\) \(16\)
norman \(\ln \left (\tan \left (\frac {x}{2}\right )\right )-\ln \left (1+\tan \left (\frac {x}{2}\right )\right )\) \(16\)
parallelrisch \(\ln \left (\tan \left (\frac {x}{2}\right )\right )-\ln \left (1+\tan \left (\frac {x}{2}\right )\right )\) \(16\)
risch \(\ln \left ({\mathrm e}^{i x}-1\right )-\ln \left (i+{\mathrm e}^{i x}\right )\) \(21\)

[In]

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

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.55 \[ \int \frac {1}{1-\cos (x)+\sin (x)} \, dx=\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 ) \]

[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] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 14, normalized size of antiderivative = 1.27 \[ \int \frac {1}{1-\cos (x)+\sin (x)} \, dx=- \log {\left (\tan {\left (\frac {x}{2} \right )} + 1 \right )} + \log {\left (\tan {\left (\frac {x}{2} \right )} \right )} \]

[In]

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

[Out]

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

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 25 vs. \(2 (9) = 18\).

Time = 0.21 (sec) , antiderivative size = 25, normalized size of antiderivative = 2.27 \[ \int \frac {1}{1-\cos (x)+\sin (x)} \, dx=-\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 ) \]

[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))

Giac [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.55 \[ \int \frac {1}{1-\cos (x)+\sin (x)} \, dx=-\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 ) \]

[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)))

Mupad [B] (verification not implemented)

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

[In]

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

[Out]

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