Skip to content
Calculus Solver

Chain Rule Calculator

Enter a composite function such as sin(x²) or (3x² + 1)⁵ to see the chain rule applied layer by layer. Each step names the outer function, the inner function and the derivative it multiplies by.

Your expression will be shown here as it will be read.

Solved entirely in your browser. Nothing you type is sent to a server or stored, and no account is needed.

Try an example

What is the chain rule?

The chain rule differentiates a composition: a function applied to the output of another function, such as sin(x²), where sin is applied to x². You differentiate the outer function while leaving the inside untouched, then multiply by the derivative of the inside.

In Leibniz notation, if y depends on u and u depends on x, the rates multiply: if y changes 3 times as fast as u, and u changes 2 times as fast as x, then y changes 6 times as fast as x.

ddx f(g(x))=f′(g(x))⋅g′(x)ordydx=dydu⋅dudx\frac{d}{dx}\,f\big(g(x)\big) = f'\big(g(x)\big)\cdot g'(x) \qquad\text{or}\qquad \frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx}

Common chain rule patterns

Most chain rule problems are one of these patterns, sometimes nested inside each other.

  • General power rule

    ddx[g(x)n]=n g(x)n−1g′(x)\frac{d}{dx}\big[g(x)^{n}\big] = n\,g(x)^{n-1}g'(x)

    For powers and roots of an expression, such as (3x + 1)⁴ or √(x² + 1).

  • Exponential

    ddx eg(x)=eg(x) g′(x)\frac{d}{dx}\,e^{g(x)} = e^{g(x)}\,g'(x)

    e to any power is unchanged, then multiplied by the derivative of the exponent.

  • Natural logarithm

    ddxln⁡g(x)=g′(x)g(x)\frac{d}{dx}\ln g(x) = \frac{g'(x)}{g(x)}

    The derivative of the inside, divided by the inside.

  • Trigonometric

    ddxsin⁡g(x)=cos⁡g(x)⋅g′(x)\frac{d}{dx}\sin g(x) = \cos g(x)\cdot g'(x)

    The same pattern holds for cos, tan and the others.

  • Nested chains

    ddx f(g(h(x)))=f′(g(h(x)))⋅g′(h(x))⋅h′(x)\frac{d}{dx}\,f\Big(g\big(h(x)\big)\Big) = f'\big(g(h(x))\big)\cdot g'\big(h(x)\big)\cdot h'(x)

    Work from the outside in, one layer at a time, multiplying as you go.

How this calculator works

The calculator reads your expression as a tree and works from the outermost operation inward. Whenever a function is applied to something other than the plain variable, it applies the chain rule and records the step, naming the inner function u.

The derivative of the inner function becomes its own step, so nested chains appear as a sequence of layers, indented to show the nesting. Products and quotients that contain compositions show the product or quotient rule first, with the chain rule steps inside.

For the full details, including how answers are verified, see how the solver works.

Worked examples

Work through these by hand first, then enter them above to compare each step.

Example 1

General power rule

ddx(3x2+1)5\frac{d}{dx}\left(3x^{2} + 1\right)^{5}
  1. Outer: u⁵, inner: u = 3x² + 1 with u′ = 6x.

    5(3x2+1)4⋅6x5\left(3x^{2} + 1\right)^{4}\cdot 6x

Answer

30x(3x2+1)430x\left(3x^{2} + 1\right)^{4}

Example 2

Exponential of a trig function

ddx esin⁡x\frac{d}{dx}\,e^{\sin x}
  1. Outer: eᵘ, inner: u = sin x with u′ = cos x.

    esin⁡x⋅cos⁡xe^{\sin x}\cdot\cos x

Answer

cos⁡x esin⁡x\cos x\,e^{\sin x}

Example 3

Square root of a polynomial

ddxx3+2x\frac{d}{dx}\sqrt{x^{3} + 2x}
  1. Rewrite as (x³ + 2x)^(1/2). Outer: u^(1/2), inner u′ = 3x² + 2.

    12(x3+2x)−1/2⋅(3x2+2)\frac{1}{2}\left(x^{3} + 2x\right)^{-1/2}\cdot\left(3x^{2} + 2\right)

Answer

3x2+22x3+2x\frac{3x^{2} + 2}{2\sqrt{x^{3} + 2x}}

Example 4

Three layers

ddxsin⁡3(2x)\frac{d}{dx}\sin^{3}(2x)
  1. sin³(2x) means (sin(2x))³. Outermost: u³, giving 3 sin²(2x).

    3sin⁡2(2x)⋅ddxsin⁡(2x)3\sin^{2}(2x)\cdot\frac{d}{dx}\sin(2x)
  2. Next layer: sin(v) with v = 2x, giving cos(2x)·2.

    3sin⁡2(2x)⋅cos⁡(2x)⋅23\sin^{2}(2x)\cdot\cos(2x)\cdot 2

Answer

6sin⁡2(2x)cos⁡(2x)6\sin^{2}(2x)\cos(2x)

Example 5

Product rule with a chain inside

ddx[x2cos⁡(3x)]\frac{d}{dx}\Big[x^{2}\cos(3x)\Big]
  1. Product rule first; the chain rule gives (cos 3x)′ = −3 sin 3x.

    2xcos⁡(3x)+x2⋅(−3sin⁡(3x))2x\cos(3x) + x^{2}\cdot\big(-3\sin(3x)\big)

Answer

2xcos⁡(3x)−3x2sin⁡(3x)2x\cos(3x) - 3x^{2}\sin(3x)

Example 6

Tangent of an exponential

ddxtan⁡(ex)\frac{d}{dx}\tan\left(e^{x}\right)
  1. Outer: tan u with derivative sec²u; inner: u = eˣ with u′ = eˣ.

    sec⁡2(ex)⋅ex\sec^{2}\left(e^{x}\right)\cdot e^{x}

Answer

exsec⁡2(ex)e^{x}\sec^{2}\left(e^{x}\right)

Common mistakes

  • Forgetting the inner derivative

    d/dx[(3x² + 1)⁵] is not 5(3x² + 1)⁴. The factor 6x from the inside is what makes it the chain rule.

  • Differentiating the inside too early

    d/dx[sin(x²)] is cos(x²)·2x, not cos(2x). The outer derivative keeps the original inside.

  • Stopping after two layers

    In sin³(2x) there are three layers: the cube, the sine and the 2x. Each contributes a factor.

  • Confusing sin²x with sin(x²)

    sin²x = (sin x)² has outer function u², while sin(x²) has outer function sin u. Their derivatives are completely different.

Limitations

  • This page uses the general derivative engine, so products, quotients and other rules appear alongside the chain rule when the function needs them.
  • Long nested expressions can produce many steps; very long step lists are shortened, but the final answer still includes every step.
  • For compositions of functions of several variables (the multivariable chain rule), use the partial derivative calculator on each piece.

Frequently asked questions

When do you use the chain rule?

Whenever a function is applied to something other than plain x: sin(3x), e^(x²), (x² + 1)⁵, ln(cos x). If the input to a function is itself an expression, you need the chain rule.

What is the formula for the chain rule?

d/dx f(g(x)) = f′(g(x))·g′(x). In Leibniz form, dy/dx = dy/du·du/dx, where u is the inner function.

How do you use the chain rule more than once?

Work from the outside in. Differentiate the outermost function, keep everything inside it unchanged, multiply by the derivative of the next layer, and repeat until you reach x.

Is the chain rule the same as the product rule?

No. The product rule is for two functions multiplied together, like x²·sin x. The chain rule is for one function inside another, like sin(x²). Many problems need both.

Next step

Pick one of the worked examples, solve it on paper, then enter it in the calculator and compare your steps with each rule shown. Spotting where your work differs is the fastest way to improve.

Back to the calculator