โ˜ฐ

Lesson 8: Chain Rule โ€“ Multiple Layers & Nested Functions

1. Chain Rule for Multiple Layers

If \(y = f(g(h(x)))\), differentiate step by step:

\[ \frac{dy}{dx} = f'(g(h(x))) \cdot g'(h(x)) \cdot h'(x) \]

Example: \(y = \sin(3x^2 + 1)\)

Outer: \(\sin(u),\, u = 3x^2 + 1\)

\(dy/du = \cos(u),\, du/dx = 6x\)

\(dy/dx = \cos(3x^2 + 1) ยท 6x\)

Exercise 1

Find \(dy/dx\) for \(y = \cos(5x^2)\)
\(dy/dx = -\sin(5x^2) ยท\)

2. Nested Chain Rule Example

\(y = e^{\sin(2x)}\)

Let \(v = \sin(2x) โ†’ y = e^v\)

\(dy/dv = e^v,\, dv/dx = \cos(2x) ยท 2\)

\(dy/dx = e^{\sin(2x)} ยท 2 \cos(2x)\)

Common in ML: activation functions like sigmoid, ReLU derivatives.

Exercise 2

Find \(dy/dx\) for \(y = (x^2 + 1)^4\)
\(dy/dx = 4(x^2 + 1)^3 ยท\)

Exercise 3

Drag the correct derivative terms to complete the chain rule for \(y = \sin(e^{3x})\):

Drop here โ†’ \(\cos(e^{3x})\)
Drop here โ†’ \(e^{3x}\)
Drop here โ†’ \(3\)
Click / tap any item to place it in the first empty zone:
Outer derivative
Middle derivative
Inner derivative
โ† Previous Lesson (7) Next Lesson (9) โ†’