# Chain Rule

## 関連する計算機: ステップ付きのオンライン微分計算機

Now, let's see how to differentiate composite functions.

Suppose that we are given a function ${h}{\left({x}\right)}={f{{\left({g{{\left({x}\right)}}}\right)}}}$. Remembering that ${g{'}}{\left({x}\right)}$ is the rate of change of ${g{{\left({x}\right)}}}$ with respect to ${x}$ and ${f{'}}{\left({g{{\left({x}\right)}}}\right)}$ is the rate of change of ${f{}}$ with respect to ${g{{\left({x}\right)}}}$, it is reasonable to suggest that the rate of change of ${f{}}$ with respect to ${x}$ is the product of ${f{'}}{\left({g{{\left({x}\right)}}}\right)}$ and ${g{'}}{\left({x}\right)}$.

Indeed, if ${g{}}$ changes twice as fast as ${x}$ and ${f{}}$ changes three times as fast as ${g{}}$, we can state that ${f{}}$ changes six times as fast as ${x}$.

Chain Rule. If ${f{}}$ and ${g{}}$ are both differentiable and ${h}={f{\circ}}{g{}}$ is a composite function defined by ${h}{\left({x}\right)}={f{{\left({g{{\left({x}\right)}}}\right)}}}$, we have that ${h}$ is differentiable and ${h}'{\left({x}\right)}={f{'}}{\left({g{{\left({x}\right)}}}\right)}{g{'}}{\left({x}\right)}$.

Proof. Recall that if ${y}={f{{\left({x}\right)}}}$ and ${x}$ changes from ${a}$ to ${a}+\Delta{x}$, the increment of ${y}$ is $\Delta{y}={f{{\left({a}+\Delta{x}\right)}}}-{f{{\left({a}\right)}}}$. According to the definition of derivative, $\lim_{{\Delta{x}\to{0}}}\frac{{\Delta{y}}}{{\Delta{x}}}={f{'}}{\left({a}\right)}$.

So, if we denote by $\epsilon$ the difference between the difference quotient and the derivative, we obtain that $\lim_{{\Delta{x}\to{0}}}\epsilon=\lim_{{\Delta{x}\to{0}}}{\left(\frac{{\Delta{y}}}{{\Delta{x}}}-{f{'}}{\left({a}\right)}\right)}={f{'}}{\left({a}\right)}-{f{'}}{\left({a}\right)}={0}$.

But $\epsilon=\frac{{\Delta{y}}}{{\Delta{x}}}-{f{'}}{\left({a}\right)}$, or $\Delta{y}={f{'}}{\left({a}\right)}\Delta{x}+\epsilon\Delta{x}$.

Thus, for any differentiable function ${f{}}$, $\Delta{y}={f{'}}{\left({a}\right)}\Delta{x}+\epsilon\Delta{x}$, where $\epsilon\to{0}$ as $\Delta{x}\to{0}$.

Now, suppose ${u}={g{{\left({x}\right)}}}$ is differentiable at ${a}$ and ${y}={f{{\left({u}\right)}}}$ is differentiable at ${b}={g{{\left({a}\right)}}}$. If $\Delta{x}$ is an increment in ${x}$ and $\Delta{u}$ and $\Delta{y}$ are the corresponding increments in ${u}$ and ${y}$, we have that:

$\Delta{u}={g{'}}{\left({a}\right)}\Delta{x}+\epsilon_{{1}}\Delta{x}={\left({g{'}}{\left({a}\right)}+\epsilon_{{1}}\right)}\Delta{x}$, where $\epsilon_{{1}}\to{0}$ as $\Delta{x}\to{0}$.

$\Delta{y}={f{'}}{\left({b}\right)}\Delta{u}+\epsilon_{{2}}\Delta{u}={\left({f{'}}{\left({b}\right)}+\epsilon_{{2}}\right)}\Delta{u}$, where $\epsilon_{{2}}\to{0}$ as $\Delta{u}\to{0}$.

Now, substitute the expression for $\Delta{u}$ in the last equation:

$\Delta{y}={\left({f{'}}{\left({b}\right)}+\epsilon_{{2}}\right)}{\left({g{'}}{\left({a}\right)}+\epsilon_{{1}}\right)}\Delta{x}$,

Or

$\frac{{\Delta{y}}}{{\Delta{x}}}={\left({f{'}}{\left({b}\right)}+\epsilon_{{2}}\right)}{\left({g{'}}{\left({a}\right)}+\epsilon_{{1}}\right)}$

As $\Delta{x}\to{0}$, it can be stated that $\Delta{u}\to{0}$. So, both $\epsilon_{{1}}\to{0}$ and $\epsilon_{{2}}\to{0}$ as $\Delta{x}\to{0}$.

Therefore, $\frac{{{d}{y}}}{{{d}{x}}}=\lim_{{\Delta{x}\to{0}}}{\left({\left({f{'}}{\left({b}\right)}+\epsilon_{{2}}\right)}{\left({g{'}}{\left({a}\right)}+\epsilon_{{1}}\right)}\right)}={f{'}}{\left({b}\right)}{g{'}}{\left({a}\right)}={f{'}}{\left({g{{\left({a}\right)}}}\right)}{g{'}}{\left({a}\right)}$.

In Leibniz's notation, if ${y}={f{{\left({u}\right)}}}$ and ${u}={g{{\left({x}\right)}}}$ are both differentiable, $\frac{{{d}{y}}}{{{d}{x}}}=\frac{{{d}{y}}}{{{d}{u}}}\frac{{{d}{u}}}{{{d}{x}}}$.

In Leibniz's notation, it is especially easy to remember the chain rule, because if $\frac{{{d}{y}}}{{{d}{u}}}$ and $\frac{{{d}{u}}}{{{d}{x}}}$ were quotients, we could cancel ${d}{u}$. Remember, however, that ${d}{u}$ has not been defined and $\frac{{{d}{u}}}{{{d}{x}}}$ should not be thought of as an actual quotient.

Example 1. Find the derivative of ${h}{\left({x}\right)}=\sqrt{{{{x}}^{{2}}+{1}}}$.

Here, ${f{{\left({u}\right)}}}=\sqrt{{{u}}}$, ${g{{\left({x}\right)}}}={{x}}^{{2}}+{1}$, and ${h}{\left({x}\right)}={f{{\left({g{{\left({x}\right)}}}\right)}}}$; therefore,

${f{'}}{\left({u}\right)}={\left(\sqrt{{{u}}}\right)}'=\frac{{1}}{{{2}\sqrt{{{u}}}}}$, and ${g{'}}{\left({x}\right)}={\left({{x}}^{{2}}+{1}\right)}'={2}{x}$.

So, ${h}'{\left({x}\right)}={f{'}}{\left({g{{\left({x}\right)}}}\right)}{g{'}}{\left({x}\right)}={f{'}}{\left(\sqrt{{{{x}}^{{2}}+{1}}}\right)}{2}{x}=\frac{{1}}{{{2}\sqrt{{{{x}}^{{2}}+{1}}}}}{2}{x}=\frac{{x}}{{\sqrt{{{{x}}^{{2}}+{1}}}}}$.

When using the chain rule, we work from the outside to the inside. We differentiate the outer function [at the inner function $g(x)$] and then we multiply by the derivative of the inner function.

Example 2. Differentiate ${y}={\cos{{\left({{x}}^{{3}}\right)}}}$ and ${y}={{\left({\cos{{\left({x}\right)}}}\right)}}^{{3}}$.

If ${y}={\cos{{\left({{x}}^{{3}}\right)}}}$, the outer function is a cosine and the inner is a cubic function; so, ${y}'=-{\sin{{\left({{x}}^{{3}}\right)}}}\cdot{\left({{x}}^{{3}}\right)}'=-{3}{{x}}^{{2}}{\sin{{\left({{x}}^{{3}}\right)}}}$.

If ${y}={{\left({\cos{{\left({x}\right)}}}\right)}}^{{3}}$, the outer function is cubic and the inner is a cosine; so, ${y}'={3}{{\left({\cos{{\left({x}\right)}}}\right)}}^{{2}}\cdot{\left({\cos{{\left({x}\right)}}}\right)}'=-{3}{{\left({\cos{{\left({x}\right)}}}\right)}}^{{2}}{\sin{{\left({x}\right)}}}$.

One more example.

Example 3. Differentiate ${y}={{\left({{x}}^{{2}}+{1}\right)}}^{{7}}$.

${y}'={7}{{\left({{x}}^{{2}}+{1}\right)}}^{{6}}\cdot{\left({{x}}^{{2}}+{1}\right)}'={7}{{\left({{x}}^{{2}}+{1}\right)}}^{{6}}\cdot{2}{x}={14}{x}{{\left({{x}}^{{2}}+{1}\right)}}^{{6}}$.

Let's work another example.

Example 4. Differentiate ${y}={{\left(\frac{{{2}{t}+{3}}}{{{t}-{5}}}\right)}}^{{8}}$.

Here, we use the chain rule and the quotient rule.

${y}'={8}{{\left(\frac{{{2}{t}+{3}}}{{{t}-{5}}}\right)}}^{{{8}-{1}}}\cdot{\left(\frac{{{2}{t}+{3}}}{{{t}-{5}}}\right)}'={8}{{\left(\frac{{{2}{t}+{3}}}{{{t}-{5}}}\right)}}^{{7}}\frac{{{\left({2}{t}+{3}\right)}'{\left({t}-{5}\right)}-{\left({2}{t}+{3}\right)}{\left({t}-{5}\right)}'}}{{{\left({t}-{5}\right)}}^{{2}}}=$

$={8}{{\left(\frac{{{2}{t}+{3}}}{{{t}-{5}}}\right)}}^{{7}}\frac{{{2}{\left({t}-{5}\right)}-{\left({2}{t}+{3}\right)}}}{{{\left({t}-{5}\right)}}^{{2}}}={8}{{\left(\frac{{{2}{t}+{3}}}{{{t}-{5}}}\right)}}^{{7}}\frac{{-{13}}}{{{\left({t}-{5}\right)}}^{{2}}}=-{104}\frac{{{{\left({2}{t}+{3}\right)}}^{{7}}}}{{{{\left({t}-{5}\right)}}^{{9}}}}$.

This is clear. Let's do a more complex one.

Example 5. Find the derivative of ${f{{\left({x}\right)}}}={{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}}^{{5}}{{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}}^{{2}}$.

We need to use the product rule together with the chain rule.

${f{'}}{\left({x}\right)}={\left({{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}}^{{5}}\right)}'{{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}}^{{2}}+{{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}}^{{5}}{\left({{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}}^{{2}}\right)}'=$

$={5}{{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}}^{{4}}\cdot{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}'{{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}}^{{2}}+{{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}}^{{5}}{2}{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}'=$

$={5}{{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}}^{{4}}\cdot{\left({6}{x}+{4}\right)}{{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}}^{{2}}+{{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}}^{{5}}{2}{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}{\left({{e}}^{{x}}+{\cos{{\left({x}\right)}}}\right)}=$

$={2}{{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}}^{{4}}{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}{\left({5}{\left({3}{x}+{2}\right)}{\left({{e}}^{{x}}+{\sin{{\left({x}\right)}}}\right)}+{\left({3}{{x}}^{{2}}+{4}{x}+{1}\right)}{\left({{e}}^{{x}}+{\cos{{\left({x}\right)}}}\right)}\right)}$.

Now, let's see how to use the chain rule more than once.

Example 6. Differentiate ${f{{\left({t}\right)}}}={{e}}^{{{\cos{{\left({2}{t}\right)}}}}}$.

We apply the chain rule twice.

${f{'}}{\left({t}\right)}={\left({{e}}^{{{\cos{{\left({2}{t}\right)}}}}}\right)}'={{e}}^{{{\cos{{\left({2}{t}\right)}}}}}\cdot{\left({\cos{{\left({2}{t}\right)}}}\right)}'={{e}}^{{{\cos{{\left({2}{t}\right)}}}}}\cdot{\left(-{\sin{{\left({2}{t}\right)}}}\right)}\cdot{\left({2}{t}\right)}'=$

$=-{2}{\sin{{\left({2}{t}\right)}}}{{e}}^{{{\cos{{\left({2}{t}\right)}}}}}$.

And our final example.

Example 7. Differentiate ${f{{\left({x}\right)}}}={\cos{{\left({\sin{{\left({\tan{{\left({x}\right)}}}\right)}}}\right)}}}$.

Here we apply the chain rule twice again.

${f{'}}{\left({x}\right)}={\left({\cos{{\left({\sin{{\left({\tan{{\left({x}\right)}}}\right)}}}\right)}}}\right)}'=-{\sin{{\left({\sin{{\left({\tan{{\left({x}\right)}}}\right)}}}\right)}}}\cdot{\left({\sin{{\left({\tan{{\left({x}\right)}}}\right)}}}\right)}'=$

$=-{\sin{{\left({\sin{{\left({\tan{{\left({x}\right)}}}\right)}}}\right)}}}\cdot{\left({\cos{{\left({\tan{{\left({x}\right)}}}\right)}}}\right)}\cdot{\left({\tan{{\left({x}\right)}}}\right)}'=$

$=-{{\sec}}^{{2}}{\left({x}\right)}{\cos{{\left({\tan{{\left({x}\right)}}}\right)}}}{\sin{{\left({\sin{{\left({\tan{{\left({x}\right)}}}\right)}}}\right)}}}$.

In general, we can apply the chain rule even more than two times. We should use it as many times as we need.