AP Calculus BC

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

The integral of x^2 cos(x) is x^2 sin(x) + 2x cos(x) - 2 sin(x) + C. You get it by integration by parts applied twice, lowering the power of x each pass until only sine and cosine terms remain.

x2cosxdx=x2sinx+2xcosx2sinx+C\int x^2\cos x\,dx = x^2\sin x+2x\cos x-2\sin x + C

First pass of integration by parts

With udv=uvvdu\int u\,dv = uv - \int v\,du, differentiate the polynomial: let u=x2u = x^2 and dv=cosxdxdv = \cos x\,dx, so v=sinxv = \sin x.

u=x2,dv=cosxdxdu=2xdx,v=sinxu = x^2,\quad dv = \cos x\,dx \Rightarrow du = 2x\,dx,\quad v = \sin x
x2cosxdx=x2sinx2xsinxdx\int x^2 \cos x\,dx = x^2 \sin x - \int 2x \sin x\,dx

Second pass and the result

Integrate 2xsinxdx\int 2x\sin x\,dx by parts with u=2xu = 2x and dv=sinxdxdv = \sin x\,dx, so v=cosxv = -\cos x.

2xsinxdx=2xcosx+2cosxdx=2xcosx+2sinx\int 2x \sin x\,dx = -2x\cos x + \int 2\cos x\,dx = -2x\cos x + 2\sin x

Subtract this whole result from the first pass, distributing the minus sign across both terms.

x2cosxdx=x2sinx(2xcosx+2sinx)=x2sinx+2xcosx2sinx+C\int x^2 \cos x\,dx = x^2\sin x - (-2x\cos x + 2\sin x) = x^2\sin x + 2x\cos x - 2\sin x + C

The mistake students make

Distributing the outer minus sign is where answers go wrong. The second pass produces 2xcosx+2sinx-2x\cos x + 2\sin x, and subtracting the whole thing flips both terms to +2xcosx2sinx+2x\cos x - 2\sin x. Dropping the parentheses and subtracting only the first term is the classic slip.

Subtract the whole bracket

Integration by parts leaves uvvduuv - \int v\,du. When vdu\int v\,du is itself a two-term result, the minus applies to every term inside, not just the first.

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 does the answer end with -2 sin x, unlike the sine version?

Because cosx\cos x integrates to sinx\sin x with no sign flip on the first pass, the signs propagate differently. The companion integral x2sinxdx\int x^2\sin x\,dx ends with +2cosx+2\cos x instead.

Do I ever need a third pass?

Not for x2x^2. Two passes drop the power from x2x^2 to 2x2x to a constant coefficient, and a constant multiple of sinx\sin x or cosx\cos x integrates directly.

Is tabular integration reliable here?

Yes. The DI table pairs derivatives of x2x^2 with integrals of cosx\cos x and alternates signs, giving x2sinx+2xcosx2sinxx^2\sin x + 2x\cos x - 2\sin x without tracking brackets by hand.