When do you need the chain rule?
Use the chain rule whenever the thing you are differentiating is not plain \(x\), but a function of \(x\). A quick test: if you have to write a bracket (or could write one), you are probably looking at a function inside a function.
Every composite function has an outer function (the outside) and an inner function (the inside):
| Function | Outer function | Inner function |
|---|---|---|
| \((3x+1)^5\) | \((\square)^5\) | \(3x+1\) |
| \(\sin(x^2)\) | \(\sin(\square)\) | \(x^2\) |
| \(e^{5x}\) | \(e^{\square}\) | \(5x\) |
| \(\sqrt{1+x^2}\) | \(\sqrt{\square}\) | \(1+x^2\) |
| \(\log(\cos x)\) | \(\log(\square)\) | \(\cos x\) |
| \(\sin^2 x = (\sin x)^2\) | \((\square)^2\) | \(\sin x\) |
Cover the inside with your finger. Whatever you can still see is the outer function.
The idea in one picture
Rates multiply along a chain. Suppose \(u\) changes 2 times as fast as \(x\), and \(y\) changes 3 times as fast as \(u\). Then \(y\) must change \(3 \times 2 = 6\) times as fast as \(x\).
You already do this in real life. A car uses 0.08 litres of petrol per km and is travelling at 50 km per hour. Petrol used per hour \(= 0.08 \times 50 = 4\) litres per hour. You multiplied two rates to get a third, which is exactly what the chain rule does:
\[\frac{d(\text{petrol})}{d(\text{time})} = \frac{d(\text{petrol})}{d(\text{distance})} \times \frac{d(\text{distance})}{d(\text{time})}\]
The chain rule formula
Function notation
If \(y = f\big(g(x)\big)\), then \[\frac{dy}{dx} = f'\big(g(x)\big)\cdot g'(x)\]
Leibniz notation
If \(y = f(u)\) and \(u = g(x)\), then \[\frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx}\]
Longer chains
If \(y = f(u)\), \(u = g(v)\) and \(v = h(x)\), then \[\frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dv}\cdot\frac{dv}{dx}\]
The Leibniz form is the easiest to remember because the \(du\)'s look as if they cancel. They don't really cancel, because \(\dfrac{dy}{dx}\) is not an ordinary fraction, but it is a reliable way to remember the rule.
The 3-step method
- Name the inside. Put \(u\) = the inner function.
- Differentiate the outside with respect to \(u\). Treat \(u\) like a plain variable and don't touch what is inside it.
- Multiply by \(\dfrac{du}{dx}\), then write \(u\) back in terms of \(x\).
For example, for \(y = (x^2+5)^7\): put \(u = x^2+5\), so \(y = u^7\). Then \(\dfrac{dy}{du} = 7u^6\) and \(\dfrac{du}{dx} = 2x\), so
\[\frac{dy}{dx} = 7(x^2+5)^6 \cdot 2x = 14x\,(x^2+5)^6\]
Once you are comfortable, stop writing \(u\). Say it in your head instead: "outside first, inside stays the same, then multiply by the derivative of the inside."
Standard results with the chain rule
Every standard derivative has a chain rule version. Learn these in the \(u\) form and most Class 12 questions become one-liners. Here \(u\) is any function of \(x\).
| Function | Derivative with respect to \(x\) |
|---|---|
| \(u^n\) | \(n\,u^{n-1}\,\dfrac{du}{dx}\) |
| \(\sqrt{u}\) | \(\dfrac{1}{2\sqrt{u}}\,\dfrac{du}{dx}\) |
| \(\sin u\) | \(\cos u\,\dfrac{du}{dx}\) |
| \(\cos u\) | \(-\sin u\,\dfrac{du}{dx}\) |
| \(\tan u\) | \(\sec^2 u\,\dfrac{du}{dx}\) |
| \(e^{u}\) | \(e^{u}\,\dfrac{du}{dx}\) |
| \(a^{u}\) | \(a^{u}\log a\,\dfrac{du}{dx}\) |
| \(\log u\) | \(\dfrac{1}{u}\,\dfrac{du}{dx}\) |
| \(\sin^{-1} u\) | \(\dfrac{1}{\sqrt{1-u^2}}\,\dfrac{du}{dx}\) |
| \(\tan^{-1} u\) | \(\dfrac{1}{1+u^2}\,\dfrac{du}{dx}\) |
In Indian textbooks, \(\log x\) in calculus means the natural logarithm (base \(e\)), also written \(\ln x\).
Solved examples
Eight examples, from warm-up to board-exam level. Try each one yourself first, then check the working.
Example 1: A power of a linear function
EasyDifferentiate \(y = (3x+1)^5\) with respect to \(x\).
- Inside: \(u = 3x+1\), so \(y = u^5\).
- \(\dfrac{dy}{du} = 5u^4\) and \(\dfrac{du}{dx} = 3\).
- \(\dfrac{dy}{dx} = 5u^4 \cdot 3 = 15(3x+1)^4\).
Answer\(\dfrac{dy}{dx} = 15(3x+1)^4\)
Example 2: A function of \(x^2\)
EasyDifferentiate \(y = \sin(x^2)\).
- Outside: \(\sin(\square)\). Inside: \(x^2\).
- Differentiate the outside and leave the inside alone: \(\cos(x^2)\).
- Multiply by the derivative of the inside, \(2x\).
Answer\(\dfrac{dy}{dx} = 2x\cos(x^2)\)
Example 3: A square root
EasyDifferentiate \(y = \sqrt{1+x^2}\).
- Write the root as a power: \(y = (1+x^2)^{1/2}\).
- \(\dfrac{dy}{dx} = \dfrac{1}{2}(1+x^2)^{-1/2} \cdot 2x\).
- Simplify.
Answer\(\dfrac{dy}{dx} = \dfrac{x}{\sqrt{1+x^2}}\)
Example 4: Log of a trigonometric function
MediumDifferentiate \(y = \log(\sin x)\).
- Outside: \(\log(\square)\). Inside: \(\sin x\).
- \(\dfrac{dy}{dx} = \dfrac{1}{\sin x} \cdot \cos x\).
- \(\dfrac{\cos x}{\sin x} = \cot x\).
Answer\(\dfrac{dy}{dx} = \cot x\)
Example 5: Three layers
MediumDifferentiate \(y = \sin^3(5x)\).
- Rewrite it as \(y = \big[\sin(5x)\big]^3\). There are three layers: cube, then sine, then \(5x\).
- Peel from the outside in: \(3\big[\sin(5x)\big]^2 \times \cos(5x) \times 5\).
- Tidy up the constants.
Answer\(\dfrac{dy}{dx} = 15\sin^2(5x)\cos(5x)\)
Example 6: Chain rule inside the product rule
MediumDifferentiate \(y = x^2 e^{3x}\).
- This is a product of \(x^2\) and \(e^{3x}\), so use the product rule, with the chain rule for \(e^{3x}\).
- Chain rule: \(\dfrac{d}{dx}\big(e^{3x}\big) = e^{3x} \cdot 3 = 3e^{3x}\).
- Product rule: \(\dfrac{dy}{dx} = 2x \cdot e^{3x} + x^2 \cdot 3e^{3x}\).
- Take out the common factor \(x e^{3x}\).
Answer\(\dfrac{dy}{dx} = x e^{3x}(2+3x)\)
Example 7: A classic board question
Exam levelDifferentiate \(y = \log(\sec x + \tan x)\).
- Outside: \(\log(\square)\). Inside: \(\sec x + \tan x\).
- \(\dfrac{dy}{dx} = \dfrac{1}{\sec x + \tan x} \cdot \big(\sec x \tan x + \sec^2 x\big)\).
- Take \(\sec x\) common in the bracket: \(\dfrac{\sec x\,(\tan x + \sec x)}{\sec x + \tan x}\).
- The brackets cancel.
Answer\(\dfrac{dy}{dx} = \sec x\)
Example 8: Simplify first, then differentiate
Exam levelDifferentiate \(y = \log\sqrt{\dfrac{1+x}{1-x}}\).
- Use log laws before differentiating: \(y = \dfrac{1}{2}\big[\log(1+x) - \log(1-x)\big]\).
- Chain rule on each term (the inside of the second log has derivative \(-1\)): \[\frac{dy}{dx} = \frac{1}{2}\left[\frac{1}{1+x} - \frac{1}{1-x}\cdot(-1)\right] = \frac{1}{2}\left[\frac{1}{1+x} + \frac{1}{1-x}\right]\]
- Combine the fractions: \(\dfrac{1}{2}\cdot\dfrac{(1-x)+(1+x)}{(1+x)(1-x)} = \dfrac{1}{2}\cdot\dfrac{2}{1-x^2}\).
Answer\(\dfrac{dy}{dx} = \dfrac{1}{1-x^2}\)
Whenever you see the log of a product, quotient, power or root, expand it with log laws first. The differentiation becomes much shorter and there are fewer places to make a mistake.
Common mistakes
1. Forgetting the derivative of the inside
2. Changing the inside while differentiating the outside
The inside stays \(x^2\). Its derivative, \(2x\), goes outside as a multiplier.
3. Mixing up \(\sin^2 x\) and \(\sin(x^2)\)
4. Stopping one layer too early
Count the layers before you start, and make sure every layer contributes a factor.
5. Using degrees instead of radians
Calculus formulas assume radians. Convert first: \(x^\circ = \dfrac{\pi x}{180}\) radians, and the chain rule brings out the factor \(\dfrac{\pi}{180}\).
How it's asked in exams
The chain rule is rarely a big question on its own, but it is inside almost every differentiation question you will write.
- Class 12 boards (HSC, CBSE, ISC): direct "differentiate with respect to \(x\)" questions on composite functions, and a step inside inverse trigonometric functions, logarithmic, implicit and parametric differentiation, and second derivatives. Questions of the form "If \(y = \dots\), show that \(\dots\)" almost always need it.
- Diploma (Applied Maths): used throughout derivatives, and in applications such as tangents and normals, and maxima and minima.
- Engineering Maths and BSc: assumed knowledge. It extends to functions of several variables (the chain rule for partial derivatives) and is used constantly in successive differentiation.
Board papers are usually marked step by step. Write the chain rule step clearly, for example "\(\times \dfrac{d}{dx}(x^2)\)", before you simplify. If you slip in the arithmetic later, the method can still earn you marks.
Practice questions
Differentiate each function with respect to \(x\). Try it on paper before you open the answer.
Q1\(y = (2x^2-3)^4\)
\(\dfrac{dy}{dx} = 4(2x^2-3)^3 \cdot 4x = 16x\,(2x^2-3)^3\)
Q2\(y = \cos(5x+2)\)
\(\dfrac{dy}{dx} = -5\sin(5x+2)\)
Q3\(y = e^{x^2}\)
\(\dfrac{dy}{dx} = 2x\,e^{x^2}\)
Q4\(y = \tan\sqrt{x}\)
\(\dfrac{dy}{dx} = \sec^2\sqrt{x}\cdot\dfrac{1}{2\sqrt{x}} = \dfrac{\sec^2\sqrt{x}}{2\sqrt{x}}\)
Q5\(y = \sqrt{\sin x}\)
\(\dfrac{dy}{dx} = \dfrac{\cos x}{2\sqrt{\sin x}}\)
Q6\(y = \log(\log x)\)
\(\dfrac{dy}{dx} = \dfrac{1}{\log x}\cdot\dfrac{1}{x} = \dfrac{1}{x\log x}\)
Q7\(y = \sin^{-1}(2x)\)
\(\dfrac{dy}{dx} = \dfrac{1}{\sqrt{1-(2x)^2}}\cdot 2 = \dfrac{2}{\sqrt{1-4x^2}}\)
Q8\(y = \cos^2(3x)\)
\(\dfrac{dy}{dx} = 2\cos(3x)\cdot\big(-\sin(3x)\big)\cdot 3 = -6\sin(3x)\cos(3x) = -3\sin(6x)\)
Q9\(y = \log\left(x+\sqrt{x^2+1}\right)\)
The inside is \(x+\sqrt{x^2+1}\), and its derivative is \(1 + \dfrac{x}{\sqrt{x^2+1}} = \dfrac{\sqrt{x^2+1}+x}{\sqrt{x^2+1}}\). So
\[\frac{dy}{dx} = \frac{1}{x+\sqrt{x^2+1}}\cdot\frac{\sqrt{x^2+1}+x}{\sqrt{x^2+1}} = \frac{1}{\sqrt{x^2+1}}\]
Q10Board-style challenge. If \(y = e^{m\sin^{-1}x}\), show that \((1-x^2)\dfrac{d^2y}{dx^2} - x\dfrac{dy}{dx} - m^2y = 0\).
Differentiate once using the chain rule: \[\frac{dy}{dx} = e^{m\sin^{-1}x}\cdot\frac{m}{\sqrt{1-x^2}} = \frac{my}{\sqrt{1-x^2}}\]
So \(\sqrt{1-x^2}\,\dfrac{dy}{dx} = my\). Differentiate again, using the product rule on the left and the chain rule for \(\sqrt{1-x^2}\): \[\sqrt{1-x^2}\,\frac{d^2y}{dx^2} - \frac{x}{\sqrt{1-x^2}}\,\frac{dy}{dx} = m\frac{dy}{dx}\]
Multiply through by \(\sqrt{1-x^2}\) and use \(\sqrt{1-x^2}\,\dfrac{dy}{dx} = my\): \[(1-x^2)\frac{d^2y}{dx^2} - x\frac{dy}{dx} = m\cdot my = m^2y\]
Hence \((1-x^2)\dfrac{d^2y}{dx^2} - x\dfrac{dy}{dx} - m^2y = 0\).
Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.
Frequently asked questions
What is the chain rule in simple words?
It is the rule for differentiating a function inside another function: differentiate the outside while leaving the inside alone, then multiply by the derivative of the inside.
How do I know when to use the chain rule?
Use it when a function is applied to something other than plain \(x\), such as \(\sin(3x)\), \(e^{x^2}\) or \((x^2+1)^5\). For \(\sin x\) or \(x^5\) you don't need it, because the derivative of the inside (\(x\)) is just 1.
What is the difference between the chain rule and the product rule?
The product rule is for two functions multiplied together, \(f(x)\cdot g(x)\). The chain rule is for one function inside another, \(f\big(g(x)\big)\). Many questions need both; see Example 6.
Which class is the chain rule taught in?
Class 12: in CBSE it is part of the Continuity and Differentiability chapter, and in the Maharashtra HSC syllabus it is in the Differentiation chapter. Diploma, Engineering and BSc students use it from their first semester.
Is dy/dx really a fraction?
Not exactly. It is a limit, not a division. But in the chain rule it behaves like one, which is why \(\dfrac{dy}{du}\cdot\dfrac{du}{dx} = \dfrac{dy}{dx}\) is such a handy way to remember the rule.