AP Calculus BC

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

The integral of x^2 e^x is e^x(x^2 - 2x + 2) + C. You get it by integration by parts done twice: each pass lowers the power of x by one, from x^2 to 2x to a constant, until the exponential integrates on its own.

x2exdx=ex(x22x+2)+C\int x^2 e^x\,dx = e^x(x^2-2x+2) + C

First pass of integration by parts

Integration by parts, udv=uvvdu\int u\,dv = uv - \int v\,du, trades a hard integral for an easier one. Differentiating the polynomial is what makes progress, so let u=x2u = x^2 and dv=exdxdv = e^x\,dx.

u=x2,dv=exdxdu=2xdx,v=exu = x^2,\quad dv = e^x\,dx \Rightarrow du = 2x\,dx,\quad v = e^x

That leaves a new integral with xx only to the first power.

x2exdx=x2ex2xexdx\int x^2 e^x\,dx = x^2 e^x - \int 2x e^x\,dx

Second pass and the result

Apply parts again to 2xexdx\int 2x e^x\,dx with u=2xu = 2x and dv=exdxdv = e^x\,dx, so du=2dxdu = 2\,dx and v=exv = e^x.

2xexdx=2xex2exdx=2xex2ex\int 2x e^x\,dx = 2x e^x - \int 2e^x\,dx = 2x e^x - 2e^x

Substitute back and factor out exe^x.

x2exdx=x2ex(2xex2ex)=ex(x22x+2)+C\int x^2 e^x\,dx = x^2 e^x - (2x e^x - 2e^x) = e^x(x^2 - 2x + 2) + C

Differentiating ex(x22x+2)e^x(x^2-2x+2) by the product rule returns ex(x22x+2)+ex(2x2)=x2exe^x(x^2-2x+2) + e^x(2x-2) = x^2 e^x, confirming the answer.

The mistake students make

The frequent slip is a sign error on the second pass, dropping the minus in front of 2xexdx\int 2x e^x\,dx and writing x2ex+2xex2exx^2 e^x + 2x e^x - 2e^x. Track the leading minus carefully, since both terms inside the parentheses change sign when the bracket is expanded.

Alternating signs, one power at a time

For xnexx^n e^x, parts applied nn times gives exe^x times a polynomial whose signs alternate, here x22x+2x^2 - 2x + 2. A tabular (DI) layout keeps those alternating signs organized.

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 choose u = x^2 and not dv = x^2 dx?

Because differentiating x2x^2 drives its power down toward a constant, which ends the process, while exe^x integrates to itself and never gets worse. Letting dv=x2dxdv = x^2\,dx would raise the power and make the integral harder.

How many times do I apply integration by parts?

Twice, matching the exponent on xx. Each pass lowers x22xx^2 \to 2x \to constant. In general xnexdx\int x^n e^x\,dx needs nn applications.

Is there a faster way than writing out both passes?

Yes, tabular integration (the DI method) lists derivatives of x2x^2 beside integrals of exe^x and reads off the answer with alternating signs. It gives the same ex(x22x+2)e^x(x^2 - 2x + 2) with less writing.