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.

∫x2cos⁡x dx=x2sin⁡x+2xcos⁡x−2sin⁡x+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 ∫u dv=uv−∫v du\int u\,dv = uv - \int v\,du, differentiate the polynomial: let u=x2u = x^2 and dv=cos⁡x dxdv = \cos x\,dx, so v=sin⁡xv = \sin x.

u=x2,dv=cos⁡x dx⇒du=2x dx,v=sin⁡xu = x^2,\quad dv = \cos x\,dx \Rightarrow du = 2x\,dx,\quad v = \sin x
∫x2cos⁡x dx=x2sin⁡x−∫2xsin⁡x dx\int x^2 \cos x\,dx = x^2 \sin x - \int 2x \sin x\,dx

Second pass and the result

Integrate ∫2xsin⁡x dx\int 2x\sin x\,dx by parts with u=2xu = 2x and dv=sin⁡x dxdv = \sin x\,dx, so v=−cos⁡xv = -\cos x.

∫2xsin⁡x dx=−2xcos⁡x+∫2cos⁡x dx=−2xcos⁡x+2sin⁡x\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.

∫x2cos⁡x dx=x2sin⁡x−(−2xcos⁡x+2sin⁡x)=x2sin⁡x+2xcos⁡x−2sin⁡x+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 −2xcos⁡x+2sin⁡x-2x\cos x + 2\sin x, and subtracting the whole thing flips both terms to +2xcos⁡x−2sin⁡x+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 uv−∫v duuv - \int v\,du. When ∫v du\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 cos⁡x\cos x integrates to sin⁡x\sin x with no sign flip on the first pass, the signs propagate differently. The companion integral ∫x2sin⁡x dx\int x^2\sin x\,dx ends with +2cos⁡x+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 sin⁡x\sin x or cos⁡x\cos x integrates directly.

Is tabular integration reliable here?

Yes. The DI table pairs derivatives of x2x^2 with integrals of cos⁡x\cos x and alternates signs, giving x2sin⁡x+2xcos⁡x−2sin⁡xx^2\sin x + 2x\cos x - 2\sin x without tracking brackets by hand.