Math concepts

Chain Rule Examples: Nested Functions Explained Step by Step

October 8, 20269 min read
Chain Rule Examples: Nested Functions Explained Step by Step

Differentiate (2x+3)5(2x+3)^5. If you apply the ordinary power rule as though the parentheses contained only xx, you get 5(2x+3)45(2x+3)^4. The shape looks right, but a factor of two is missing. The expression inside the parentheses changes twice as fast as xx, and the derivative has to carry that change.

That missing factor is the point of the chain rule. This lesson works through original chain rule examples, from one inner function to three nested layers. For the broader meaning of a derivative, start with our derivative guide. Here we will focus on recognizing the layers, differentiating them, and checking the result.

Spot the inner and outer functions

A composition feeds the output of one function into another. In y=(2x+3)5y=(2x+3)^5, first calculate 2x+32x+3, then raise the result to the fifth power. Write g(x)=2x+3g(x)=2x+3 for the inner function and f(u)=u5f(u)=u^5 for the outer function. Then y=f(g(x))y=f(g(x)).

The order of evaluation and the order of differentiation run in opposite directions. To evaluate, move from the inside out. To differentiate, start with the outside operation, keep its input unchanged, and then multiply by the derivative of that input. OpenStax states the rule this way for differentiable compositions in its chain rule chapter:

ddxf(g(x))=f′(g(x))g′(x)\frac{d}{dx}f(g(x))=f'(g(x))g'(x)

The derivative of the outer function is evaluated at g(x)g(x), not at g′(x)g'(x). The inner derivative is a separate factor. If either layer is not differentiable at the relevant point, this formula cannot simply be applied there.

Try naming the layers before touching a rule. In sin⁡(4x2−1)\sin(4x^2-1), the outer operation is sine and the inner expression is 4x2−14x^2-1. In 1+x4\sqrt{1+x^4}, the outer operation is square root and the inner expression is 1+x41+x^4. In x2+3xx^2+3x, the top-level operation is addition; differentiate the terms separately. Not every set of parentheses announces a chain rule.

If the idea of feeding one function into another is new, composite functions covers evaluation and domain before differentiation. Functions themselves are the starting point if input and output notation is still unfamiliar.

Use the same four steps every time

The method does not change with the size of the expression:

  1. Name the immediate inner expression. For h(x)=(3x2−2)4h(x)=(3x^2-2)^4, use u=3x2−2u=3x^2-2.
  2. Differentiate the outside while leaving uu in place. Since the outside is u4u^4, its derivative is 4u34u^3.
  3. Differentiate the inside. Here du/dx=6xdu/dx=6x.
  4. Multiply and restore the expression. The result is h′(x)=4(3x2−2)3(6x)=24x(3x2−2)3h'(x)=4(3x^2-2)^3(6x)=24x(3x^2-2)^3.

Do not expand the fourth power unless a later calculation requires it. The factored answer shows where each piece came from: 4(3x2−2)34(3x^2-2)^3 belongs to the outer power, while 6x6x belongs to the inner quadratic. Expanding early makes a missing factor harder to see.

For three layers, repeat the same action. Differentiate the outermost layer, multiply by the derivative of the next layer, then multiply by the derivative of the deepest one. OpenStax develops that repeated use of the chain rule in the same chapter. There is no new rule to memorize.

Three complete worked examples

A power of a linear expression. Return to p(x)=(2x+3)5p(x)=(2x+3)^5. The outer derivative is 5(2x+3)45(2x+3)^4 and the inner derivative is 22. Therefore:

p′(x)=5(2x+3)4(2)=10(2x+3)4p'(x)=5(2x+3)^4(2)=10(2x+3)^4

Check at x=0x=0 without trusting the symbolic answer. The original function has p(0)=35=243p(0)=3^5=243. Expanding only the first-order term in (3+2x)5(3+2x)^5 gives 243+5(34)(2x)+⋯=243+810x+⋯243+5(3^4)(2x)+\cdots=243+810x+\cdots, so the slope at zero is 810810. Our derivative gives 10(3)4=81010(3)^4=810. The version without the inner factor gives 405405 and fails this check.

A trigonometric composition. Let q(x)=sin⁡(4x2−1)q(x)=\sin(4x^2-1), with angles in radians. The outer derivative of sine is cosine evaluated at the same input, and the inner derivative of 4x2−14x^2-1 is 8x8x:

q′(x)=cos⁡(4x2−1)(8x)=8xcos⁡(4x2−1)q'(x)=\cos(4x^2-1)(8x)=8x\cos(4x^2-1)

At x=0x=0 the inner derivative is zero, so q′(0)=0q'(0)=0. That makes sense as a local symmetry check: q(x)q(x) depends on x2x^2, so it takes the same value at xx and −x-x. At x=1x=1, the slope is 8cos⁡(3)8\cos(3), not cos⁡(8)\cos(8). The cosine receives the unchanged inner expression, not its derivative.

Three nested layers. Take r(x)=[sin⁡(2x2+1)]3r(x)=\left[\sin(2x^2+1)\right]^3. The layers, from outside inward, are a cube, sine, and 2x2+12x^2+1. Differentiate each in that order:

r′(x)=3[sin⁡(2x2+1)]2⋅cos⁡(2x2+1)⋅4x=12xsin⁡2(2x2+1)cos⁡(2x2+1).\begin{aligned} r'(x)&=3\left[\sin(2x^2+1)\right]^2 \cdot\cos(2x^2+1)\cdot 4x\\ &=12x\sin^2(2x^2+1)\cos(2x^2+1). \end{aligned}

There are three factors because three changes are linked. The cube contributes 3sin⁡2(⋅)3\sin^2(\cdot), sine contributes cosine, and the quadratic contributes 4x4x. Again, r′(0)=0r'(0)=0, consistent with the even function r(x)r(x). This does not prove the whole derivative, but it quickly catches some algebra errors.

Decide when another rule is needed

Find the top-level operation first. In a(x)=x(2x+3)5a(x)=x(2x+3)^5, two variable expressions are multiplied. Begin with the product rule, then use the chain rule on the powered factor:

a′(x)=1⋅(2x+3)5+x⋅5(2x+3)4⋅2=(2x+3)5+10x(2x+3)4=(2x+3)4(12x+3).\begin{aligned} a'(x)&=1\cdot(2x+3)^5+x\cdot 5(2x+3)^4\cdot2\\ &=(2x+3)^5+10x(2x+3)^4\\ &=(2x+3)^4(12x+3). \end{aligned}

By contrast, b(x)=(2x+3)5b(x)=(2x+3)^5 has no top-level product, so the chain rule alone gives 10(2x+3)410(2x+3)^4. The two expressions differ by a factor of xx outside the power, and that factor changes the governing rule.

A quotient can hide the same choice. For c(x)=1/(2x+3)2c(x)=1/(2x+3)^2, rewrite it as (2x+3)−2(2x+3)^{-2}. Its top-level operation is a power, so:

c′(x)=−2(2x+3)−3(2)=−4(2x+3)3,x≠−32.c'(x)=-2(2x+3)^{-3}(2)=-\frac{4}{(2x+3)^3},\qquad x\ne-\frac32.

The quotient rule would also work, but rewriting makes the composition plain. If both numerator and denominator depend on xx, use the quotient rule at the top and inspect each part for a chain rule. OpenStax treats these combinations together in its chain rule section.

Repair three common wrong answers

Missing the inner factor. For (5x−1)4(5x-1)^4, the answer 4(5x−1)34(5x-1)^3 leaves out the derivative 55. Write the two pieces before multiplying: 4(5x−1)3×5=20(5x−1)34(5x-1)^3\times5=20(5x-1)^3.

Changing the outer function's input. For cos⁡(x2+2)\cos(x^2+2), the answer −sin⁡(2x)⋅2x-\sin(2x)\cdot2x puts the derivative of the inside into sine. The correct derivative is −sin⁡(x2+2)⋅2x-\sin(x^2+2)\cdot2x. Differentiate the outside at the unchanged inside, then attach the inside's derivative.

Losing parentheses. For (x2+3)3(x^2+3)^3, 3x2+32(2x)3x^2+3^2(2x) is not the chain rule. The entire inner expression stays inside the squared power: 3(x2+3)2(2x)=6x(x2+3)23(x^2+3)^2(2x)=6x(x^2+3)^2. Write large parentheses around the inside until the final line.

One useful check is to evaluate both the original function and your derivative at a simple point. An easy numerical value will not prove a derivative for every xx, but a disagreement can disprove a tempting wrong answer quickly.

Three practice problems with full solutions

Try each before reading its solution. Mark the layers, then write one factor per layer.

1. Differentiate s(x)=(7−3x)4s(x)=(7-3x)^4. The outer derivative is 4(7−3x)34(7-3x)^3. The inner derivative is −3-3, so:

s′(x)=4(7−3x)3(−3)=−12(7−3x)3.s'(x)=4(7-3x)^3(-3)=-12(7-3x)^3.

The negative sign is the quick check: near a point where 7−3x7-3x is positive, increasing xx reduces that inner quantity and therefore reduces its fourth power.

2. Differentiate t(x)=cos⁡(3x2+x)t(x)=\cos(3x^2+x). The outer cosine becomes negative sine; the inner polynomial becomes 6x+16x+1:

t′(x)=−sin⁡(3x2+x)(6x+1).t'(x)=-\sin(3x^2+x)(6x+1).

At x=0x=0, this gives zero because sin⁡(0)=0\sin(0)=0. Do not infer that the inner derivative is zero there; it equals one. Keeping the two factors separate tells you why the product vanishes.

3. Differentiate v(x)=(1+sin⁡x)3v(x)=(1+\sin x)^3. The outer power contributes 3(1+sin⁡x)23(1+\sin x)^2; the inside derivative is cos⁡x\cos x:

v′(x)=3(1+sin⁡x)2cos⁡x.v'(x)=3(1+\sin x)^2\cos x.

Here the inside contains sine, but the top-level operation is still the cube. Work from the outside inward. At x=0x=0, the derivative is 3(1)2(1)=33(1)^2(1)=3.

Once these are comfortable, Math Zen's derivatives practice includes a chain-rule skill among its calculus exercises. Return to an example you missed and explain which factor was absent before trying the next one. The habit to keep is simple: name the outer operation, preserve its input, and multiply by the derivative of that input.

Frequently asked questions

Is the chain rule the same as the power rule?

No. The power rule differentiates xnx^n. The chain rule lets you use it on a power of an inner expression: the derivative of [g(x)]n[g(x)]^n is n[g(x)]n−1g′(x)n[g(x)]^{n-1}g'(x). If g(x)=xg(x)=x, its derivative is one and the familiar power rule appears.

Can I use the chain rule for a square root?

Yes. Rewrite 1+x4\sqrt{1+x^4} as (1+x4)1/2(1+x^4)^{1/2}. The outer derivative is 12(1+x4)−1/2\tfrac12(1+x^4)^{-1/2} and the inner derivative is 4x34x^3, giving 2x3/1+x42x^3/\sqrt{1+x^4}.

Why do nested functions produce multiple factors?

Each layer responds to the change in the layer inside it. In [sin⁡(2x2+1)]3[\sin(2x^2+1)]^3, a change in xx changes the quadratic, which changes sine, which changes the cube. The three derivative factors describe those three linked changes.

Put This Into Practice