Part 4 - Chain rule

Posted on Sep 5, 2023
(Last updated: May 26, 2024)

Introduction

In this part we’ll define the chain rule for functions with several variables. We will also cover something called implicit differentiation.

Chain rule

Let’s recall the chain rule for functions with one variable. $$ f(x) = h(g(x)) \newline f’(x) = h’(g(x)) \cdot g’(x) $$

Alternative notation: $$ y = f(x) \newline x = g(t) $$

$$ \dfrac{dy}{dt} = \dfrac{dy}{dx} \cdot \dfrac{dx}{dt} $$

For functions with two variables. $$ z = f(x, y),\ x = g(t),\ y = h(t) $$

$$ \dfrac{dz}{dt} = ? $$

Let’s first assume $f, g \text{ and } h$ are all differentiable. Using the definition: $$ \dfrac{dz}{dt} = \lim_{\Delta t \to 0} \dfrac{\Delta z}{\Delta t} $$

As we defined last time, $\Delta t$ is the increment in t. Increment in $\Delta t$ produces increment in: $$ \Delta x = g(t + \Delta t) - g(t) \Delta y = h(t + \Delta t) - h(t) $$

Since, $f$, is differentiable, this must mean: $$ \Delta z = \dfrac{\partial z}{\partial x} \Delta x + \dfrac{\partial z}{\partial y} \Delta y + \varepsilon_1 \Delta x + \varepsilon_2 \Delta y $$

Where $\varepsilon_1$, $\varepsilon_2 \to 0$ as $(\Delta x, \Delta y) \to (0, 0)$.

As we defined earlier: $$ \dfrac{dz}{dt} = \lim_{\Delta t \to 0} \dfrac{\Delta z}{\Delta t} $$

We then get: $$ \dfrac{\Delta z}{\Delta t} = \dfrac{\partial z}{\partial x} \dfrac{\Delta x}{\Delta t} + \dfrac{\partial z}{\partial y} \dfrac{\Delta y}{\Delta t} + \varepsilon_1 \dfrac{\Delta x}{\Delta t} + \varepsilon_2 \dfrac{\Delta y}{\Delta t} $$

$$ \lim_{\Delta t \to 0} \dfrac{\Delta z}{\Delta t} = \dfrac{\partial z}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial z}{\partial y} \dfrac{dy}{dt} + \varepsilon_1 \dfrac{dx}{dt} + \varepsilon_2 \dfrac{dy}{dt} $$

If $\Delta t \to 0$, then: $$ \lim_{\Delta t \to 0} \Delta x = \lim_{\Delta t \to 0} g(t + \Delta t) - g(t) \newline \lim_{\Delta t \to 0} \Delta x = \lim_{\Delta t \to 0} g(t) - g(t) \newline \lim_{\Delta t \to 0} \Delta x = 0 $$

$$ \lim_{\Delta t \to 0} \Delta y = \lim_{\Delta t \to 0} h(t + \Delta t) - g(t) \newline \lim_{\Delta t \to 0} \Delta y = \lim_{\Delta t \to 0} h(t) - g(t) \newline \lim_{\Delta t \to 0} \Delta y = 0 $$

So, $(\Delta x, \Delta y) \to (0, 0)$, which finally leads us to:

$$ \boxed{\dfrac{dz}{dt} = \dfrac{\partial z}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial z}{\partial y} \dfrac{dy}{dt}} $$

Let’s write and define properly now.

Definition

Suppose $z = f(x, y)$ is differentiable function of $x, y$. Where $x = g(t)$ and $y = h(t)$. Which both are differentiable functions of $t$. Then: $$ \boxed{\dfrac{dz}{dt} = \dfrac{\partial z}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial z}{\partial y} \dfrac{dy}{dt}} $$

Example

Find $\dfrac{dz}{dt}$ at $t = 0$.

For:

$$ z = x^2y + 3xy^4 \newline x = sin(2t) \newline y = cos(t) $$

$$ \dfrac{dz}{dt} = \dfrac{\partial z}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial z}{\partial y} \dfrac{dy}{dt} $$

$$ \dfrac{dz}{dt} = (2yx + 3y^4) \cdot (2cos(2t)) + (x^2 + 12xy^3) \cdot (-sin(t)) $$

Since we need to evaluate at $t = 0$, we evaluate what $x$ and $y$ are at this point.

$$ x = sin(2 \cdot 0) = 0 \newline y = cos(0) = 1 $$

Now we substitute these values. $$ \dfrac{dz}{dt} = (2 \cdot 1 \cdot 0 + 3 \cdot 1^4) \cdot (2cos(2 \cdot 0)) + (0^2 + 12 \cdot 0 \cdot 1^3) \cdot (-sin(0)) $$

$$ \dfrac{dz}{dt} \bigg\rvert_{t = 0} = \ldots = \boxed{6} $$

Chain Rule for functions with two variables

We’ve defined the chain rule only if our functions depend on two variables when they depend on a single variable. But often this is not the case.

$z = f(x, y),\ x = g(t, s),\ y = h(t, s)$.

How do we find $\dfrac{\partial z}{\partial t} = ?$ $\dfrac{\partial z}{\partial s} = ?$

Let’s think about this, when we say we want to find $\dfrac{\partial z}{\partial t}$ this means $s$ is a constant, we can now view the functions as a function of one variable!

This means: $$ \dfrac{dz}{dt} = \dfrac{\partial z}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial z}{\partial y} \dfrac{dy}{dt} $$

$$ \dfrac{dz}{ds} = \dfrac{\partial z}{\partial x} \dfrac{dx}{ds} + \dfrac{\partial z}{\partial y} \dfrac{dy}{ds} $$

We now can generalize the chain rule.

General chain rule

Let $z$ be a differentiable function of $n$ variables, $x_1, \ldots, x_n$, where each $x_i$ is differentiable function of $m$ variables, $t_1, \ldots, t_m$.

Then: $$ \dfrac{\partial z}{\partial t_i} = \dfrac{\partial z}{\partial x_1} \dfrac{\partial x_1}{\partial t_i} + \dfrac{\partial z}{\partial x_2} \dfrac{\partial x_2}{\partial t_i} + \ldots + \dfrac{\partial z}{\partial x_n} \dfrac{\partial x_n}{\partial t_i} $$

Example

Let

$$ u = x^4y + y^2 z^3 \newline x = rs \cdot e^t \newline y = rs^2 \cdot e^{-t} \newline z = r^2s \cdot sin(t) $$

Find the value of $\dfrac{\partial u}{\partial s}$ when $r = 1, s = 1, t = 0$.

$$ \dfrac{\partial u}{\partial s} \bigg\rvert_{r = 1, s = 1, t = 0} = \dfrac{\partial u}{\partial x} \dfrac{\partial x}{\partial s} + \dfrac{\partial u}{\partial y} \dfrac{\partial y}{\partial s} + \dfrac{\partial u}{\partial z} \dfrac{\partial z}{\partial s} $$

$$ \dfrac{\partial u}{\partial s} \bigg\rvert_{r = 1, s = 1, t = 0} = \ldots = (4yx^3) \cdot (re^t) + (x^4 + 2z^3y) \cdot (2rse^{-t}) + (3y^2z^2) \cdot (r^2 sin(t)) $$

Evaluate $x, y, z$ at $r = 1, s = 1, t = 0$: $$ x = 1 \cdot 1 \cdot e^0 = 1 \newline y = 1 \cdot 1 \cdot e^{-0} = 1 \newline z = 1 \cdot 1 \cdot sin(0) = 0 \newline $$

Substitute all variables: $$ \dfrac{\partial u}{\partial s} \bigg\rvert_{r = 1, s = 1, t = 0} = \ldots = \boxed{} $$

Implicit differentiation

Sometimes the function is not given explicitly, rather implicitly. For example:

Let y(x) be a function that satisfies: $$ x^3 + 3xy - y^5 + 1 = 0 $$

How can we find $\dfrac{dy}{dx}$?

The first logical answer would be to explicitly find $y(x)$, but that can be really tedious. We can instead view this equation as a function of two variables.

Let’s introduce a new function, $F(x, y)$. This means: $$ F(x, y) = x^3 + 3xy - y^5 + 1 = 0 $$

We want to find a $y(x)$ such that this equation is satisfied. Since $y(x)$ depends on $x$, and $x$ in itself depends on $x$. We can apply the chain rule! $$ \dfrac{dF(x, y)}{dx} = \dfrac{\partial F}{\partial x} \dfrac{dx}{dx} + \dfrac{\partial F}{\partial y} \dfrac{dy}{dx} $$

We want to find $y(x)$ such that: $$ \dfrac{\partial F}{\partial x} \dfrac{dx}{dx} + \dfrac{\partial F}{\partial y} \dfrac{dy}{dx} = 0 $$

Which means: $$ \dfrac{dy}{dx} = - \dfrac{\dfrac{\partial F}{\partial x}}{\dfrac{\partial F}{\partial y}} = \boxed{-\dfrac{F_x}{F_y}} $$

Here we need to assume $F_y$ isn’t zero. But this means in our case that: $$ \dfrac{dy}{dx} = - \dfrac{3x^2 + 3y}{3x - 5y^4} $$

Definition

Suppose a function $y = y(x)$ is given implicitly by equation of the form $F(x, y) = 0$ where $F$ is a differentiable function of two variables and $F_y \neq 0$. Then: $$ \boxed{\dfrac{dy}{dx} = -\dfrac{F_x}{F_y}} $$

Example

Let $y(x)$ be given implicitly by equation: $$ x^3 + 3xy - y^5 + 1 = 0 $$

Evaluate $\dfrac{dy}{dx}$ at $x = 0$.

$$ \dfrac{dy}{dx} \bigg\rvert_{x = 0} = -\dfrac{F_x}{F_y} = - \dfrac{3x^2 + 3y}{3x - 5y^4} $$

Evaluate $y$ at $x = 0$: $$ x^3 + 3xy - y^5 + 1 = 0 \newline 0^3 + 3 \cdot 0 \cdot y - y^5 + 1 = 0 \newline y = 1 $$

Which means: $$ \dfrac{dy}{dx} \bigg\rvert_{x = 0} = \ldots = \boxed{\dfrac{3}{5}} $$

Implicit differentiation of several variables

The proof for this is exactly the same so… Let $z(x, y)$ be given implicitly, by equation of form $F(x, y, z) = 0$ where $F$ is differentiable and $F_z \neq 0$, then: $$ \dfrac{\partial z}{\partial x} = -\dfrac{F_x}{F_z} \newline \dfrac{\partial z}{\partial y} = -\dfrac{F_y}{F_z} \newline $$

Example

Find $\dfrac{\partial z}{\partial y}$, given $x^3 + y^3 + z^3 + 6xyz - 1 = 0$ $$ \dfrac{\partial z}{\partial y} = -\dfrac{F_y}{F_z} = - \dfrac{3y^2 + 6xz}{3z^2 + 6xy} = - \dfrac{y^2 + 2xz}{z^2 + 2xy} $$