---
title: The integration techniques you'll need
heading: Undoing the chain rule and the product rule
eyebrow: A5 · Lesson 45 · Integration techniques
xp: 40
---

::: hook
Differentiating is mechanical: the rules always work. Integrating is harder, because not every formula has an antiderivative you can write down, and the ones that do often need a trick. For electrical engineering a small toolkit covers nearly everything: substitution, integration by parts, and a couple of identities. Here's that toolkit, each trick tied to the derivative rule it undoes.
:::

::: predict
## Without integrating, which of these is an antiderivative of $2x\,e^{x^2}$?

- [x] $e^{x^2}$
- [ ] $x^2e^{x^2}$
- [ ] $2e^{x^2}$
- [ ] $e^{2x}$

::: reveal
$e^{x^2}$. Differentiate it with the chain rule: $e^{x^2}\cdot 2x$, exactly the integrand. Recognizing "a function times the derivative of its inside" is the substitution trick, and checking an antiderivative by differentiating it is always allowed and always wise.
:::
:::

::: nameit
## The toolkit

**Substitution** undoes the chain rule. If the integrand is some $f(u)$ times $du/dx$, set $u$ equal to the inside:

$$\int f\big(u(x)\big)\,u'(x)\,dx = \int f(u)\,du$$

For $\int 2x\,e^{x^2}dx$, let $u = x^2$, so $du = 2x\,dx$, and the integral is $\int e^u du = e^u = e^{x^2}$. The most common case in circuits is a linear inside, $u = at + b$: $\int e^{-t/\tau}dt = -\tau e^{-t/\tau}$.

**Integration by parts** undoes the product rule. From $(uv)' = u'v + uv'$,

$$\int u\,v'\,dx = uv - \int u'\,v\,dx$$

Choose $u$ to be the factor that gets simpler when differentiated. For $\int x\,e^{x}dx$, take $u = x$ and $v' = e^x$: the result is $xe^x - \int e^x dx = (x - 1)e^x$.

**Identities** turn awkward powers into easy terms. The one you'll use most, from A2:

$$\sin^2\theta = \frac{1 - \cos 2\theta}{2} \qquad\text{so}\qquad \int_0^{2\pi}\sin^2\theta\,d\theta = \pi$$

That's why the average of $\sin^2$ over a cycle is ½, the heart of RMS.

**Definite integrals of exponential decays** come up in every transient. Two to know:

$$\int_0^{\infty} e^{-t/\tau}dt = \tau \qquad \int_0^{\infty} t\,e^{-t/\tau}dt = \tau^2$$

**When nothing works.** Many integrals, like $\int e^{-x^2}dx$, have no formula in ordinary functions. Then you integrate numerically, with the trapezoid rule or better (A6 and A13), or use a named function: $\int e^{-x^2}$ is where the error function, erf, comes from.

**Energy check.** A capacitor charged to $V_0$ discharging through $R$ delivers power $p = V_0^2e^{-2t/RC}/R$. Integrating to infinity gives $\frac{V_0^2}{R}\cdot\frac{RC}{2} = \tfrac12CV_0^2$, exactly the energy it stored. Lesson 52 finds the same energy from the work done charging it.
:::

::: example
## Find $\int 2x\cos(x^2)\,dx$.

::: solution
1. **Substitute.** Let $u = x^2$, so $du = 2x\,dx$:
   $$\begin{aligned} \int 2x\cos(x^2)\,dx &= \int \cos u\,du \\ &= \sin u + C \\ &= \sin(x^2) + C \end{aligned}$$
2. **Check.**
   $$\frac{d}{dx}\sin(x^2) = 2x\cos(x^2)$$

**Answer:** $\int 2x\cos(x^2)\,dx = \sin(x^2) + C$.
:::
:::

::: example
## Find $\int x\,e^x\,dx$.

::: solution
1. **Integrate by parts.** Take $u = x$ and $dv = e^x\,dx$:
   $$\begin{aligned} \int x e^x\,dx &= xe^x - \int e^x\,dx \\ &= (x - 1)e^x + C \end{aligned}$$
2. **Check.**
   $$\begin{aligned} \frac{d}{dx}(x - 1)e^x &= e^x + (x - 1)e^x \\ &= xe^x \end{aligned}$$

**Answer:** $\int x\,e^x\,dx = (x - 1)e^x + C$.
:::
:::

::: example
## Find $\int_0^\pi x\sin x\,dx$.

::: solution
1. **Choose the parts.** Take $u = x$ and $dv = \sin x\,dx$, so $du = dx$ and $v = -\cos x$.
2. **Integrate by parts.**
   $$\begin{aligned} &\int x\sin x\,dx \\ &= -x\cos x + \int\cos x\,dx \\ &= -x\cos x + \sin x \end{aligned}$$
3. **Evaluate from 0 to $\pi$.**
   $$\begin{aligned} &(-\pi\cos\pi + \sin\pi) - (0) \\ &= \pi \end{aligned}$$
4. **Check.** Differentiating $-x\cos x + \sin x$ gives back $x\sin x$, which confirms it.

**Answer:** the integral is $\pi$.
:::
:::

::: check
kind: expression
given: a = 2..9 int
answer: exp(a*x^2)/(2*a)
vars: x = -1..1

## Find an antiderivative of $x\,e^{\given{a}x^2}$ (constant zero).

::: right
Right. With $u = \given{a}x^2$, $du = 2\cdot\given{a}x\,dx$, so $x\,dx = du/(2\cdot\given{a})$.
:::

::: misses
- [exp(a*x^2)] Differentiate that: you get $2\given{a}x\,e^{\given{a}x^2}$, $2\cdot\given{a}$ times too much.
- [x^2*exp(a*x^2)/2] Substitute $u = \given{a}x^2$ instead of integrating the factors separately.
- [any] Not yet. Substitute $u = \given{a}x^2$.
:::
:::

::: check
kind: expression
answer: (x - 1)*exp(x)
vars: x = -2..2

## Find an antiderivative of $x\,e^{x}$ (constant zero).

::: right
Right. By parts with $u = x$: $xe^x - e^x$. Differentiate to check: $e^x + xe^x - e^x = xe^x$.
:::

::: misses
- [x*exp(x)] Differentiate that: $e^x + xe^x$, one $e^x$ too many.
- [x^2*exp(x)/2] Integrating the factors separately doesn't work for a product. Use parts.
- [any] Not yet. Integrate by parts with $u = x$, $v' = e^x$.
:::
:::

::: check
given: A = 1..20 int; n = 1..4 int
answer: A^2*pi*n
tolerance: 0.5%

## Evaluate $\int_0^{2\pi\given{n}} \given{A}^2\sin^2\theta\,d\theta$.

::: right
Right. Each full cycle of $\sin^2$ contributes π, so the result is $\given{A}^2\pi \times \given{n}$ = {answer}.
:::

::: misses
- [A^2*2*pi*n] $\sin^2$ averages ½, so each cycle contributes π, not 2π.
- [0] $\sin^2$ is never negative, so its area can't be zero.
- [any] Not yet. Use $\sin^2\theta = (1 - \cos 2\theta)/2$.
:::
:::

::: check
given: V0 = 5..24 int; C = 1µ..100µ E6 F
answer: 0.5*C*V0^2
unit: J
tolerance: 1%

## A {C} capacitor charged to {V0} V discharges through a resistor. Integrating the resistor's power $V_0^2e^{-2t/RC}/R$ from 0 to ∞, how much energy does the resistor absorb?

::: right
Right. $\frac{V_0^2}{R}\cdot\frac{RC}{2} = \tfrac12 CV_0^2$ = {answer}: all the stored energy, whatever R is.
:::

::: misses
- [C*V0^2] Integrating $e^{-2t/RC}$ gives $RC/2$: there's a factor of ½.
- [any] Not yet. Use $\int_0^\infty e^{-2t/RC}dt = RC/2$.
:::
:::

::: check
kind: parts
given: a = 1 | 2 | 3

## Evaluate these integrals.

::: part
answer: exp(a)*(a - 1)/a^2 + 1/a^2
tolerance: 0.5%

### $\displaystyle\int_0^1 xe^{\given{a}x}\,dx$

::: misses
- [exp(a)/a] That's $\int_0^1 e^{ax}$ evaluated wrongly; integrate by parts with $u = x$.
- [any] By parts: $\frac{xe^{ax}}{a} - \frac{e^{ax}}{a^2}$.
:::
:::

::: part
answer: ln(1 + a)/(2*a)
tolerance: 0.5%

### $\displaystyle\int_0^1\frac{x}{1 + \given{a}x^2}\,dx$

::: misses
- [ln(1 + a)/a] With $u = 1 + ax^2$, $du = 2ax\,dx$: there's a factor $\frac{1}{2a}$.
- [any] Substitute $u = 1 + ax^2$.
:::
:::

::: part
answer: 1/(a + 1)
tolerance: 0.5%

### $\displaystyle\int_0^{\pi/2}\sin x\cos^{\given{a}}x\,dx$

::: misses
- [any] Substitute $u = \cos x$, $du = -\sin x\,dx$.
:::
:::
:::

::: check
kind: derivation
vars: x = -3..3

## Integrate $x\cos x$ by parts, with $u = x$ and $dv = \cos x\,dx$.

::: step
answer: sin(x)

### What is $v$?
:::

::: step
answer: x*sin(x) + cos(x)

### Write $uv - \int v\,du$ and finish the integral.
:::

::: right
Right. $\int x\cos x\,dx = x\sin x + \cos x + C$; differentiate it to check.
:::
:::

::: explain
## Why is it always a good idea to differentiate an antiderivative you've found?

::: model
Differentiating is mechanical and reliable, while finding antiderivatives involves choices and tricks where it's easy to slip, like a missing constant factor from a substitution. Since an antiderivative is defined as a function whose derivative is the integrand, differentiating your answer and getting the integrand back proves it right, and getting something else shows exactly what went wrong.
:::
:::

::: practice

::: check
kind: expression
given: k = 2..9 int
answer: -exp(-k*x)/k
vars: x = -1..1

## Find an antiderivative of $e^{-\given{k}x}$ (constant zero).

::: misses
- [exp(-k*x)/k] The inner rate is $-\given{k}$: divide by it, sign included.
- [-k*exp(-k*x)] That's the derivative. Divide by the inner rate instead.
- [any] Substitute $u = -\given{k}x$.
:::
:::

::: check
given: tau = 2..9 int
answer: tau^2
tolerance: 0.5%

## Evaluate $\int_0^{\infty} t\,e^{-t/\given{tau}}\,dt$.

::: misses
- [tau] That's $\int_0^\infty e^{-t/\tau}dt$. The extra factor of t gives $\tau^2$.
- [any] By parts, or the known result $\int_0^\infty te^{-t/\tau}dt = \tau^2$.
:::
:::

::: check
kind: expression
given: w = 2..9 int
answer: x/2 - sin(2*w*x)/(4*w)
vars: x = -1..1

## Find an antiderivative of $\sin^2(\given{w}x)$ (constant zero).

::: misses
- [x/2 + sin(2*w*x)/(4*w)] $\sin^2 = (1 - \cos 2\theta)/2$: the cosine term is subtracted.
- [x/2] The cosine term matters for an antiderivative, though it averages out over whole cycles.
- [any] Use $\sin^2\theta = (1 - \cos 2\theta)/2$, then integrate each term.
:::
:::

::: check
given: a = 1..4 int; b = 2..5 int
answer: ((a + b)^3 - b^3)/3
tolerance: 0.5%

## Evaluate $\int_0^{\given{a}}(x + \given{b})^2\,dx$.

::: misses
- [(a + b)^3/3] Subtract the antiderivative's value at 0, which is $\given{b}^3/3$.
- [any] Substitute $u = x + \given{b}$: the limits become {b} and {a} + {b}.
:::
:::
:::
