Part 4 - Chain rule

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))f(x)=h(g(x))g(x)f(x) = h(g(x)) \newline f'(x) = h'(g(x)) \cdot g'(x)

Alternative notation:

y=f(x)x=g(t)y = f(x) \newline x = g(t) dydt=dydxdxdt\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)z = f(x, y),\ x = g(t),\ y = h(t) dzdt=?\dfrac{dz}{dt} = ?

Let’s first assume f,g and hf, g \text{ and } h are all differentiable. Using the definition:

dzdt=limΔt0ΔzΔt\dfrac{dz}{dt} = \lim_{\Delta t \to 0} \dfrac{\Delta z}{\Delta t}

As we defined last time, Δt\Delta t is the increment in t. Increment in Δt\Delta t produces increment in:

Δx=g(t+Δt)g(t)Δy=h(t+Δt)h(t)\Delta x = g(t + \Delta t) - g(t) \Delta y = h(t + \Delta t) - h(t)

Since, ff, is differentiable, this must mean:

Δz=zxΔx+zyΔy+ε1Δx+ε2Δy\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 ε1\varepsilon_1, ε20\varepsilon_2 \to 0 as (Δx,Δy)(0,0)(\Delta x, \Delta y) \to (0, 0).

As we defined earlier:

dzdt=limΔt0ΔzΔt\dfrac{dz}{dt} = \lim_{\Delta t \to 0} \dfrac{\Delta z}{\Delta t}

We then get:

ΔzΔt=zxΔxΔt+zyΔyΔt+ε1ΔxΔt+ε2ΔyΔt\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Δt0ΔzΔt=zxdxdt+zydydt+ε1dxdt+ε2dydt\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 Δt0\Delta t \to 0, then:

limΔt0Δx=limΔt0g(t+Δt)g(t)limΔt0Δx=limΔt0g(t)g(t)limΔt0Δx=0\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Δt0Δy=limΔt0h(t+Δt)g(t)limΔt0Δy=limΔt0h(t)g(t)limΔt0Δy=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, (Δx,Δy)(0,0)(\Delta x, \Delta y) \to (0, 0), which finally leads us to:

dzdt=zxdxdt+zydydt\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.

Theorem 1 (Chain rule)

Suppose z=f(x,y)z = f(x, y) is differentiable function of x,yx, y. Where x=g(t)x = g(t) and y=h(t)y = h(t). Which both are differentiable functions of tt. Then:

dzdt=zxdxdt+zydydt\boxed{\dfrac{dz}{dt} = \dfrac{\partial z}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial z}{\partial y} \dfrac{dy}{dt}}
Example 1

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

For:

z=x2y+3xy4x=sin(2t)y=cos(t)z = x^2y + 3xy^4 \newline x = sin(2t) \newline y = cos(t)dzdt=zxdxdt+zydydt\dfrac{dz}{dt} = \dfrac{\partial z}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial z}{\partial y} \dfrac{dy}{dt}dzdt=(2yx+3y4)(2cos(2t))+(x2+12xy3)(sin(t))\dfrac{dz}{dt} = (2yx + 3y^4) \cdot (2cos(2t)) + (x^2 + 12xy^3) \cdot (-sin(t))

Since we need to evaluate at t=0t = 0, we evaluate what xx and yy are at this point.

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

Now we substitute these values.

dzdt=(210+314)(2cos(20))+(02+12013)(sin(0))\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))dzdtt=0==6\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)z = f(x, y),\ x = g(t, s),\ y = h(t, s).

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

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

This means:

dzdt=zxdxdt+zydydt\dfrac{dz}{dt} = \dfrac{\partial z}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial z}{\partial y} \dfrac{dy}{dt} dzds=zxdxds+zydyds\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 zz be a differentiable function of nn variables, x1,,xnx_1, \ldots, x_n, where each xix_i is differentiable function of mm variables, t1,,tmt_1, \ldots, t_m.

Then:

zti=zx1x1ti+zx2x2ti++zxnxnti\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 2

Let

u=x4y+y2z3x=rsety=rs2etz=r2ssin(t)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 us\dfrac{\partial u}{\partial s} when r=1,s=1,t=0r = 1, s = 1, t = 0.

usr=1,s=1,t=0=uxxs+uyys+uzzs\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}usr=1,s=1,t=0==(4yx3)(ret)+(x4+2z3y)(2rset)+(3y2z2)(r2sin(t))\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,zx, y, z at r=1,s=1,t=0r = 1, s = 1, t = 0:

x=11e0=1y=11e0=1z=11sin(0)=0x = 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:

usr=1,s=1,t=0==\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:

x3+3xyy5+1=0x^3 + 3xy - y^5 + 1 = 0

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

The first logical answer would be to explicitly find y(x)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)F(x, y). This means:

F(x,y)=x3+3xyy5+1=0F(x, y) = x^3 + 3xy - y^5 + 1 = 0

We want to find a y(x)y(x) such that this equation is satisfied. Since y(x)y(x) depends on xx, and xx in itself depends on xx. We can apply the chain rule!

dF(x,y)dx=Fxdxdx+Fydydx\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)y(x) such that:

Fxdxdx+Fydydx=0\dfrac{\partial F}{\partial x} \dfrac{dx}{dx} + \dfrac{\partial F}{\partial y} \dfrac{dy}{dx} = 0

Which means:

dydx=FxFy=FxFy\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 FyF_y isn’t zero. But this means in our case that:

dydx=3x2+3y3x5y4\dfrac{dy}{dx} = - \dfrac{3x^2 + 3y}{3x - 5y^4}
Theorem 2 (Implicit differentiation)

Suppose a function y=y(x)y = y(x) is given implicitly by equation of the form F(x,y)=0F(x, y) = 0 where FF is a differentiable function of two variables and Fy0F_y \neq 0. Then:

dydx=FxFy\boxed{\dfrac{dy}{dx} = -\dfrac{F_x}{F_y}}
Example 3

Let y(x)y(x) be given implicitly by equation:

x3+3xyy5+1=0x^3 + 3xy - y^5 + 1 = 0

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

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

Evaluate yy at x=0x = 0:

x3+3xyy5+1=003+30yy5+1=0y=1x^3 + 3xy - y^5 + 1 = 0 \newline 0^3 + 3 \cdot 0 \cdot y - y^5 + 1 = 0 \newline y = 1

Which means:

dydxx=0==35\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)z(x, y) be given implicitly, by equation of form F(x,y,z)=0F(x, y, z) = 0 where FF is differentiable and Fz0F_z \neq 0, then:

zx=FxFzzy=FyFz\dfrac{\partial z}{\partial x} = -\dfrac{F_x}{F_z} \newline \dfrac{\partial z}{\partial y} = -\dfrac{F_y}{F_z} \newline
Example 4

Find zy\dfrac{\partial z}{\partial y}, given x3+y3+z3+6xyz1=0x^3 + y^3 + z^3 + 6xyz - 1 = 0

zy=FyFz=3y2+6xz3z2+6xy=y2+2xzz2+2xy\dfrac{\partial z}{\partial y} = -\dfrac{F_y}{F_z} = - \dfrac{3y^2 + 6xz}{3z^2 + 6xy} = - \dfrac{y^2 + 2xz}{z^2 + 2xy}