Calculus · real student question

Find the indefinite integral of x^2 * e^(-x^2) with respect to x.

Question

Find

x2ex2dx.\int x^{2}e^{-x^{2}}\,dx.

Step-by-step solution

  1. Split x2x^{2} so that one xx joins the exponential. The factor xex2xe^{-x^{2}} has an elementary antiderivative (its inner derivative is 2x-2x), while ex2e^{-x^{2}} alone does not. So set

    u=x,dv=xex2dx.u=x,\qquad dv=xe^{-x^{2}}\,dx.

    Splitting the other way, with dv=ex2dxdv=e^{-x^{2}}dx, immediately stalls — the choice of pairing is the entire trick.

  2. Find vv by substitution. With t=x2t=-x^{2}, dt=2xdxdt=-2x\,dx:

    v=xex2dx=12etdt=12ex2.v=\int xe^{-x^{2}}dx=-\frac12\int e^{t}\,dt=-\frac12 e^{-x^{2}}.

    Also du=dxdu=dx. The 12-\tfrac12 comes from 12\frac{1}{-2} in the substitution and must be carried through.

  3. Apply integration by parts. Using udv=uvvdu\int u\,dv=uv-\int v\,du:

    x2ex2dx=x(12ex2)(12ex2)dx=x2ex2+12ex2dx.\int x^{2}e^{-x^{2}}dx=x\left(-\frac12 e^{-x^{2}}\right)-\int\left(-\frac12 e^{-x^{2}}\right)dx=-\frac{x}{2}e^{-x^{2}}+\frac12\int e^{-x^{2}}dx.

    The remaining integral is the Gaussian — simpler than what we started with, which is the sign that the pairing was chosen well.

  4. Express the Gaussian with the error function. ex2dx\int e^{-x^{2}}dx has no elementary antiderivative. The error function is defined precisely to name it:

    erf(x)=2π0xet2dt    ex2dx=π2erf(x)+C.\operatorname{erf}(x)=\frac{2}{\sqrt{\pi}}\int_{0}^{x}e^{-t^{2}}dt\;\Longrightarrow\;\int e^{-x^{2}}dx=\frac{\sqrt{\pi}}{2}\operatorname{erf}(x)+C.

  5. Assemble and verify. Substituting back,

    x2ex2dx=x2ex2+π4erf(x)+C.\int x^{2}e^{-x^{2}}dx=-\frac{x}{2}e^{-x^{2}}+\frac{\sqrt{\pi}}{4}\operatorname{erf}(x)+C.

    Differentiating: 12ex2+x2ex2+π42πex2=x2ex2-\tfrac12 e^{-x^{2}}+x^{2}e^{-x^{2}}+\tfrac{\sqrt{\pi}}{4}\cdot\tfrac{2}{\sqrt{\pi}}e^{-x^{2}}=x^{2}e^{-x^{2}} ✓ — the two half-terms cancel exactly. A numeric check at x=0.9x=0.9 gives 0.36033500.3603350 both ways ✓. As a bonus, since erf()=1\operatorname{erf}(\infty)=1 and the first term vanishes, 0x2ex2dx=π4\int_{0}^{\infty}x^{2}e^{-x^{2}}dx=\tfrac{\sqrt{\pi}}{4}.

Answer

x2ex2dx=x2ex2+π4erf(x)+C\int x^{2}e^{-x^{2}}\,dx=-\frac{x}{2}e^{-x^{2}}+\frac{\sqrt{\pi}}{4}\operatorname{erf}(x)+C

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