AP Calculus BC

Integral of x^2 sin x: Answer, Proof, and Steps

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\int x^2\sin x\,dx = -x^2\cos x+2x\sin x+2\cos x + C

First pass of integration by parts

Use udv=uvvdu\int u\,dv = uv - \int v\,du and differentiate the polynomial, so let u=x2u = x^2 and dv=sinxdxdv = \sin x\,dx. Then v=cosxv = -\cos x.

u=x2,dv=sinxdxdu=2xdx,v=cosxu = x^2,\quad dv = \sin x\,dx \Rightarrow du = 2x\,dx,\quad v = -\cos x
x2sinxdx=x2cosx+2xcosxdx\int x^2 \sin x\,dx = -x^2 \cos x + \int 2x \cos x\,dx

The minus from v=cosxv = -\cos x and the minus in front of the integral combine into a +2xcosxdx+\int 2x\cos x\,dx.

Second pass and the result

Integrate 2xcosxdx\int 2x\cos x\,dx by parts with u=2xu = 2x and dv=cosxdxdv = \cos x\,dx, so v=sinxv = \sin x.

2xcosxdx=2xsinx2sinxdx=2xsinx+2cosx\int 2x \cos x\,dx = 2x\sin x - \int 2\sin x\,dx = 2x\sin x + 2\cos x

Combine both passes.

x2sinxdx=x2cosx+2xsinx+2cosx+C\int x^2 \sin x\,dx = -x^2\cos x + 2x\sin x + 2\cos x + C

Differentiating confirms it: the product rule on each term cancels the intermediate pieces and leaves x2sinxx^2\sin x.

The mistake students make

The usual error is a sign slip from v=cosxv = -\cos x. Because sinxdx=cosx\int \sin x\,dx = -\cos x, the first term is x2cosx-x^2\cos x and the next integral flips to +2xcosxdx+\int 2x\cos x\,dx. Writing v=cosxv = \cos x by reflex reverses several signs at once.

Sine and cosine swap with a sign

Each antiderivative here carries a sign: sinxdx=cosx\int\sin x\,dx = -\cos x and cosxdx=sinx\int\cos x\,dx = \sin x. 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=sinxdxdv = \sin x\,dx integrates to v=cosxv = -\cos x, so uv=x2(cosx)=x2cosxuv = x^2\cdot(-\cos x) = -x^2\cos x. 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=sinxv = \sin x instead of cosx-\cos x. The signs land differently, giving x2sinx+2xcosx2sinx+Cx^2\sin x + 2x\cos x - 2\sin x + C for the cosine version.

Can I use tabular integration?

Yes. List derivatives of x2x^2 against integrals of sinx\sin x and read across with alternating signs. It reproduces x2cosx+2xsinx+2cosx-x^2\cos x + 2x\sin x + 2\cos x quickly.