3.22 \(\int \frac {1}{(1+\cos (x)+\sin (x))^2} \, dx\)

Optimal. Leaf size=29 \[ -\log \left (\tan \left (\frac {x}{2}\right )+1\right )-\frac {\cos (x)-\sin (x)}{\sin (x)+\cos (x)+1} \]

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.02, antiderivative size = 29, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.375, Rules used = {3129, 3124, 31} \[ -\log \left (\tan \left (\frac {x}{2}\right )+1\right )-\frac {\cos (x)-\sin (x)}{\sin (x)+\cos (x)+1} \]

Antiderivative was successfully verified.

[In]

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

[Out]

-Log[1 + Tan[x/2]] - (Cos[x] - Sin[x])/(1 + Cos[x] + Sin[x])

Rule 31

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

Rule 3124

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

Rule 3129

Int[(cos[(d_.) + (e_.)*(x_)]*(b_.) + (a_) + (c_.)*sin[(d_.) + (e_.)*(x_)])^(n_), x_Symbol] :> Simp[((-(c*Cos[d
 + e*x]) + b*Sin[d + e*x])*(a + b*Cos[d + e*x] + c*Sin[d + e*x])^(n + 1))/(e*(n + 1)*(a^2 - b^2 - c^2)), x] +
Dist[1/((n + 1)*(a^2 - b^2 - c^2)), Int[(a*(n + 1) - b*(n + 2)*Cos[d + e*x] - c*(n + 2)*Sin[d + e*x])*(a + b*C
os[d + e*x] + c*Sin[d + e*x])^(n + 1), x], x] /; FreeQ[{a, b, c, d, e}, x] && NeQ[a^2 - b^2 - c^2, 0] && LtQ[n
, -1] && NeQ[n, -3/2]

Rubi steps

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

________________________________________________________________________________________

Mathematica [A]  time = 0.04, size = 56, normalized size = 1.93 \[ \frac {1}{2} \tan \left (\frac {x}{2}\right )+\log \left (\cos \left (\frac {x}{2}\right )\right )+\frac {\sin \left (\frac {x}{2}\right )}{\sin \left (\frac {x}{2}\right )+\cos \left (\frac {x}{2}\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])^(-2),x]

[Out]

Log[Cos[x/2]] - Log[Cos[x/2] + Sin[x/2]] + Sin[x/2]/(Cos[x/2] + Sin[x/2]) + Tan[x/2]/2

________________________________________________________________________________________

fricas [A]  time = 0.44, size = 46, normalized size = 1.59 \[ \frac {{\left (\cos \relax (x) + \sin \relax (x) + 1\right )} \log \left (\frac {1}{2} \, \cos \relax (x) + \frac {1}{2}\right ) - {\left (\cos \relax (x) + \sin \relax (x) + 1\right )} \log \left (\sin \relax (x) + 1\right ) - 2 \, \cos \relax (x) + 2 \, \sin \relax (x)}{2 \, {\left (\cos \relax (x) + \sin \relax (x) + 1\right )}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

giac [A]  time = 0.18, size = 30, normalized size = 1.03 \[ \frac {\tan \left (\frac {1}{2} \, x\right )}{\tan \left (\frac {1}{2} \, x\right ) + 1} - \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) + 1 \right |}\right ) + \frac {1}{2} \, \tan \left (\frac {1}{2} \, x\right ) \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

maple [A]  time = 0.08, size = 27, normalized size = 0.93 \[ -\ln \left (\tan \left (\frac {x}{2}\right )+1\right )+\frac {\tan \left (\frac {x}{2}\right )}{2}-\frac {1}{\tan \left (\frac {x}{2}\right )+1} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

maxima [A]  time = 0.43, size = 40, normalized size = 1.38 \[ \frac {\sin \relax (x)}{2 \, {\left (\cos \relax (x) + 1\right )}} - \frac {1}{\frac {\sin \relax (x)}{\cos \relax (x) + 1} + 1} - \log \left (\frac {\sin \relax (x)}{\cos \relax (x) + 1} + 1\right ) \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

mupad [B]  time = 0.28, size = 26, normalized size = 0.90 \[ \frac {\mathrm {tan}\left (\frac {x}{2}\right )}{2}-\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )+1\right )-\frac {1}{\mathrm {tan}\left (\frac {x}{2}\right )+1} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

sympy [B]  time = 0.69, size = 66, normalized size = 2.28 \[ - \frac {2 \log {\left (\tan {\left (\frac {x}{2} \right )} + 1 \right )} \tan {\left (\frac {x}{2} \right )}}{2 \tan {\left (\frac {x}{2} \right )} + 2} - \frac {2 \log {\left (\tan {\left (\frac {x}{2} \right )} + 1 \right )}}{2 \tan {\left (\frac {x}{2} \right )} + 2} + \frac {\tan ^{2}{\left (\frac {x}{2} \right )}}{2 \tan {\left (\frac {x}{2} \right )} + 2} - \frac {3}{2 \tan {\left (\frac {x}{2} \right )} + 2} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________