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)+1/2*sin(x)^2

________________________________________________________________________________________

Rubi [A]  time = 0.02, antiderivative size = 14, normalized size of antiderivative = 1.00, 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 8

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

Rule 30

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

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 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]

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.01, 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]

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

________________________________________________________________________________________

fricas [A]  time = 0.71, size = 12, normalized size = 0.86 \[ -\frac {1}{2} \, \cos \relax (x)^{2} + \cos \relax (x) \sin \relax (x) \]

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)

________________________________________________________________________________________

giac [A]  time = 0.14, size = 13, normalized size = 0.93 \[ -\frac {1}{2} \, \cos \relax (x)^{2} + \frac {1}{2} \, \sin \left (2 \, x\right ) \]

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)

________________________________________________________________________________________

maple [A]  time = 0.02, size = 13, normalized size = 0.93 \[ \cos \relax (x ) \sin \relax (x )+\frac {\left (\sin ^{2}\relax (x )\right )}{2} \]

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.32, size = 13, normalized size = 0.93 \[ -\frac {1}{2} \, \cos \relax (x)^{2} + \frac {1}{2} \, \sin \left (2 \, x\right ) \]

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)

________________________________________________________________________________________

mupad [B]  time = 2.97, size = 11, normalized size = 0.79 \[ -\frac {\cos \relax (x)\,\left (\cos \relax (x)-2\,\sin \relax (x)\right )}{2} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

sympy [A]  time = 0.05, size = 12, normalized size = 0.86 \[ \frac {\sin ^{2}{\relax (x )}}{2} + \sin {\relax (x )} \cos {\relax (x )} \]

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)

________________________________________________________________________________________