Start the course

Derivatives

The chain rule explained, with step-by-step examples

7 min readUpdated

Quick answer

The chain rule finds the derivative of a function inside another function, f(g(x)): differentiate the outside function, leaving the inside unchanged, then multiply by the derivative of the inside. As a formula, ddxf(g(x))= f′(g(x))⋅g′(x). For example, ddx(3x+1)5= 5(3x+1)4⋅3.

Key points
  • Use the chain rule whenever a function is applied to something other than plain x: (3x+1)5, sin⁡(x2), e−2x, x2+9.
  • Outside derivative, inside unchanged, times inside derivative.
  • In Leibniz notation: dydx= dydu⋅dudx, where u is the inside.
  • The most common mistake is forgetting to multiply by the inside's derivative.

What kind of function needs the chain rule?

The power rule tells us ddxx5= 5x4, and we know ddxsin⁡x= cos⁡x. But what about (3x+1)5 or sin⁡(x2)? Here a function (the 5th power, or sine) is applied not to x but to another expression. A function built this way, by feeding the output of one function into another, is called a composite function.

Definition: composite function

The composite f(g(x)) applies g first and then f to the result. We call g the inside function and f the outside function.

To find the inside and outside, think about how you'd calculate the value for a particular x. For (3x+1)5 at x=2, you first work out 3(2)+1=7 (that's the inside), then raise it to the 5th power (that's the outside).

FunctionInside g(x)Outside f(u)
(3x+1)53x+1u5
sin⁡(x2)x2sin⁡u
e−2x−2xeu
x2+9x2+9u
sin2⁡x, meaning (sin⁡x)2sin⁡xu2

What is the chain rule formula?

The chain rule
ddxf(g(x))= f′(g(x))⋅g′(x). In Leibniz notation, with u=g(x) and y=f(u): dydx= dydu⋅dudx.
Why it works
  1. Rates of change multiply. If u changes 3 times as fast as x, and y changes 5 times as fast as u, then y changes 5×3=15 times as fast as x.
  2. dudx=g′(x) is how fast the inside changes as x changes.
  3. dydu=f′(u) is how fast the outside changes as its input u changes, measured at the current value u=g(x).
  4. Multiplying the two rates gives how fast y changes as x changes.

Think of gears: if the first gear turns the second 3 times as fast, and the second turns the third 5 times as fast, the third turns 15 times as fast as the first. Each link in the chain multiplies in its own rate.

How do you use the chain rule, step by step?

  1. Identify the inside and the outside.
  2. Differentiate the outside, leaving the inside exactly as it is.
  3. Multiply by the derivative of the inside.
  4. Simplify, and check whether the inside itself was a chain (if so, repeat).
Worked example: A power of a function

Differentiate y=(3x2+1)5.

  1. Inside: 3x2+1, with derivative 6x. Outside: u5, with derivative 5u4.
  2. Outside's derivative with the inside unchanged: 5(3x2+1)4.
  3. Multiply by the inside's derivative: 5(3x2+1)4⋅6x.
  4. Simplify: 30x(3x2+1)4.

Answer: y′=30x(3x2+1)4

Worked example: A square root

Differentiate y=x2+9.

  1. Rewrite as a power: y=(x2+9)1/2. Inside x2+9 (derivative 2x); outside u1/2 (derivative 12u−1/2).
  2. Outside's derivative, inside unchanged: 12(x2+9)−1/2.
  3. Times the inside's derivative: 12(x2+9)−1/2⋅2x.
  4. The 12 and the 2 cancel, and a negative power means dividing: y′= xx2+9.

Answer: y′= xx2+9

Worked example: An exponential and a trig function

Differentiate y=esin⁡x.

  1. Inside: sin⁡x, with derivative cos⁡x. Outside: eu, which is its own derivative.
  2. Outside's derivative, inside unchanged: esin⁡x.
  3. Times the inside's derivative: y′=esin⁡xcos⁡x.

Answer: y′= cos⁡xesin⁡x

Common mistake

Forgetting the inside's derivative. ddxsin⁡(x2) is not cos⁡(x2); it is cos⁡(x2)⋅2x. A quick check: if the inside isn't plain x, your answer should contain the inside's derivative as a factor.

What is the difference between sin²x and sin(x²)?

They are different functions, so they have different derivatives. In sin2⁡x=(sin⁡x)2 the sine is applied first and then the result is squared, so the outside is the square. In sin⁡(x2) the squaring happens first, so the outside is the sine.

FunctionOutside, insideDerivative
sin2⁡x=(sin⁡x)2u2, sin⁡x2sin⁡xcos⁡x
sin⁡(x2)sin⁡u, x22xcos⁡(x2)

How do you use the chain rule more than once?

When the inside is itself a composite, the chain has more links. Work from the outside in, multiplying by one derivative for each layer.

Worked example: Three links

Differentiate y= cos(x2+1).

  1. Layers from the outside in: cos⁡( ), then  , then x2+1.
  2. Derivative of the outside layer, everything inside unchanged: −sin(x2+1).
  3. Times the derivative of the middle layer, u→12u, with its inside unchanged: 12x2+1.
  4. Times the derivative of the innermost layer: 2x.
  5. Multiply and cancel the 2s: y′= −xsin(x2+1)x2+1.

Answer: y′= −xsin(x2+1)x2+1

How does the chain rule combine with the product rule?

Choose the first rule by the last operation. In x2e3x, the last step is multiplying, so start with the product rule; the chain rule appears when you differentiate the factor e3x.

Worked example: Product rule, then chain rule

Differentiate y=x2e3x.

  1. Product rule with f=x2 (f′=2x) and g=e3x.
  2. Chain rule for g: inside 3x with derivative 3, so g′= e3x⋅3= 3e3x.
  3. Product rule: y′= 2xe3x+x2⋅3e3x.
  4. Factor out the common xe3x: y′=xe3x(2+3x).

Answer: y′=xe3x(3x+2)

Tip

Some chain rule problems can be avoided with a rewrite: ln⁡(x5)=5ln⁡x, whose derivative is simply 5x. See derivatives of ex and ln⁡x. The chain rule is also what makes implicit differentiation and u-substitution work.

Learn it step by step

The full lessons in the course explain this from the ground up, with graphs, worked examples, and practice problems that each have a complete worked solution.

Open the lesson

Frequently asked questions

When do you use the chain rule?

Whenever a function is applied to an expression other than plain x, such as a power of a bracket, a trig function of 2x, or e to the power of something. If you'd compute the inside first and then apply another function, it's a chain.

What is the chain rule in simple terms?

Derivative of the outside, keeping the inside the same, times the derivative of the inside.

Do you need the chain rule for e^(2x)?

Yes: the inside is 2x, so ddxe2x= e2x⋅2= 2e2x.

Can the chain rule be used more than once in one problem?

Yes. A function with several layers, like cos⁡(x2+1), needs one derivative factor per layer, multiplied together.

Why is it called the chain rule?

Because a composite function is a chain of functions, each feeding the next, and the rule multiplies one rate of change for each link in the chain.