Chain Rule

The derivative of a composite function \( f(g(x)) \) is given by $$ Df[g(x)] = f'[g(x)] \cdot g'(x) $$

The chain rule is one of the most important tools in differential calculus. It allows you to differentiate functions that are built by combining other functions.

Whenever one function is nested inside another, the chain rule provides a systematic way to compute the derivative. The basic idea is simple: differentiate the outer function, then multiply by the derivative of the inner function.

The rule also extends to compositions involving three or more functions, such as \( f(g(h(x))) \). In that case, the process is repeated step by step, moving from the outermost function toward the innermost one.

This extension is often called the iterated chain rule.

\[ \frac{d}{dx} f(g(h(x))) = f'(g(h(x))) \cdot g'(h(x)) \cdot h'(x) \]

Note. The same idea applies to any number of nested functions. Differentiate the outermost function with respect to its argument, then successively multiply by the derivatives of the inner functions as you work inward.

Worked Examples

The best way to understand the chain rule is to see it in action.

Example 1

Consider the function

$$ \sin x^2 $$

This is a composite function because it can be viewed as the composition of two simpler functions:

$$ f(z)=\sin z $$

$$ z=g(x)=x^2 $$

Applying the chain rule gives

$$ D[\sin z]\cdot D[x^2] $$

The derivative of \( \sin z \) is \( \cos z \), while the derivative of \( x^2 \) is \( 2x \):

$$ \cos z \cdot 2x $$

Substituting \( z=x^2 \) back into the expression yields

$$ \cos x^2 \cdot 2x $$

Therefore, the derivative of the composite function is

$$ 2x \cos x^2 $$

Note. A useful strategy for recognizing a composite function is to temporarily replace part of the expression with a variable such as \( z \). Doing so often makes it easier to identify which function is inside and which function is outside. In this example, differentiating the outer function \( \sin z \) gives \( \cos z \). Afterward, substitute \( z=x^2 \) and multiply by the derivative of the inner function, which is \( 2x \).

Example 2

This example also involves a composite function. Here, the outer function is the squaring operation, while the inner function is the sine function.

$$ \sin^2 x $$

Rewrite the expression as

$$ (\sin x)^2 $$

Now introduce the temporary variable \( z=\sin x \)

$$ f(z)=z^2 $$

$$ z=g(x)=\sin x $$

Applying the chain rule gives

$$ D[z^2]\cdot D[\sin x] $$

The derivative of \( z^2 \) is \( 2z \), while the derivative of \( \sin x \) is \( \cos x \):

$$ 2z\cdot\cos x $$

Substituting \( z=\sin x \) back into the expression yields

$$ 2\sin x\cdot\cos x $$

Therefore, the derivative of the composite function is

$$ 2\sin x\cos x $$

Note. In this case, the inner function is \( \sin x \) and the outer function is squaring. Differentiating the outer function \( z^2 \) gives \( 2z \). Replacing \( z \) with \( \sin x \) and multiplying by the derivative of the inner function, \( \cos x \), produces the final result.

Example 3

Consider the function

$$ ( x^2 +1 )^2 $$

This is a composite function because the expression \( x^2+1 \) can be replaced by a temporary variable \( z \), allowing the function to be rewritten as \( z^2 \).

Applying the chain rule gives

$$ D[ z^2 ] \cdot D[ ( x^2 +1 ) ] $$

$$ 2z \cdot 2x $$

Since \( z=x^2+1 \)

$$ 2( x^2 +1 ) \cdot 2x $$

$$ 4x( x^2 +1 ) $$

$$ 4x^3 + 4x $$

This is the first derivative of the composite function.

Proof of the Chain Rule

The chain rule can be derived directly from the definition of the derivative. Start with the difference quotient of a function \( f(x) \):

$$ \lim_{h \rightarrow 0} \frac{f(x+h)-f(x)}{h} $$

For a composite function, the input of \( f \) is the output of another function \( g \).

$$ x = g(x) $$

Substituting this relationship into the difference quotient gives

$$ \lim_{h \rightarrow 0} \frac{f(g(x+h))-f(g(x))}{h} $$

The increment of the function \( g \) can be written as

$$ g(x+h) = g(x) + \Delta g $$

Substituting this expression into the difference quotient yields

$$ \lim_{h \rightarrow 0} \frac{f(g(x)+\Delta g)-f(g(x))}{h} $$

Now multiply the numerator and denominator by \( g(x+h)-g(x) \):

$$ \lim_{h \rightarrow 0} \frac{f(g(x)+\Delta g)-f(g(x))}{h} \cdot \frac{g(x+h)-g(x)}{g(x+h)-g(x)} $$

$$ \lim_{h \rightarrow 0} \frac{f(g(x)+\Delta g)-f(g(x))}{g(x+h)-g(x)} \cdot \frac{g(x+h)-g(x)}{h} $$

$$ \lim_{h \rightarrow 0} \frac{f(g(x)+\Delta g)-f(g(x))}{\Delta g} \cdot \frac{g(x+h)-g(x)}{h} $$

Note. In the last step, \( g(x+h)-g(x) \) was replaced by \( \Delta g \) because $$ g(x+h)=g(x)+\Delta g $$ and therefore $$ \Delta g=g(x+h)-g(x) $$

Using the product law for limits, we obtain

$$ \lim_{h \rightarrow 0} \frac{f(g(x)+\Delta g)-f(g(x))}{\Delta g} \cdot \lim_{h \rightarrow 0} \frac{g(x+h)-g(x)}{h} $$

As \( h \to 0 \), the quantity \( \Delta g \) also approaches zero because \( \Delta g=g(x+h)-g(x) \).

Therefore, the first limit can be rewritten as

$$ \lim_{\Delta g \rightarrow 0} \frac{f(g(x)+\Delta g)-f(g(x))}{\Delta g} \cdot \lim_{h \rightarrow 0} \frac{g(x+h)-g(x)}{h} $$

The two limits can now be identified directly.

The first factor is the derivative of \( f \) evaluated at \( g(x) \), while the second factor is the derivative of \( g(x) \).

$$ f'(g(x)) \cdot g'(x) $$

This shows that the derivative of a composite function is obtained by multiplying the derivative of the outer function, evaluated at the inner function, by the derivative of the inner function itself. This completes the proof of the chain rule.

An Alternative Proof of the Chain Rule

The chain rule is one of the most important results in differential calculus. It allows us to differentiate composite functions, that is, functions built by applying one function to the output of another.

We want to prove the following formula:

$$ D[f(g(x))]=f'(g(x)) \cdot g'(x) $$

Start with the definition of the derivative:

$$ D[f(g(x))]=\lim_{h\to 0}\frac{f(g(x+h))-f(g(x))}{h} $$

Here, \( h \) represents a small change in the independent variable \( x \). When \( x \) changes by \( h \), the value of the inner function \( g(x) \) changes as well.

To simplify the notation, introduce the variable

$$ z=g(x) $$

and let \( \Delta z \) represent the corresponding change in \( z \):

$$ \Delta z=g(x+h)-g(x) $$

From this definition, we obtain

$$ g(x+h)=g(x)+\Delta z=z+\Delta z $$

Substituting this expression into the definition of the derivative gives

$$ \lim_{h\to 0}\frac{f(z+\Delta z)-f(z)}{h} $$

At this stage, the numerator is expressed in terms of \( z \), but the denominator is still expressed in terms of \( h \).

To isolate the derivative of \( f \), multiply and divide by \( \Delta z \):

$$ \lim_{h\to 0} \frac{f(z+\Delta z)-f(z)}{h} \cdot \frac{\Delta z}{\Delta z} $$

Rearranging the factors yields

$$ \lim_{h\to 0} \frac{f(z+\Delta z)-f(z)}{\Delta z} \cdot \frac{\Delta z}{h} $$

The original difference quotient has now been split into two separate factors.

The first factor is

$$ \frac{f(z+\Delta z)-f(z)}{\Delta z} $$

Because \( g \) is differentiable, it is also continuous. Therefore, as \( h \to 0 \), the increment \( \Delta z \) also approaches zero:

$$ \Delta z=g(x+h)-g(x)\to 0 $$

As a result, the first factor approaches the derivative of \( f \):

$$ \lim_{\Delta z\to 0} \frac{f(z+\Delta z)-f(z)}{\Delta z}=f'(z) $$

Now consider the second factor:

$$ \frac{\Delta z}{h} $$

Substituting the definition of \( \Delta z \) gives

$$ \frac{\Delta z}{h}=\frac{g(x+h)-g(x)}{h} $$

As \( h \to 0 \), this expression becomes the derivative of \( g \):

$$ \lim_{h\to 0}\frac{g(x+h)-g(x)}{h}=g'(x) $$

Combining the two results, the entire limit becomes

$$ f'(z)\cdot g'(x) $$

Finally, since \( z=g(x) \), substitute back:

$$ f'(g(x))\cdot g'(x) $$

Therefore, the derivative of a composite function is

$$ D[f(g(x))]=f'(g(x))\cdot g'(x) $$

This is exactly the chain rule.

The Iterated Chain Rule

When a composite function contains three nested functions, \( f(g(h(x))) \), the chain rule can be applied repeatedly from the outside in: \[ \frac{d}{dx}f(g(h(x)))=f'(g(h(x)))\cdot g'(h(x))\cdot h'(x) \]

In other words, first differentiate the outermost function \( f \).

Then multiply by the derivative of the middle function \( g \).

Finally, multiply by the derivative of the innermost function \( h \).

Each derivative is evaluated with respect to its own argument, which is why the process works naturally from the outside toward the inside.

Example

Consider the composite function

\[ f(g(h(x))) = e^{(\sin(x))^2} \]

This function is built from three nested functions:

  • \( h(x)=\sin(x) \), the innermost function
  • \( g(u)=u^2 \), the middle function
  • \( f(v)=e^v \), the outermost function

Start by differentiating the outer function \( f(v)=e^v \):

\[ f'(g(h(x)))=e^{(\sin(x))^2} \]

Next, differentiate the middle function \( g(u)=u^2 \):

\[ g'(h(x))=2\sin(x) \]

Finally, differentiate the innermost function \( h(x)=\sin(x) \):

\[ h'(x)=\cos(x) \]

Multiplying these three derivatives together gives

\[ \frac{d}{dx}f(g(h(x))) = e^{(\sin(x))^2}\cdot 2\sin(x)\cdot\cos(x) \]

Therefore,

\[ \frac{d}{dx}e^{(\sin x)^2} = e^{(\sin x)^2}\cdot 2\sin x\cdot\cos x = 2e^{(\sin x)^2}\sin x\cos x \]

The result can be simplified further using the double-angle identity

\[ \sin(2x)=2\sin x\cos x \]

Substituting this identity into the derivative yields

\[ \frac{d}{dx}e^{(\sin x)^2} = e^{(\sin x)^2}\sin(2x) \]

The same approach can be used for compositions involving four, five, or even more nested functions. Each additional layer contributes one more derivative factor to the final product.

 
 

Please feel free to point out any errors or typos, or share suggestions to improve these notes. English isn't my first language, so if you notice any mistakes, let me know, and I'll be sure to fix them.

FacebookTwitterLinkedinLinkedin
knowledge base

Derivatives

Theorems

Various Derivatives

Exercises