\(\int (-3+4 x+x^2) \sin (2 x) \, dx\) [811]

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

Optimal result

Integrand size = 13, antiderivative size = 40 \[ \int \left (-3+4 x+x^2\right ) \sin (2 x) \, dx=\frac {7}{4} \cos (2 x)-2 x \cos (2 x)-\frac {1}{2} x^2 \cos (2 x)+\sin (2 x)+\frac {1}{2} x \sin (2 x) \]

[Out]

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

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {6874, 2718, 3377, 2717} \[ \int \left (-3+4 x+x^2\right ) \sin (2 x) \, dx=-\frac {1}{2} x^2 \cos (2 x)+\frac {1}{2} x \sin (2 x)+\sin (2 x)-2 x \cos (2 x)+\frac {7}{4} \cos (2 x) \]

[In]

Int[(-3 + 4*x + x^2)*Sin[2*x],x]

[Out]

(7*Cos[2*x])/4 - 2*x*Cos[2*x] - (x^2*Cos[2*x])/2 + Sin[2*x] + (x*Sin[2*x])/2

Rule 2717

Int[sin[Pi/2 + (c_.) + (d_.)*(x_)], x_Symbol] :> Simp[Sin[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rule 2718

Int[sin[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Cos[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rule 3377

Int[((c_.) + (d_.)*(x_))^(m_.)*sin[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[(-(c + d*x)^m)*(Cos[e + f*x]/f), x]
+ Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Cos[e + f*x], x], x] /; FreeQ[{c, d, e, f}, x] && GtQ[m, 0]

Rule 6874

Int[u_, x_Symbol] :> With[{v = ExpandIntegrand[u, x]}, Int[v, x] /; SumQ[v]]

Rubi steps \begin{align*} \text {integral}& = \int \left (-3 \sin (2 x)+4 x \sin (2 x)+x^2 \sin (2 x)\right ) \, dx \\ & = -(3 \int \sin (2 x) \, dx)+4 \int x \sin (2 x) \, dx+\int x^2 \sin (2 x) \, dx \\ & = \frac {3}{2} \cos (2 x)-2 x \cos (2 x)-\frac {1}{2} x^2 \cos (2 x)+2 \int \cos (2 x) \, dx+\int x \cos (2 x) \, dx \\ & = \frac {3}{2} \cos (2 x)-2 x \cos (2 x)-\frac {1}{2} x^2 \cos (2 x)+\sin (2 x)+\frac {1}{2} x \sin (2 x)-\frac {1}{2} \int \sin (2 x) \, dx \\ & = \frac {7}{4} \cos (2 x)-2 x \cos (2 x)-\frac {1}{2} x^2 \cos (2 x)+\sin (2 x)+\frac {1}{2} x \sin (2 x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.09 (sec) , antiderivative size = 29, normalized size of antiderivative = 0.72 \[ \int \left (-3+4 x+x^2\right ) \sin (2 x) \, dx=\frac {1}{4} \left (\left (7-8 x-2 x^2\right ) \cos (2 x)+2 (2+x) \sin (2 x)\right ) \]

[In]

Integrate[(-3 + 4*x + x^2)*Sin[2*x],x]

[Out]

((7 - 8*x - 2*x^2)*Cos[2*x] + 2*(2 + x)*Sin[2*x])/4

Maple [A] (verified)

Time = 0.51 (sec) , antiderivative size = 26, normalized size of antiderivative = 0.65

method result size
risch \(\left (-\frac {1}{2} x^{2}-2 x +\frac {7}{4}\right ) \cos \left (2 x \right )+\frac {\left (2+x \right ) \sin \left (2 x \right )}{2}\) \(26\)
derivativedivides \(\frac {7 \cos \left (2 x \right )}{4}-2 x \cos \left (2 x \right )-\frac {x^{2} \cos \left (2 x \right )}{2}+\sin \left (2 x \right )+\frac {x \sin \left (2 x \right )}{2}\) \(35\)
default \(\frac {7 \cos \left (2 x \right )}{4}-2 x \cos \left (2 x \right )-\frac {x^{2} \cos \left (2 x \right )}{2}+\sin \left (2 x \right )+\frac {x \sin \left (2 x \right )}{2}\) \(35\)
parts \(\frac {7 \cos \left (2 x \right )}{4}-2 x \cos \left (2 x \right )-\frac {x^{2} \cos \left (2 x \right )}{2}+\sin \left (2 x \right )+\frac {x \sin \left (2 x \right )}{2}\) \(35\)
parallelrisch \(\frac {\left (x^{2}+4 x \right ) \tan \left (x \right )^{2}+\left (2 x +4\right ) \tan \left (x \right )-x^{2}-4 x +7}{2+2 \tan \left (x \right )^{2}}\) \(42\)
norman \(\frac {x \tan \left (x \right )-2 x -\frac {x^{2}}{2}+2 x \tan \left (x \right )^{2}+\frac {x^{2} \tan \left (x \right )^{2}}{2}+2 \tan \left (x \right )+\frac {7}{2}}{1+\tan \left (x \right )^{2}}\) \(44\)
meijerg \(\frac {\sqrt {\pi }\, \left (-\frac {1}{2 \sqrt {\pi }}+\frac {\left (-2 x^{2}+1\right ) \cos \left (2 x \right )}{2 \sqrt {\pi }}+\frac {x \sin \left (2 x \right )}{\sqrt {\pi }}\right )}{2}+2 \sqrt {\pi }\, \left (-\frac {x \cos \left (2 x \right )}{\sqrt {\pi }}+\frac {\sin \left (2 x \right )}{2 \sqrt {\pi }}\right )-\frac {3 \sqrt {\pi }\, \left (\frac {1}{\sqrt {\pi }}-\frac {\cos \left (2 x \right )}{\sqrt {\pi }}\right )}{2}\) \(81\)

[In]

int((x^2+4*x-3)*sin(2*x),x,method=_RETURNVERBOSE)

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 26, normalized size of antiderivative = 0.65 \[ \int \left (-3+4 x+x^2\right ) \sin (2 x) \, dx=-\frac {1}{4} \, {\left (2 \, x^{2} + 8 \, x - 7\right )} \cos \left (2 \, x\right ) + \frac {1}{2} \, {\left (x + 2\right )} \sin \left (2 \, x\right ) \]

[In]

integrate((x^2+4*x-3)*sin(2*x),x, algorithm="fricas")

[Out]

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

Sympy [A] (verification not implemented)

Time = 0.09 (sec) , antiderivative size = 39, normalized size of antiderivative = 0.98 \[ \int \left (-3+4 x+x^2\right ) \sin (2 x) \, dx=- \frac {x^{2} \cos {\left (2 x \right )}}{2} + \frac {x \sin {\left (2 x \right )}}{2} - 2 x \cos {\left (2 x \right )} + \sin {\left (2 x \right )} + \frac {7 \cos {\left (2 x \right )}}{4} \]

[In]

integrate((x**2+4*x-3)*sin(2*x),x)

[Out]

-x**2*cos(2*x)/2 + x*sin(2*x)/2 - 2*x*cos(2*x) + sin(2*x) + 7*cos(2*x)/4

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 38, normalized size of antiderivative = 0.95 \[ \int \left (-3+4 x+x^2\right ) \sin (2 x) \, dx=-\frac {1}{4} \, {\left (2 \, x^{2} - 1\right )} \cos \left (2 \, x\right ) - 2 \, x \cos \left (2 \, x\right ) + \frac {1}{2} \, x \sin \left (2 \, x\right ) + \frac {3}{2} \, \cos \left (2 \, x\right ) + \sin \left (2 \, x\right ) \]

[In]

integrate((x^2+4*x-3)*sin(2*x),x, algorithm="maxima")

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 26, normalized size of antiderivative = 0.65 \[ \int \left (-3+4 x+x^2\right ) \sin (2 x) \, dx=-\frac {1}{4} \, {\left (2 \, x^{2} + 8 \, x - 7\right )} \cos \left (2 \, x\right ) + \frac {1}{2} \, {\left (x + 2\right )} \sin \left (2 \, x\right ) \]

[In]

integrate((x^2+4*x-3)*sin(2*x),x, algorithm="giac")

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 34, normalized size of antiderivative = 0.85 \[ \int \left (-3+4 x+x^2\right ) \sin (2 x) \, dx=\frac {7\,\cos \left (2\,x\right )}{4}+\sin \left (2\,x\right )-2\,x\,\cos \left (2\,x\right )+\frac {x\,\sin \left (2\,x\right )}{2}-\frac {x^2\,\cos \left (2\,x\right )}{2} \]

[In]

int(sin(2*x)*(4*x + x^2 - 3),x)

[Out]

(7*cos(2*x))/4 + sin(2*x) - 2*x*cos(2*x) + (x*sin(2*x))/2 - (x^2*cos(2*x))/2