Chain Rule

Related calculator: Online Derivative Calculator with Steps

Now let's see how to differentiate composite functions.

Suppose that we are given function $$${h}{\left({x}\right)}={f{{\left({g{{\left({x}\right)}}}\right)}}}$$$. Remembering that $$${g{'}}{\left({x}\right)}$$$ is rate of change of $$${g{{\left({x}\right)}}}$$$ with respect to $$${x}$$$ and $$${f{'}}{\left({g{{\left({x}\right)}}}\right)}$$$ is rate of change of $$${f{}}$$$ with respect to $$${g{{\left({x}\right)}}}$$$ then it is reasonable to suggest that rate of change of $$${f{}}$$$ with respect to $$${x}$$$ is 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{}}$$$, then $$${f{}}$$$ changes six times as fast as $$${x}$$$.

Chain Rule. If $$${f{}}$$$ and $$${g{}}$$$ are both differentiable and $$${h}={f{\circ}}{g{}}$$$ is the composite function defined by $$${h}{\left({x}\right)}={f{{\left({g{{\left({x}\right)}}}\right)}}}$$$, then $$${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}$$$ then 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 $$$\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}$$$ then

$$$\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 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}$$$ then$$$\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 notation, if $$${y}={f{{\left({u}\right)}}}$$$ and $$${u}={g{{\left({x}\right)}}}$$$ are both differentiable then $$$\frac{{{d}{y}}}{{{d}{x}}}=\frac{{{d}{y}}}{{{d}{u}}}\frac{{{d}{u}}}{{{d}{x}}}$$$.

In Leibniz notation it is especially easy to remember chain rule because if $$$\frac{{{d}{y}}}{{{d}{u}}}$$$ and $$$\frac{{{d}{u}}}{{{d}{x}}}$$$ were quotients, then 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 derivative of $$${h}{\left({x}\right)}=\sqrt{{{{x}}^{{2}}+{1}}}$$$

Here $$${f{{\left({u}\right)}}}=\sqrt{{{u}}}$$$ and $$${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}}}}}$$$.

In 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)}}}$$$ then outer function is cosine and inner is 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}}$$$ then outer function is cubic and inner is 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)}}}$$$.

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}}$$$.

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

Here we use chain rule and 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}}}}$$$.

Example 5. Find 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 product rule together with 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 chain rule more than once.

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

We apply 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)}}}}}$$$.

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

Here we again apply chain rule twice.

$$${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 chain rule even more than two times. We need to use it as many times as we need.