3.837 \(\int (-1+2 \cos ^2(x)+\cos (x) \sin (x)) \, dx\)

Optimal. Leaf size=14 \[ \frac{\sin ^2(x)}{2}+\sin (x) \cos (x) \]

[Out]

Cos[x]*Sin[x] + Sin[x]^2/2

________________________________________________________________________________________

Rubi [A]  time = 0.0166557, antiderivative size = 14, normalized size of antiderivative = 1., number of steps used = 5, number of rules used = 4, integrand size = 13, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.308, Rules used = {2635, 8, 2564, 30} \[ \frac{\sin ^2(x)}{2}+\sin (x) \cos (x) \]

Antiderivative was successfully verified.

[In]

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

[Out]

Cos[x]*Sin[x] + Sin[x]^2/2

Rule 2635

Int[((b_.)*sin[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> -Simp[(b*Cos[c + d*x]*(b*Sin[c + d*x])^(n - 1))/(d*n),
x] + Dist[(b^2*(n - 1))/n, Int[(b*Sin[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1] && Integer
Q[2*n]

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 2564

Int[cos[(e_.) + (f_.)*(x_)]^(n_.)*((a_.)*sin[(e_.) + (f_.)*(x_)])^(m_.), x_Symbol] :> Dist[1/(a*f), Subst[Int[
x^m*(1 - x^2/a^2)^((n - 1)/2), x], x, a*Sin[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2] &&
 !(IntegerQ[(m - 1)/2] && LtQ[0, m, n])

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rubi steps

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

Mathematica [A]  time = 0.0053653, size = 17, normalized size = 1.21 \[ \frac{1}{2} \sin (2 x)-\frac{\cos ^2(x)}{2} \]

Antiderivative was successfully verified.

[In]

Integrate[-1 + 2*Cos[x]^2 + Cos[x]*Sin[x],x]

[Out]

-Cos[x]^2/2 + Sin[2*x]/2

________________________________________________________________________________________

Maple [A]  time = 0.005, size = 13, normalized size = 0.9 \begin{align*} \cos \left ( x \right ) \sin \left ( x \right ) +{\frac{ \left ( \sin \left ( x \right ) \right ) ^{2}}{2}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(-1+2*cos(x)^2+cos(x)*sin(x),x)

[Out]

cos(x)*sin(x)+1/2*sin(x)^2

________________________________________________________________________________________

Maxima [A]  time = 0.949812, size = 18, normalized size = 1.29 \begin{align*} -\frac{1}{2} \, \cos \left (x\right )^{2} + \frac{1}{2} \, \sin \left (2 \, x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Fricas [A]  time = 1.99195, size = 42, normalized size = 3. \begin{align*} -\frac{1}{2} \, \cos \left (x\right )^{2} + \cos \left (x\right ) \sin \left (x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [A]  time = 0.061004, size = 12, normalized size = 0.86 \begin{align*} \frac{\sin ^{2}{\left (x \right )}}{2} + \sin{\left (x \right )} \cos{\left (x \right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Giac [A]  time = 1.08018, size = 18, normalized size = 1.29 \begin{align*} -\frac{1}{2} \, \cos \left (x\right )^{2} + \frac{1}{2} \, \sin \left (2 \, x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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