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" 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, \]
Hopefully, you feel comfortable with basic integrals, e.g.,
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}. \]
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$.
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.
"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.
We will compute the following integrals using the fact that \[ \int f(g(x)) \, g'(x) \, dx = \int f(u) du. \]
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*}
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.
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. \]
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 \]
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$,
This is the main idea. You will have to practice these on many problems to become proficient in this technique.
\[ \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. \]
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?