### 3.9 $$\int \frac{\sin (x)}{-2+\cos (x)+\cos ^2(x)} \, dx$$

Optimal. Leaf size=21 $\frac{1}{3} \log (\cos (x)+2)-\frac{1}{3} \log (1-\cos (x))$

[Out]

-Log[1 - Cos[x]]/3 + Log[2 + Cos[x]]/3

________________________________________________________________________________________

Rubi [A]  time = 0.0244769, antiderivative size = 21, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 3, integrand size = 13, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.231, Rules used = {3259, 616, 31} $\frac{1}{3} \log (\cos (x)+2)-\frac{1}{3} \log (1-\cos (x))$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

-Log[1 - Cos[x]]/3 + Log[2 + Cos[x]]/3

Rule 3259

Int[((a_.) + (b_.)*(cos[(d_.) + (e_.)*(x_)]*(f_.))^(n_.) + (c_.)*(cos[(d_.) + (e_.)*(x_)]*(f_.))^(n2_.))^(p_.)
*sin[(d_.) + (e_.)*(x_)]^(m_.), x_Symbol] :> Module[{g = FreeFactors[Cos[d + e*x], x]}, -Dist[g/e, Subst[Int[(
1 - g^2*x^2)^((m - 1)/2)*(a + b*(f*g*x)^n + c*(f*g*x)^(2*n))^p, x], x, Cos[d + e*x]/g], x]] /; FreeQ[{a, b, c,
d, e, f, n, p}, x] && EqQ[n2, 2*n] && IntegerQ[(m - 1)/2]

Rule 616

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> With[{q = Rt[b^2 - 4*a*c, 2]}, Dist[c/q, Int[1/Simp
[b/2 - q/2 + c*x, x], x], x] - Dist[c/q, Int[1/Simp[b/2 + q/2 + c*x, x], x], x]] /; FreeQ[{a, b, c}, x] && NeQ
[b^2 - 4*a*c, 0] && PosQ[b^2 - 4*a*c] && PerfectSquareQ[b^2 - 4*a*c]

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{\sin (x)}{-2+\cos (x)+\cos ^2(x)} \, dx &=-\operatorname{Subst}\left (\int \frac{1}{-2+x+x^2} \, dx,x,\cos (x)\right )\\ &=-\left (\frac{1}{3} \operatorname{Subst}\left (\int \frac{1}{-1+x} \, dx,x,\cos (x)\right )\right )+\frac{1}{3} \operatorname{Subst}\left (\int \frac{1}{2+x} \, dx,x,\cos (x)\right )\\ &=-\frac{1}{3} \log (1-\cos (x))+\frac{1}{3} \log (2+\cos (x))\\ \end{align*}

Mathematica [A]  time = 0.0251045, size = 19, normalized size = 0.9 $\frac{1}{3} \left (\log (\cos (x)+2)-2 \log \left (\sin \left (\frac{x}{2}\right )\right )\right )$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

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

________________________________________________________________________________________

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

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

1/3*ln(2+cos(x))-1/3*ln(cos(x)-1)

________________________________________________________________________________________

Maxima [A]  time = 0.948131, size = 20, normalized size = 0.95 \begin{align*} \frac{1}{3} \, \log \left (\cos \left (x\right ) + 2\right ) - \frac{1}{3} \, \log \left (\cos \left (x\right ) - 1\right ) \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

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

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [A]  time = 0.242954, size = 15, normalized size = 0.71 \begin{align*} - \frac{\log{\left (\cos{\left (x \right )} - 1 \right )}}{3} + \frac{\log{\left (\cos{\left (x \right )} + 2 \right )}}{3} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-log(cos(x) - 1)/3 + log(cos(x) + 2)/3

________________________________________________________________________________________

Giac [A]  time = 1.78329, size = 23, normalized size = 1.1 \begin{align*} \frac{1}{3} \, \log \left (\cos \left (x\right ) + 2\right ) - \frac{1}{3} \, \log \left (-\cos \left (x\right ) + 1\right ) \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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