The Chain Rule Explained: How to Differentiate a Function Inside a Function

Learn the chain rule in calculus: what it says, why it works, and how to apply it step by step to composite functions, with worked examples.

Share on Linkedin Share on WhatsApp

Estimated reading time: 7 minutes

Article image The Chain Rule Explained: How to Differentiate a Function Inside a Function

Differentiating simple functions like x² or sin(x) is straightforward. But what about sin(x²), or (3x + 1)⁵? These are composite functions: one function tucked inside another. To differentiate them, calculus gives us a powerful tool called the chain rule.

What is a composite function?

A composite function applies one function to the output of another. If f(u) = u⁵ and u = g(x) = 3x + 1, then the composite is f(g(x)) = (3x + 1)⁵. You can think of it as a two-step machine: first compute the inside (3x + 1), then apply the outside (raise to the fifth power).

Spotting this structure is the most important skill in using the chain rule. A quick test: if you were evaluating the expression with a calculator, which operation would you do last? That is the outside function. Whatever it is applied to is the inside.

The chain rule in one sentence

The derivative of a composite function is the derivative of the outside function (evaluated at the inside) multiplied by the derivative of the inside function.

In symbols: if y = f(g(x)), then

dy/dx = f′(g(x)) · g′(x)

In Leibniz notation, with u = g(x), this looks like fractions cancelling: dy/dx = (dy/du) · (du/dx). The “cancelling” is just a memory aid, not a literal proof, but it captures the idea well: the rate of change of y with respect to x is the product of two chained rates.

Why does it work? A rate-of-change intuition

Imagine three gears connected in a line. If gear A turns twice as fast as gear B, and gear B turns three times as fast as gear C, then gear A turns 2 × 3 = 6 times as fast as gear C. Rates multiply along the chain.

The chain rule says the same about derivatives. When x changes slightly, u changes by about g′(x) times that amount. Then y changes by about f′(u) times the change in u. Multiply those two factors and you get the overall rate at which y responds to x.

A step-by-step method

  1. Identify the outside and inside functions. Write u = inside.
  2. Differentiate the outside function with respect to u, leaving the inside untouched for now.
  3. Differentiate the inside function with respect to x.
  4. Multiply the two results and substitute u back in terms of x.

Worked examples

Example 1: y = (3x + 1)⁵. The outside is u⁵ and the inside is u = 3x + 1. The derivative of the outside is 5u⁴, and the derivative of the inside is 3. Multiply: dy/dx = 5(3x + 1)⁴ · 3 = 15(3x + 1)⁴.

Example 2: y = sin(x²). The outside is sin(u) and the inside is u = x². The derivative of sin(u) is cos(u), and the derivative of x² is 2x. So dy/dx = cos(x²) · 2x = 2x·cos(x²).

Example 3: y = e^(4x). The outside is e^u, whose derivative is e^u, and the inside is 4x, whose derivative is 4. So dy/dx = 4e^(4x).

Example 4: y = √(x² + 1). Rewrite as (x² + 1)^(1/2). The outside gives (1/2)u^(−1/2) and the inside gives 2x. So dy/dx = (1/2)(x² + 1)^(−1/2) · 2x = x / √(x² + 1).

Quick reference table

FunctionOutside / insideDerivative
(2x − 7)³u³ / 2x − 73(2x − 7)² · 2 = 6(2x − 7)²
cos(5x)cos u / 5x−sin(5x) · 5 = −5 sin(5x)
ln(x² + 3)ln u / x² + 3(1 / (x² + 3)) · 2x = 2x / (x² + 3)
e^(x²)e^u / x²e^(x²) · 2x

Chaining more than twice

Some functions have three or more layers, such as y = sin²(3x), which is (sin(3x))². Work from the outermost layer inward and multiply as you go: the derivative of u² is 2u, the derivative of sin(v) is cos(v), and the derivative of 3x is 3. The result is 2·sin(3x) · cos(3x) · 3 = 6 sin(3x) cos(3x). The more layers, the more factors in the product, but the process never changes.

Checking your answer

A good habit is to sanity-check a result before moving on. For y = (3x + 1)⁵, plug in x = 0: the function equals 1, and the derivative we found, 15(3·0 + 1)⁴, equals 15. You can confirm that value numerically by comparing y at x = 0 and at a tiny step such as x = 0.001, then dividing the change in y by the step. If the two numbers are close, your use of the rule is almost certainly correct. Graphing software can also help: plot the function and its derivative and check that the derivative is positive where the function rises and negative where it falls.

Common mistakes to avoid

  • Forgetting the inside derivative. Writing the derivative of sin(x²) as cos(x²) is the classic error. The factor 2x is missing.
  • Changing the inside while differentiating the outside. The inside stays exactly as it is until you multiply.
  • Confusing composition with multiplication. The expression x²·sin(x) is a product, so it needs the product rule, while sin(x²) is a composition, so it needs the chain rule. Some problems need both.
  • Dropping constants. In e^(4x), the factor 4 matters. Always multiply by the inside derivative, even when it looks trivial.

Where the chain rule shows up

The chain rule is not just a classroom exercise. It sits behind related rates problems in physics, such as how fast the area of a circle grows as its radius changes over time. It is also the mathematical engine of backpropagation in neural networks, where errors are passed backward through many layers of composed functions. Learning it well pays off far beyond a single calculus exam.

Conclusion

The chain rule boils down to a habit: find the layers, differentiate from the outside in, and multiply. With a few dozen practice problems, spotting the inside function becomes automatic. If you want guided practice with worked solutions, explore the calculus and math courses on Cursa, designed to build these skills step by step.

The Bronze Age Collapse: When an Entire Interconnected World Fell Apart

Around 1200 BCE several Mediterranean civilisations collapsed within decades. Here is what happened, the leading explanations, and why it still matters.

Correlation Is Not Causation: How to Read a Data Chart Without Being Fooled

Two lines moving together rarely prove one caused the other. Learn the traps behind correlation and how analysts test for real causal links.

Sample Size and Margin of Error: How a Survey of 1,000 People Represents Millions

Why polling 1,000 people can describe a whole country, what margin of error really means, and how bad sampling ruins good statistics.

The Silk Road: How a Network of Trade Routes Connected the Ancient World

The Silk Road was never one road, and silk was only part of the story. A clear look at the routes, the goods, the ideas and why the network faded.

Why Steel Ships Float: Buoyancy and Archimedes’ Principle Explained

Density, displacement and pressure explain why a steel ship floats while a steel bolt sinks. A clear introduction to buoyancy for beginners.

The Pythagorean Theorem: What It Is and How to Use It

Learn what the Pythagorean theorem is, why it works, and how to use this essential geometry rule to find the sides of right triangles.

What Is Stoicism? A Beginner’s Guide to the Ancient Philosophy

Discover the core ideas of Stoicism, the philosophers behind it, and practical ways to apply its wisdom to daily life.

Why Every World Map Is Wrong: Map Projections Explained

Every flat map distorts the round Earth. Learn what map projections trade away, why Greenland looks huge, and how to read maps critically.