What Is the Chain Rule?
The chain rule is the differentiation rule for composite functions — functions built by feeding one function into another. When you see sin(3x²), you're really looking at two functions layered together: an outer function (sine) applied to an inner function (3x²). The chain rule says the derivative of such a composition is the derivative of the outer function, evaluated at the inner function, multiplied by the derivative of the inner function:
d/dx[f(g(x))] = f'(g(x)) · g'(x)
The multiplication by g'(x) at the end is the heart of the rule — and the part students most often forget. Intuitively, it accounts for how fast the inner function is feeding change into the outer one: if the inner function is changing three times as fast as x itself, the whole composition inherits that factor of three on top of the outer function's own rate of change.
How to Use This Calculator
Enter a composite function like sin(3x^2) or exp(x^2+1). The calculator identifies the outer and inner functions automatically, differentiates each one separately, and shows the chain rule assembling them into the final answer. If your expression has multiple layers of nesting — like ln(cos(x)), where ln wraps cos which wraps x — the rule is applied recursively from the outside in, exactly the way you'd work it by hand. Optionally supply an x-value to get the numeric slope at that point, and check the graph to see the composite function alongside its derivative.
Recognizing When You Need the Chain Rule
The chain rule applies any time the "inside" of a function is anything other than plain x. A quick test: cover the outermost operation with your hand and look at what's left. If what's left is just x, ordinary rules suffice; if it's an expression like 3x², cos(x), or x+1, you have a composition and need the chain rule.
| Function | Outer f(u) | Inner g(x) | Derivative |
|---|---|---|---|
| sin(3x²) | sin(u) | 3x² | cos(3x²) · 6x |
| e^(x²+1) | eᵘ | x²+1 | e^(x²+1) · 2x |
| (2x+1)⁵ | u⁵ | 2x+1 | 5(2x+1)⁴ · 2 |
| ln(cos x) | ln(u) | cos(x) | (1/cos x)(−sin x) = −tan(x) |
| √(x²+9) | √u | x²+9 | 2x / (2√(x²+9)) = x/√(x²+9) |
Worked Example
Differentiate f(x) = sin(3x²). The outer function is sin(u), whose derivative is cos(u); the inner function is g(x) = 3x², whose derivative is 6x. Applying the chain rule:
f'(x) = cos(3x²) · 6x = 6x·cos(3x²)
Notice the two distinct pieces: cos(3x²) is the outer derivative with the inner function left intact inside it (a very common mistake is differentiating the inner function inside the cosine too), and 6x is the inner derivative multiplied on afterward.
Common Mistakes to Avoid
- Dropping the inner derivative entirely. Writing d/dx[sin(3x²)] = cos(3x²) misses the ×6x factor — this is the single most common chain rule error.
- Differentiating the inside while it sits inside the outer function. The inner function stays unchanged inside the outer derivative: cos(3x²), not cos(6x).
- Stopping one layer too early on nested compositions. For ln(cos(x)), you need the derivative of cos(x) too: the answer is (1/cos x)·(−sin x), requiring two applications of the rule.
- Confusing the chain rule with the product rule. sin(3x²) is a composition (chain rule); x²·sin(x) is a product (product rule — see the Product Rule Calculator). The structural difference: composition puts one function inside the other; a product places them side by side.
Real-World Applications of the Chain Rule
The chain rule is the mathematical machinery behind any situation where rates of change cascade through linked quantities. If the radius of an oil spill grows with time and the spill's area depends on its radius, then the rate the area grows with time is dA/dt = (dA/dr)·(dr/dt) — a direct chain rule statement, and the foundation of every related-rates problem in calculus courses. In physics, converting between reference frames or coordinate systems (polar to Cartesian, for instance) relies on the chain rule to translate derivatives taken with respect to one variable into derivatives with respect to another.
In machine learning, the backpropagation algorithm that trains every neural network is nothing more than the chain rule applied systematically through the network's layers: the loss depends on the output layer, which depends on the previous layer, and so on back through the network, and the chain rule multiplies those layer-by-layer derivatives together to determine how each weight deep in the network affects the final error. Without the chain rule, modern deep learning literally could not be trained.
Frequently Asked Questions
How do I know which function is the "outer" one?
The outer function is the last operation you'd perform if you evaluated the expression by hand. In sin(3x²), you'd square x, multiply by 3, and take sine last — so sine is the outer function and 3x² is the inner one.
Can the chain rule be applied more than once in one problem?
Yes — for deeply nested functions like e^(sin(x²)), the rule applies at every layer: derivative of eᵘ, times derivative of sin(v), times derivative of x². This calculator handles arbitrary nesting automatically, applying the rule recursively from the outermost layer inward.
Does the chain rule combine with the product and quotient rules?
Constantly — most realistic derivatives mix rules. For x²·sin(3x), you need the product rule for the overall product and the chain rule for the sin(3x) factor inside it. The general Derivative Calculator applies whichever combination of rules a function requires.
What does the chain rule look like in Leibniz notation?
If y = f(u) and u = g(x), then dy/dx = (dy/du)·(du/dx). Many students find this form more intuitive because the "du" terms appear to cancel like fractions — a useful mnemonic, though not a rigorous proof.
Why does my answer look different from the calculator's but might still be right?
Chain rule results can often be simplified in multiple equivalent ways — for instance, (1/cos x)·(−sin x) equals −tan(x). If your form differs, check equivalence by evaluating both at a couple of x-values, or simplify with trig identities before comparing.
Is there a chain rule for functions of several variables?
Yes — the multivariable chain rule extends the same idea: if z depends on x and y, and both x and y depend on t, then dz/dt = (∂z/∂x)(dx/dt) + (∂z/∂y)(dy/dt), summing a chain-rule product over every path the dependence flows through. It's built from the partial derivatives covered by the Partial Derivative Calculator, and it's the version of the rule that powers backpropagation in neural networks.