\(\int x^2 \sin (x) \, dx\) [23]

   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 = 6, antiderivative size = 17 \[ \int x^2 \sin (x) \, dx=2 \cos (x)-x^2 \cos (x)+2 x \sin (x) \]

[Out]

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

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3377, 2718} \[ \int x^2 \sin (x) \, dx=x^2 (-\cos (x))+2 x \sin (x)+2 \cos (x) \]

[In]

Int[x^2*Sin[x],x]

[Out]

2*Cos[x] - x^2*Cos[x] + 2*x*Sin[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]

Rubi steps \begin{align*} \text {integral}& = -x^2 \cos (x)+2 \int x \cos (x) \, dx \\ & = -x^2 \cos (x)+2 x \sin (x)-2 \int \sin (x) \, dx \\ & = 2 \cos (x)-x^2 \cos (x)+2 x \sin (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.01 (sec) , antiderivative size = 15, normalized size of antiderivative = 0.88 \[ \int x^2 \sin (x) \, dx=-\left (\left (-2+x^2\right ) \cos (x)\right )+2 x \sin (x) \]

[In]

Integrate[x^2*Sin[x],x]

[Out]

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

Maple [A] (verified)

Time = 0.04 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.00

method result size
risch \(\left (-x^{2}+2\right ) \cos \left (x \right )+2 x \sin \left (x \right )\) \(17\)
default \(2 \cos \left (x \right )-x^{2} \cos \left (x \right )+2 x \sin \left (x \right )\) \(18\)
parts \(2 \cos \left (x \right )-x^{2} \cos \left (x \right )+2 x \sin \left (x \right )\) \(18\)
parallelrisch \(-x^{2} \cos \left (x \right )+2 x \sin \left (x \right )+2 \cos \left (x \right )+2\) \(19\)
meijerg \(4 \sqrt {\pi }\, \left (-\frac {1}{2 \sqrt {\pi }}+\frac {\left (-\frac {x^{2}}{2}+1\right ) \cos \left (x \right )}{2 \sqrt {\pi }}+\frac {x \sin \left (x \right )}{2 \sqrt {\pi }}\right )\) \(34\)
norman \(\frac {x^{2} \left (\tan ^{2}\left (\frac {x}{2}\right )\right )-x^{2}+4 x \tan \left (\frac {x}{2}\right )+4}{1+\tan ^{2}\left (\frac {x}{2}\right )}\) \(36\)

[In]

int(x^2*sin(x),x,method=_RETURNVERBOSE)

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 15, normalized size of antiderivative = 0.88 \[ \int x^2 \sin (x) \, dx=-{\left (x^{2} - 2\right )} \cos \left (x\right ) + 2 \, x \sin \left (x\right ) \]

[In]

integrate(x^2*sin(x),x, algorithm="fricas")

[Out]

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

Sympy [A] (verification not implemented)

Time = 0.09 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.00 \[ \int x^2 \sin (x) \, dx=- x^{2} \cos {\left (x \right )} + 2 x \sin {\left (x \right )} + 2 \cos {\left (x \right )} \]

[In]

integrate(x**2*sin(x),x)

[Out]

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

Maxima [A] (verification not implemented)

none

Time = 0.18 (sec) , antiderivative size = 15, normalized size of antiderivative = 0.88 \[ \int x^2 \sin (x) \, dx=-{\left (x^{2} - 2\right )} \cos \left (x\right ) + 2 \, x \sin \left (x\right ) \]

[In]

integrate(x^2*sin(x),x, algorithm="maxima")

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 15, normalized size of antiderivative = 0.88 \[ \int x^2 \sin (x) \, dx=-{\left (x^{2} - 2\right )} \cos \left (x\right ) + 2 \, x \sin \left (x\right ) \]

[In]

integrate(x^2*sin(x),x, algorithm="giac")

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.02 (sec) , antiderivative size = 15, normalized size of antiderivative = 0.88 \[ \int x^2 \sin (x) \, dx=2\,x\,\sin \left (x\right )-\cos \left (x\right )\,\left (x^2-2\right ) \]

[In]

int(x^2*sin(x),x)

[Out]

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