Calculus · real student question

Find the indefinite integral of x^2 times e^x with respect to x.

Question

Find the indefinite integral

x2exdx\int x^2e^x\,dx

Step-by-step solution

  1. Recognise the product type and pick uu so the polynomial shrinks. The integrand is a polynomial times an exponential, the classic signal for integration by parts:

    udv=uvvdu\int u\,dv=uv-\int v\,du

    Choose u=x2u=x^2 and dv=exdxdv=e^x\,dx. The reason is that differentiating x2x^2 lowers its degree, while exe^x is unchanged by integration — so each application of the formula moves us strictly closer to an integral we can do. Choosing the other way round (u=exu=e^x) would raise the power to x3x^3 and make the problem worse.

  2. First application of the formula. With u=x2u=x^2 and dv=exdxdv=e^x\,dx we get du=2xdxdu=2x\,dx and v=exv=e^x, so

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

    The remaining integral has the same shape but with xx instead of x2x^2: the degree has dropped by one exactly as planned.

  3. Second application, on xexdx\int xe^x\,dx. Take u=xu=x, dv=exdxdv=e^x\,dx, so du=dxdu=dx and v=exv=e^x:

    xexdx=xexexdx=xexex\int xe^x\,dx=xe^x-\int e^x\,dx=xe^x-e^x

    In general xnexdx\int x^n e^x\,dx needs nn passes, because the degree falls by one each time. Here n=2n=2, hence exactly two passes.

  4. Substitute back and simplify. Feeding the second result into the first:

    x2exdx=x2ex2(xexex)=x2ex2xex+2ex\int x^2e^x\,dx=x^2e^x-2\big(xe^x-e^x\big)=x^2e^x-2xe^x+2e^x

    Factoring out the common exe^x gives the tidy form

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

    Do not forget the constant CC: it is only added once, at the very end, not after each pass.

  5. Verify by differentiating the answer. This is the one check that is always available for an indefinite integral. By the product rule,

    ddx[ex(x22x+2)]=ex(x22x+2)+ex(2x2)=ex(x22x+2+2x2)=x2ex\frac{d}{dx}\Big[e^x\big(x^2-2x+2\big)\Big]=e^x\big(x^2-2x+2\big)+e^x\big(2x-2\big)=e^x\big(x^2-2x+2+2x-2\big)=x^2e^x

    The two linear pieces cancel and we recover the original integrand exactly, so the antiderivative is correct.

  6. Note the pattern for reuse. The alternating-sign structure generalises:

    xnexdx=ex(xnnxn1+n(n1)xn2±n!)+C\int x^ne^x\,dx=e^x\left(x^n-nx^{n-1}+n(n-1)x^{n-2}-\cdots\pm n!\right)+C

    For n=2n=2 this reads ex(x22x+2)+Ce^x(x^2-2x+2)+C, matching what we derived. Recognising this lets you write down x3exdx=ex(x33x2+6x6)+C\int x^3e^x\,dx=e^x(x^3-3x^2+6x-6)+C without repeating the work three times.

Answer

ex(x22x+2)+Ce^x\left(x^2-2x+2\right)+C

Need to solve a different problem like this? Open the solver →