Integration by substitution

Chain rule in reverse

As the very first "advanced" integration technique we will study, integration by substitution is essentially the integral version of the "Chain Rule".

Integration by substitution

"Integration by substitution" is essentially the integral version of the "chain rule". It will allow us to compute seemingly complicated integrals like these \[ \int e^{x^2} \, 2x \, dx, \quad\quad\quad \int \frac{3x}{\sqrt{x^2+1}} dx, \]

Preparation

Hopefully, you feel comfortable with basic integrals, e.g.,

  • $\int e^x dx = e^x + C$
  • $\int \cos(x) dx = \sin(x) + C$
  • $\int \sin(x) dx = -\cos(x) + C$
  • $\int 2x dx = x^2 + C$
  • $\int x^{-1} dx = \ln|x| + C$

and understand what they mean.

Moreover, you understand that the names of the variables are not very important in the sense that they only tell us how to distinguish one from another, and nothing more. E.g., you should be able to compute \[ \int e^u du = e^u + C. \]

Make sure you also understand why we cannot directly compute \[ \int e^{\color{red} u} \, d{\color{red} x}. \]

Differentials

You also need to feel comfortable manipulating differentials (which are objects like "$dx$" in integrals).

Suppose $u$ is a function of $x$, then \[ du = \frac{du}{dx} \, dx. \] $du$ and $dx$ are called differentials, and they are meaningful objects in their own rights, even outside integrals.

For example, if $u$ is a function of $x$ given by \[ u = x^2 \] then \[ du = 2x \, dx. \] It is important to understand $du$ is a function of both $x$ and $dx$.

Warm up exercises

You understand $\int e^x dx = e^x + C$ by now. But what about \[ \int e^{3x} dx? \]

A naive guess would be $e^{3x} + C$. That’s not a terrible guess, but it's easy to see it is wrong, since the derivative of $e^{3x}$ would be $3e^{3x}$ (not $e^{3x}$).

So it is off by a factor of 3. To compensate for this, we simply need to multiply our original guess by $\frac{1}{3}$. Therefore, $\frac{1}{3} e^{3x} + C$ is our answer: \[ \int e^{3x} dx = \frac{1}{3} e^{3x} + C. \]

Here, we took an educated guess, which turns out to be wrong, and then we checked our answer and made a good correction. This is a completely valid tactic.

Compute \[ \int \cos(10 x) dx. \]

Substitution

"Substitution" is the simple idea of replacing certain part of an expression by a single variable (or vice versa). For example, \[ e^{-3x} \quad\text{is equivalent to}\quad e^u \;\text{ with }\; u = -3x. \] This simple idea allows us to compute more complicated integrals.

From the "chain rule" in differentiation, we know that \[ [ f(g(x)) ]' = f'(g(x)) \, g'(x). \]

From this, we can easily derive the antiderivative/integral version.

Suppose $f$ is a continuous function and $g$ is a differentiable function, then with $u = g(x)$, \[ \int f(g(x)) \, g'(x) \, dx = \int f(u) du. \]
We are performing a substitution $u = g(x)$, i.e., replacing an inner function by a new variable $u$. The name is not important, as long as it is different from the original variable of integration.

We will compute the following integrals using the fact that \[ \int f(g(x)) \, g'(x) \, dx = \int f(u) du. \]

Compute \[ \int \cos(5x) \, 5 \, dx. \]

Solution. The "inner" function is $u = g(x) = 5x$ (so $g'(x) = 5$), and the "outer" function $f(x) = \cos(x)$. Thus, \begin{gather*} \int \cos(5x) 5 dx = \int f(g(x)) g'(x) dx \\ = \int f(u) du = \int \cos(u) du \\ = \sin(u) + C = \sin(5x) + C. \end{gather*}

Compute \[ \int e^{x^2} \, 2x \, dx. \]

Solution. The "inner" function is $u = g(x) = x^2$ (so $g'(x) = 2x$), and the "outer" function $f(x) = e^x$. Thus, \begin{gather*} \int e^{x^2} 2x dx. = \int f(g(x)) g'(x) dx \\ = \int f(u) du = \int e^u du \\ = e^u + C = e^{x^2} + C. \end{gather*}

The notations we used in these examples may be awkward, and they are there just to help us to see the connection to chain rule. We will see a more natural way of writing.

Substitution in action: a more natural way of writing

Compute \[ \int \cos( \, 3x \,) dx \]
Solution. We will now follow a more natural way writing.

Let $u = 3x$ (the "inner" function") then $du = \frac{du}{dx} \, dx = 3 \, dx.$

That is, $ \color{blue}{\frac{1}{3} du = dx}$. Now we can replace $\color{red}{3x}$ by $\color{red}{u}$ and replace $\color{blue}{dx}$ by $\color{blue}{\frac{1}{3} du}$: \begin{align*} \int \cos(\color{red}{3x}) \,\color{blue}{dx} &= \int \cos(\color{red}{u}) \,\color{blue}{\frac{1}{3} du} = \frac{1}{3} \int \cos(u) du = \frac{\sin(u)}{3} + C \end{align*} where $C$ is an arbitrary constant. Don’t forget that $u$ is a variable we introduced ourselves. So we have to substitute everything back and get \[ \frac{\sin(u)}{3} + C = \frac{\sin(3x)}{3} + C. \]

One more example

Compute \[ \int x \sqrt{1 + x^2} dx \]
Solution. Let $u = 1+x^2$, then, by definition, $du = 2x \, dx.$ That is, \[ \color{blue}{\frac{1}{2} du = x \, dx} \]

Now we can replace $\color{red}{1+x^2}$ by $\color{red}{u}$ and replace $\color{blue}{x \, dx}$ by $\frac{1}{2} du$. Therefore, \begin{align*} \int \color{blue}{x} \sqrt{\color{red}{1+x^2} } \,\color{blue}{dx} &= \int \sqrt{\color{red}{u}} \,\color{blue}{\frac{1}{2} du} = \frac{1}{2} \int \sqrt{u} \, du = \frac{u^{3/2}}{3} + C \end{align*} where $C$ is an arbitrary constant. Again, $u$ is a variable we introduced ourselves. So we have to substitute everything back and get \[ \frac{u^{3/2}}{3} + C = \frac{(1+x^2)^{3/2}}{3} + C \]

Integration by substitution

The above procedure is the essence of integration by substitution. Simply put, when faced with a complicated integral of the form $\int f(x) dx$,

  1. Identify a part of the integral and replace it by a new variable;
  2. Also properly replace the differential $dx$;
  3. Compute the resulting simpler integral if possible;
  4. Replace everything back.

This is the main idea. You will have to practice these on many problems to become proficient in this technique.

Compute \[ \int (2x + 5)^6 dx. \] (Hint: try $u = 2x+5$.)
Compute \[\int \sin(x^3) x^2 \, dx.\] (Hint: try $u = x^3$.)

A less obvious example

Compute \[\int \tan(x) dx.\]
It is not at all obvious that we can even apply substitution here. Let's first rewrite $\tan(x)$ in terms of $\sin(x)$ and $\cos(x)$:

\[ \int \tan(x) dx = \int \frac{\sin(x)}{\cos(x)} dx = \int \frac{1}{\cos(x)} \, \sin(x) \, dx. \]

Now we can pick $u = \cos(x)$. then $du = -\sin(x) dx$. That is, \[ (-1) du = \sin(x) dx. \] Therefore the above integral becomes \[ \int \frac{1}{\cos(x)} \sin(x) dx = -\int \frac{1}{u} du = -\ln|u| + C = -\ln|\cos(x)| + C. \]

When substitution doesn't work

It is very important to understand the limitation of your tools. Consider the integral \[ \int e^{x^2} dx. \]

Can you see why the substitution $u = x^2$ will not work?