DerivCalc
Focused calculus lesson

Mastering the Chain Rule

Master the chain rule for nested functions with outside-in identification, multi-layer examples, mistakes, and practice.

Guide 3 · Core rules

Mastering the Chain Rule

Written by SilverCodeLabsReviewed for mathematical clarityRevised September 23, 2026
Recognize

One function sits inside another function.

Apply

Differentiate outside, preserve inside, multiply by inside derivative.

Verify

Count layers; each normally contributes a derivative factor.

The Chain Rule is one of the most powerful tools in calculus, used to differentiate composite functions — functions nested within one another. It describes how rates of change propagate through a system of dependent variables, like a chain reaction.

The Core Concept: Outside-In Differentiation

A composite function \(h(x) = f(g(x))\) has an "outer function" \(f\) and an "inner function" \(g\). The Chain Rule states that the derivative is the derivative of the outer function (evaluated at the original inner function) multiplied by the derivative of the inner function.

The rule in two notations

Lagrange's notation: \((f(g(x)))' = f'(g(x)) \cdot g'(x)\)

Leibniz's notation: if \(y=f(u)\) and \(u=g(x)\), then \(\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}\)

Example: differentiating \(h(x) = \sin(x^2)\)

  • Outer function \(f(u)=\sin(u)\): derivative is \(\cos(u)\).
  • Inner function \(g(x)=x^2\): derivative is \(2x\).
  • Apply the rule: \(h'(x) = \cos(x^2)\cdot(2x) = 2x\cos(x^2)\)

Advanced Compositions

The rule can be applied recursively for functions with multiple layers.

Nested functions: \(k(x) = \cos^4(7x^2+1)\)

Rewrite as \(k(x) = [\cos(7x^2+1)]^4\). This has three layers:

  1. Outermost (\(u^4\)): \(4[\cos(7x^2+1)]^3\)
  2. Middle (\(\cos(v)\)): \(-\sin(7x^2+1)\)
  3. Innermost (\(7x^2+1\)): \(14x\)

Combine all parts: \(k'(x) = -56x \cos^3(7x^2+1)\sin(7x^2+1)\)

Real-World Applications

  • Related rates: used with time as the variable to find how the rate of change of one quantity affects another (for example, relating a balloon's volume change to its radius change).
  • Machine learning: the Chain Rule is the engine behind "backpropagation," the algorithm used to train artificial neural networks by calculating the gradient of the network's error.
  • Implicit differentiation: the Chain Rule is the justification for why we multiply by \(\frac{dy}{dx}\) when differentiating terms involving \(y\) — see the implicit differentiation lesson.

The Chain Rule is far more than a procedure. It is the essential instrument that allows calculus to move from analyzing static quantities to studying dynamic, interconnected systems — the causal chains that govern processes in science, engineering, and beyond.

Try it: differentiate sin(x²) and watch the chain rule fire →

Check the domain before applying the rule

The chain rule applies when the inner function is differentiable at the input and the outer function is differentiable at the corresponding inner value. For ln(g(x)), require g(x) > 0 for the real logarithm. For √g(x), the usual derivative formula g′(x)/(2√g(x)) applies when g(x) > 0; zeros of g need separate analysis.

For ln(x²), the derivative is 2x/x² = 2/x for x ≠ 0, including negative inputs. For √(x²), the function equals |x| and is not differentiable at zero. Count the layers, but also check whether the resulting expressions are defined.

Compare the sin(2x) walkthrough with the ln(2x) walkthrough: both include an inner factor of 2, but the logarithm simplifies and the sine does not.

Practice the chain rule with exponentials

For a larger graded sequence, work through the chain rule practice problems with complete solutions.

Compare the constant inner derivative in e^(2x) with the variable inner derivative in e^(x²). Then study e^(−x) to see how a negative inner derivative changes the slope while the function stays positive. Each solution includes second derivatives and practice answers.

Check your understanding

  1. Differentiate (5x−2)⁷.
    Show answer

    35(5x−2)⁶.

  2. Differentiate e^(x²+1).
    Show answer

    2x e^(x²+1).

  3. Differentiate cos³(2x).
    Show answer

    −6cos²(2x)sin(2x).

Reference standard: Rule statements and notation follow OpenStax Calculus Volume 1, Chapter 3. DerivCalc's explanations and examples are independently written.

Editorial note: Worked examples explain the symbolic rules. Numerical spot-checks in the calculator are consistency checks, not formal proofs. Read the methodology and limitations or report a correction.