The integral of x^2 sin(x) is -x^2 cos(x) + 2x sin(x) + 2 cos(x) + C. You get it by integration by parts applied twice, lowering the power of x each time until only sine and cosine terms remain.
∫x2sinxdx=−x2cosx+2xsinx+2cosx+C
First pass of integration by parts
Use ∫udv=uv−∫vdu and differentiate the polynomial, so let u=x2 and dv=sinxdx. Then v=−cosx.
u=x2,dv=sinxdx⇒du=2xdx,v=−cosx
∫x2sinxdx=−x2cosx+∫2xcosxdx
The minus from v=−cosx and the minus in front of the integral combine into a +∫2xcosxdx.
Second pass and the result
Integrate ∫2xcosxdx by parts with u=2x and dv=cosxdx, so v=sinx.
∫2xcosxdx=2xsinx−∫2sinxdx=2xsinx+2cosx
Combine both passes.
∫x2sinxdx=−x2cosx+2xsinx+2cosx+C
Differentiating confirms it: the product rule on each term cancels the intermediate pieces and leaves x2sinx.
The mistake students make
The usual error is a sign slip from v=−cosx. Because ∫sinxdx=−cosx, the first term is −x2cosx and the next integral flips to +∫2xcosxdx. Writing v=cosx by reflex reverses several signs at once.
Sine and cosine swap with a sign
Each antiderivative here carries a sign: ∫sinxdx=−cosx and ∫cosxdx=sinx. Keeping a short table beside the work prevents the cascade of sign errors.
Every answer on this page is machine checked
An automated test differentiates the antiderivative above and confirms it returns the integrand. A wrong sign or a missing factor fails the build, so it cannot reach you.
Frequently asked questions
Why is the first term negative?
Because dv=sinxdx integrates to v=−cosx, so uv=x2⋅(−cosx)=−x2cosx. The minus comes straight from the antiderivative of sine.
How does this compare to the integral of x^2 cos x?
Same two-pass method, but starting with v=sinx instead of −cosx. The signs land differently, giving x2sinx+2xcosx−2sinx+C for the cosine version.
Can I use tabular integration?
Yes. List derivatives of x2 against integrals of sinx and read across with alternating signs. It reproduces −x2cosx+2xsinx+2cosx quickly.