Calculus

The Chain Rule Visualized

You already know how to differentiate basic functions: the derivative of x^2 is 2x, the derivative of sin(x) is cos(x). But what about sin(3x)? Or (2x + 1)^5?

These are compositions — functions inside other functions. And to differentiate them, you need the chain rule.

1. Functions Inside Functions

When you write sin(3x), you are really doing two things:

  1. Inner function: g(x) = 3x (triple the input)
  2. Outer function: f(u) = sin(u) (take the sine of the result)

The composition is f(g(x)) = sin(3x). The chain rule tells you how to find its derivative.

00f(g(x))=f(g(x))g(x)\frac00 f(g(x)) = f'(g(x)) \cdot g'(x)

In words: derivative of the outer (evaluated at the inner) times derivative of the inner.

2. See It with sin(kx)

Let’s start simple. The inner function is g(x) = kx, and the outer is f(u) = sin(u). Change k to see how the inner function stretches or compresses the sine wave, and how that affects the derivative.

k (inner function multiplier)1
0.55
f(x)=sin(1x),f(x)=1cos(1x)f(x) = \sin(1 \cdot x), \quad f'(x) = 1 \cos(1 \cdot x)
-6-4-2246-6-4-2246sin(kx)k cos(kx) — derivative
Try This

Try this: Increase k from 1 to 3. The sine wave compresses (more oscillations), and the derivative gets taller — it is multiplied by k. The faster the inner function changes, the bigger the overall derivative. That multiplier k is exactly the chain rule’s g’(x).

3. Power of a Function: (x^2 + a)^n

Here is another classic chain rule scenario. The inner function is g(x) = x^2 + a, and the outer function is f(u) = u^3 (we will use cubing for clarity).

a (shift parameter)1
-33
f(x)=(x2+1)3f(x) = (x^2 + 1)^3
f(x)=3(x2+1)22x=6x(x2+1)2f'(x) = 3(x^2 + 1)^2 \cdot 2x = 6x(x^2 + 1)^2
-10-551015202530(x² + a)³derivative
Connection

The chain rule splits the work: the 3(…)^2 comes from differentiating the outer cube, and the 2x comes from differentiating the inner x^2 + a. You multiply them together. Changing a shifts the inner function up or down, which changes where the derivative is zero — but the chain rule structure stays the same.

4. Exponential Composition: e^(kx)

One of the most important chain rule examples in science is the exponential function with a rate constant.

k (rate constant)1
-22
f(x)=e1x,f(x)=1e1xf(x) = e^{1 x}, \quad f'(x) = 1 \cdot e^{1 x}
-4-224-4-2246810e^(kx)k e^(kx) — derivative
Try This

Try this: Set k = 1. The function and its derivative are the same curve! That is the famous property of e^x. Now change k — the derivative is just a scaled version of the original. The chain rule multiplier k stretches or compresses the derivative. Try negative k for exponential decay.

5. Visualizing the Inner and Outer Together

Let’s put it all together. Below, you can see the inner function g(x), the composition f(g(x)), and the derivative — all at once. The inner function is g(x) = x^2, and the outer is f(u) = sin(u), giving us sin(x^2).

x (point to examine)1
-33
g(x)=x2,f(u)=sin(u),f(g(x))=sin(x2)g(x) = x^2, \quad f(u) = \sin(u), \quad f(g(x)) = \sin(x^2)
f(g(x))g(x)=cos(x2)2xf'(g(x)) \cdot g'(x) = \cos(x^2) \cdot 2x
-4-224-4-22468g(x) = x² (inner)sin(x²) (composition)cos(x²)·2x (derivative)
Challenge

Challenge: Use the chain rule to find the derivative of e^(sin(x)). There are two layers: the outer function is e^u and the inner is sin(x). What is the outer derivative? What is the inner derivative? Multiply them together.

Answer: e^(sin(x)) * cos(x)

The Big Idea

The chain rule says: when functions are nested, multiply the derivatives layer by layer from outside in.

Every composition has an outer function and an inner function. The derivative of the whole thing is the derivative of the outer (evaluated at the inner) times the derivative of the inner. It is like peeling an onion — differentiate each layer and multiply the results together.

Take the Quiz