# Integral of x² eˣ: Formula, Steps and Examples

> The integral of x² eˣ is (x² − 2x + 2)eˣ + C. See integration by parts twice, the tabular shortcut, a check, a graph and the xⁿ eˣ pattern.

Source: https://practicecalculus.com/integrals/x-squared-e-to-the-x
Updated: 2026-11-06

$$ \int x^2 e^x\,dx = (x^2 - 2x + 2)e^x + C $$

## At a glance

- **Antiderivative:** $(x^2 - 2x + 2)e^x + C$
- **Method:** Integration by parts twice, or the tabular method
- **From 0 to 1:** $e - 2 \approx 0.718$
- **With e^(−x), 0 to ∞:** $\int_0^\infty x^2e^{-x}\,dx = 2$
- **Pattern:** $\int x^3e^x\,dx = (x^3 - 3x^2 + 6x - 6)e^x + C$

## Key takeaways

- The integral of $x^2e^x$ is $(x^2 - 2x + 2)e^x + C$.
- Use integration by parts twice with $u$ as the power of $x$. Each pass lowers the power by one.
- The tabular method does both passes at once: differentiate $x^2$ to zero, integrate $e^x$, and alternate signs.
- The pattern continues: $\int_0^\infty x^n e^{-x}\,dx = n!$.

The **integral of $x^2e^x$ is $(x^2 - 2x + 2)e^x + C$**. It takes integration by parts twice, and it is the standard example for the tabular method.

$$\int x^2e^x\,dx = (x^2 - 2x + 2)e^x + C$$

## Graph of x² eˣ and its antiderivative

```graph
title: 'y = x² eˣ and its antiderivative (x² − 2x + 2)eˣ'
caption: 'The shaded area from $0$ to $1$ is $e - 2 \approx 0.718$. The dashed antiderivative is always increasing, because $x^2e^x \ge 0$ for every $x$.'
x: [-5, 1.5]
y: [-0.5, 5]
functions:
  - expr: x^2*e^x
    label: y = x² eˣ
  - expr: (x^2 - 2x + 2)*e^x
    label: y = (x² − 2x + 2)eˣ (antiderivative)
    dashed: true
shade:
  expr: x^2*e^x
  from: 0
  to: 1
points:
  - [0, 2, '(0, 2)']
  - [1, 2.718, '(1, e)']
```

## How to integrate x² eˣ step by step

Use [integration by parts](/rules/integration-by-parts-rule), $\int u\,dv = uv - \int v\,du$, with the power of $x$ as $u$ each time.

1. **First pass.** $u = x^2$, $dv = e^x\,dx$, so $du = 2x\,dx$ and $v = e^x$:
$$\int x^2e^x\,dx = x^2e^x - 2\int xe^x\,dx$$
2. **Second pass.** You already know $\int xe^x\,dx = (x-1)e^x$ from the [integral of x eˣ](/integrals/x-e-to-the-x). If not, use $u = x$, $dv = e^x\,dx$ again.
3. **Combine.**
$$x^2e^x - 2(x - 1)e^x + C = (x^2 - 2x + 2)e^x + C$$

## The tabular shortcut

When one factor differentiates to zero and the other is easy to integrate over and over, set up a table. Differentiate $x^2$ in the left column, integrate $e^x$ in the right, and attach alternating signs:

| Sign | Differentiate | Integrate |
| --- | --- | --- |
| $+$ | $x^2$ | $e^x$ |
| $-$ | $2x$ | $e^x$ |
| $+$ | $2$ | $e^x$ |
| | $0$ | $e^x$ |

Multiply each left entry by the right entry one row down, using the sign of the left row:

$$+x^2e^x - 2xe^x + 2e^x = (x^2 - 2x + 2)e^x$$

The [repeated parts and LIATE](/learn/calculus-2/integration-techniques/repeated-parts-and-liate) lesson practices this method.

## Check by differentiating

$$\frac{d}{dx}\Big[(x^2 - 2x + 2)e^x\Big] = (2x - 2)e^x + (x^2 - 2x + 2)e^x = x^2e^x$$

Everything except $x^2$ cancels. A nice way to remember the answer: the polynomial $p(x) = x^2 - 2x + 2$ satisfies $p + p' = x^2$.

## Definite integrals

**From 0 to 1:**

$$\Big[(x^2 - 2x + 2)e^x\Big]_0^1 = (1)e - (2)(1) = e - 2 \approx 0.718$$

**From −∞ to 0:** as $x \to -\infty$, $(x^2 - 2x + 2)e^x \to 0$, so the integral is $2 - 0 = 2$.

**With a decaying exponential.** $\int x^2e^{-x}\,dx = -(x^2 + 2x + 2)e^{-x} + C$, so

$$\int_0^\infty x^2e^{-x}\,dx = 0 - (-2) = 2 = 2!$$

This is a case of the Gamma function result $\int_0^\infty x^ne^{-x}\,dx = n!$. See [improper integrals](/blog/improper-integrals) for why the limit at infinity is $0$.

## The xⁿ eˣ pattern

Each extra power of $x$ adds one row to the table:

| Integral | Answer |
| --- | --- |
| $\int e^x\,dx$ | $e^x + C$ |
| $\int xe^x\,dx$ | $(x - 1)e^x + C$ |
| $\int x^2e^x\,dx$ | $(x^2 - 2x + 2)e^x + C$ |
| $\int x^3e^x\,dx$ | $(x^3 - 3x^2 + 6x - 6)e^x + C$ |

The polynomial is $x^n$ minus its derivative plus its second derivative and so on, with alternating signs.

## Worked examples

**Example 1: a faster exponential.** $\int x^2e^{2x}\,dx$. In the tabular method the right column is $e^{2x}, \frac{1}{2}e^{2x}, \frac{1}{4}e^{2x}, \frac{1}{8}e^{2x}$:

$$\frac{x^2}{2}e^{2x} - \frac{2x}{4}e^{2x} + \frac{2}{8}e^{2x} + C = \left(\frac{x^2}{2} - \frac{x}{2} + \frac{1}{4}\right)e^{2x} + C$$

**Example 2: a quadratic.** $\int(x^2 + 1)e^x\,dx$. Here $p = x^2 + 1$, and the pattern gives $(p - p' + p'')e^x = (x^2 + 1 - 2x + 2)e^x = (x^2 - 2x + 3)e^x + C$.

**Example 3: a substitution first.** $\int x^3e^{x^2}\,dx$. Let $w = x^2$, $dw = 2x\,dx$, so the integral is $\frac{1}{2}\int we^w\,dw = \frac{1}{2}(x^2 - 1)e^{x^2} + C$.

## Common mistakes

1. **Stopping after one pass.** $x^2e^x - 2\int xe^x\,dx$ still has an integral in it.
2. **Losing the factor 2.** The first pass brings out $2x$, and the $2$ multiplies the whole second result.
3. **Wrong signs in the table.** The signs alternate $+, -, +$ starting from the top row.
4. **Choosing $u = e^x$.** The power of $x$ goes up instead of down.

More practice: the [integration by parts practice problems](/practice-problems/integration-by-parts).

## Frequently asked questions

### What is the integral of x² eˣ?

It is $(x^2 - 2x + 2)e^x + C$, which expands to $x^2e^x - 2xe^x + 2e^x + C$.

### What is the integral of x² e^(−x)?

It is $-(x^2 + 2x + 2)e^{-x} + C$. From $0$ to $\infty$ it equals $2$.

### How many times do you use integration by parts for x² eˣ?

Twice. The first pass turns $x^2$ into $2x$, and the second turns $2x$ into $2$. After that only $\int e^x\,dx$ remains.

### What is the integral of x³ eˣ?

It is $(x^3 - 3x^2 + 6x - 6)e^x + C$. Use the tabular method with three nonzero derivatives of $x^3$.
