Derivatives

Chain Rule Explained: Formula, Steps and 8 Examples

Chain Rule Explained: Formula, Steps and 8 Examples — CalculusCalc cover image

The chain rule: for a composite function \( f(g(x)) \),

$$\frac{d}{dx}f\big(g(x)\big) = f'\big(g(x)\big)\cdot g'(x)$$

In Leibniz notation, with \( y = f(u) \) and \( u = g(x) \): \( \frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx} \).

In words: differentiate the outer function, leave the inside alone, then multiply by the derivative of the inside.

The chain rule is the rule you will use most often after the power rule, because almost every interesting function is built by putting one function inside another. Once you can see the layers, the rule itself is mechanical.

Why rates multiply

If \( u \) changes 3 times as fast as \( x \), and \( y \) changes 2 times as fast as \( u \), then \( y \) changes \( 2\times3 = 6 \) times as fast as \( x \). Nested rates of change multiply. That is the whole idea of the chain rule.

Gears make this concrete. Suppose gear A turns gear B three times per turn of A, and gear B turns gear C twice per turn of B. Then C turns six times for every turn of A. Each gear ratio is a derivative, and the overall ratio is their product.

Seeing the inside derivative on a graph

Compare \( \sin x \) with \( \sin(2x) \). The second graph has the same shape, but it is squeezed horizontally by a factor of 2, so it completes each wave in half the time. Squeezing a curve horizontally makes every slope steeper by the same factor. So the slopes of \( \sin(2x) \) should be twice the slopes of sine at the matching point, and indeed its derivative is \( 2\cos(2x) \).

That factor of 2 is exactly the derivative of the inside function \( 2x \). The outer derivative, \( \cos(2x) \), tells you the slope of the basic wave at the right spot, and the inside derivative tells you how much faster that wave is being run through. Forgetting the inside derivative amounts to forgetting that the graph was squeezed.

You can also check the rule against algebra. Expanding \( (2x+1)^2 \) gives \( 4x^2 + 4x + 1 \), with derivative \( 8x + 4 \). The chain rule gives \( 2(2x+1)\cdot 2 \), which is the same.

Why it works

Let \( u = g(x) \) and \( y = f(u) \). A small change \( \Delta x \) causes a change \( \Delta u \) in the inside, which in turn causes a change \( \Delta y \) in the output. As long as \( \Delta u \neq 0 \), you can write

$$\frac{\Delta y}{\Delta x} = \frac{\Delta y}{\Delta u}\cdot\frac{\Delta u}{\Delta x}$$

Now let \( \Delta x \to 0 \). Because \( g \) is differentiable, it is continuous, so \( \Delta u \to 0 \) as well. The first fraction approaches \( f'(u) = f'(g(x)) \) and the second approaches \( g'(x) \). That is the chain rule. A fully rigorous proof also has to handle functions where \( \Delta u \) is zero for some small \( \Delta x \), but the idea is exactly this: the Leibniz fractions really do behave like fractions in the limit.

A 3-step method

  1. Spot the layers. Ask “what is done last?” That is the outer function.
  2. Differentiate the outer layer, keeping the inside unchanged.
  3. Multiply by the derivative of the inside. Repeat if the inside has layers of its own.

Here is how the first step looks for some common shapes:

Function Outer Inner
\( (3x^2+1)^5 \) \( u^5 \) \( 3x^2 + 1 \)
\( \sin(x^2) \) \( \sin u \) \( x^2 \)
\( e^{3x} \) \( e^u \) \( 3x \)
\( \ln(\cos x) \) \( \ln u \) \( \cos x \)
\( \sin^2 x \) \( u^2 \) \( \sin x \)

The last row is the one people misread. \( \sin^2 x \) means \( (\sin x)^2 \), so squaring is the outer layer and its derivative is \( 2\sin x\cos x \). The same pattern is worked in detail in derivative of cos²x.

Shortcut formulas

Applying the chain rule to the standard outer functions gives a handful of patterns worth memorizing, where \( g \) is any inside function:

$$\begin{aligned} \frac{d}{dx}\,g^n &= n\,g^{n-1}\,g' \\ \frac{d}{dx}\,e^{g} &= e^{g}\,g' \\ \frac{d}{dx}\ln g &= \frac{g'}{g} \\ \frac{d}{dx}\sin g &= \cos g\cdot g' \end{aligned}$$

The first line is often called the general power rule. Each one is simply “derivative of the outer function, times the derivative of the inside.”

8 worked examples

1. \( (3x^2 + 1)^5 \). Outer: \( u^5 \). Inside: \( 3x^2 + 1 \).

$$5(3x^2+1)^4\cdot 6x = 30x(3x^2+1)^4$$

Expanding \( (3x^2+1)^5 \) first would also work, but it means multiplying out a polynomial of degree 10. The chain rule avoids that entirely.

2. \( \sin(x^2) \): \( \cos(x^2)\cdot 2x \). The cosine keeps \( x^2 \) inside it unchanged; the \( 2x \) is the derivative of that inside.

3. \( e^{3x} \): \( 3e^{3x} \) (more in derivative of e^2x)

4. \( \sqrt{1 + x^3} \): \( \frac{3x^2}{2\sqrt{1 + x^3}} \). Think of the root as a power of one half; its derivative puts \( 2\sqrt{\;} \) in the denominator, and \( 3x^2 \) comes from the inside.

5. \( \ln(\cos x) \): \( \frac{-\sin x}{\cos x} = -\tan x \)

6. \( \sin\left(e^{2x}\right) \): three layers (sine, exponential, linear):

$$\cos\left(e^{2x}\right)\cdot e^{2x}\cdot 2$$

7. \( \cos^2(x^3) \): squaring, then cosine, then cube:

$$2\cos(x^3)\cdot\left(-\sin(x^3)\right)\cdot 3x^2 = -6x^2\cos(x^3)\sin(x^3)$$

8. \( \frac{1}{(x^2+4)^3} = (x^2+4)^{-3} \): \( -3(x^2+4)^{-4}\cdot 2x = -\frac{6x}{(x^2+4)^4} \). Rewriting as a negative power lets you skip the quotient rule.

Harder examples

9. \( e^{\sin x} \). The exponential is outermost, so it stays as it is and gets multiplied by the derivative of its exponent: \( \cos x\,e^{\sin x} \).

10. \( \sin^3(2x) \). Three layers: cubing, then sine, then the linear \( 2x \). Peel them one at a time:

$$3\sin^2(2x)\cdot\cos(2x)\cdot 2 = 6\sin^2(2x)\cos(2x)$$

Combining with other rules

The chain rule often sits inside the product rule or quotient rule. For \( x^2\sin(3x) \):

$$2x\sin(3x) + x^2\cdot 3\cos(3x)$$

Example 11. For \( xe^{-x^2} \), the product rule gives two terms, and the second one needs the chain rule because the exponent is \( -x^2 \), with derivative \( -2x \):

$$e^{-x^2} + x\cdot e^{-x^2}\cdot(-2x) = e^{-x^2}\left(1 - 2x^2\right)$$

Decide the overall shape first (here, a product), then handle each piece with whatever rule it needs.

Whenever quantities change over time, the chain rule links their rates. A circle’s radius grows at 2 cm per second. How fast is its area growing when the radius is 5 cm? Area is \( A = \pi r^2 \), and \( r \) is a function of time, so

$$\frac{dA}{dt} = 2\pi r\cdot\frac{dr}{dt} = 2\pi(5)(2) = 20\pi$$

The area grows at \( 20\pi \approx 62.8 \) square centimeters per second. This is the whole basis of related rates problems and of implicit differentiation, where every \( y \) term picks up a factor of \( \frac{dy}{dx} \).

Most common mistakes

  • Forgetting the inside derivative. Writing \( \frac{d}{dx}\sin(x^2) = \cos(x^2) \) is the number one chain-rule error.
  • Changing the inside. In step 2 the inside stays exactly as it was: \( \cos(x^2) \), not \( \cos(2x) \).
  • Stopping one layer early in nested functions like example 6.
  • Treating a composition as a product. \( \sin(x^2) \) is not \( \sin x\cdot x^2 \), so the product rule does not apply to it.
  • Misreading powers of trig functions. \( \sin^3(2x) \) has the cube on the outside, not on the \( 2x \).

Try it yourself

The solver lists every rule it applies, so you can see each chain rule layer.

Step-by-step solverExact symbolic engine

Interactive Calculus Problem Solver

Derivatives, antiderivatives, definite and improper integrals, and limits. Every answer comes with the rules used, and antiderivatives are verified by differentiating them back.

Try:
Input syntax
  • Powers x^2, roots sqrt(x), cbrt(x), absolute value |x|
  • Implicit multiplication works: 3x sin(2x)
  • sin cos tan sec csc cot, asin acos atan, sinh cosh tanh
  • e^x or exp(x); ln(x) and log(x) are both the natural log
  • Constants pi and e; bounds accept inf and -inf
Enter a function and press Solve to see a full worked solution.

For your own functions, the derivative calculator shows each layer of the chain rule as a separate step.

Practice problems

Try these before checking the answers.

  1. \( \frac{d}{dx}(2x - 5)^{7} \)
  2. \( \frac{d}{dx}\cos(\ln x) \)
  3. \( \frac{d}{dx}\sqrt{\tan x} \)
  4. \( \frac{d}{dx}e^{x^2} \)
  5. \( \frac{d}{dx}\ln(x^2 + 1) \)
  6. \( \frac{d}{dx}\cos^4(3x) \)
  7. \( \frac{d}{dx}\tan(5x) \)

Answers: (1) \( 14(2x-5)^6 \); (2) \( -\frac{\sin(\ln x)}{x} \); (3) \( \frac{\sec^2 x}{2\sqrt{\tan x}} \); (4) \( 2xe^{x^2} \); (5) \( \frac{2x}{x^2 + 1} \); (6) \( -12\cos^3(3x)\sin(3x) \); (7) \( 5\sec^2(5x) \).

FAQ

How do I know when to use the chain rule?

Whenever something other than plain \( x \) sits inside a function: inside a power, a root, a trig function, an exponential or a logarithm.

How many times do I apply the chain rule?

Once for every layer below the outermost one. Keep multiplying by inside derivatives until the innermost piece is plain \( x \).

What is the general power rule?

It is the chain rule applied to a power: the derivative of \( g(x)^n \) is \( n\,g(x)^{n-1}g'(x) \).

What is the chain rule for integrals?

Running it backwards is u-substitution.

What is the chain rule in multivariable calculus?

It uses partial derivatives: \( \frac{dz}{dt} = \frac{\partial z}{\partial x}\frac{dx}{dt} + \frac{\partial z}{\partial y}\frac{dy}{dt} \).

Further reading

Calculators for this topic

Leave a comment

Your email address will not be published. Required fields are marked *