Chain rule examples
Example 1
Let g : R → R2 and f : R2 → R be defined by
| g(t) = (t3,t4) | |
|
| f(x,y) = x2y. | | |
(You can think of this as the
mountain climbing example where
f(
x,y) is height
of mountain at point (
x,y) and the path
g(
t) gives your position at time
t.) Let
h(
t) be the composition of
f with
g (which would give your height at time
t):
| h(t) = (f ∘ g)(t) = f(g(t)) | | |
Calculate the derivative
h'(
t) =

(
t) (i.e., the change in height) via the chain
rule.
Solution A: We’ll use the formula using matrices of partial derivatives:
We calculate the matrices of partial derivatives of f and g.
We need to evaluate
Df at the point
g(
t):
Df(g(t)) = Df(t3,t4) = = ![[ 2t7 t6 ]](chainruleex6x.png) | | |
The derivative of
h is
h'(t) = (t) = Dh(t) | = Df(g(t))Dg(t) | |
|
| = ![[ 2t7 t6 ]](chainruleex8x.png) ![[ 2 ]
3t
4t3](chainruleex9x.png) | |
|
| = (2t7)(3t2) + (t6)(4t3) = 6t9 + 4t9 | |
|
| = 10t9 | | |
Solution B: We’ll start immediately with the formula in component
form:
(t) = (g(t)) (t) + (g(t)) (t). | | |
We calculate
(x,y) | = 2xy | |
|
(x,y) | = x2 | |
|
(g(t)) | = (t3,t4) = 2(t3)(t4) = 2t7 | |
|
(g(t)) | = (t3,t4) = (t3)2 = t6 | |
|
(t) | = 3t2 | |
|
(t) | = 4t3. | | |
Therefore,
(t) = (2t7)(3t2) + (t6)(4t3) = 6t9 + 4t9 = 10t9. | | |
Example 1’
Verify the chain rule for example 1 by calculating an expression for h(t) and then
differentiating it to obtain
(t).
Solution: h(t) = f(g(t)) = f(t3,t4) = (t3)2(t4) = t10.
h'(t) = (t) = 10t9, | | |
which matches the solution to Example 1, verifying that the chain rule got the
correct answer.
For this simple example, doing it without the chain rule was a lot easier. However,
that is not always the case. And, in the next example, the only way to obtain the
answer is to use the chain rule.
Example 2
We continue the mountain climbing example of Example 1. But now, let’s say we
don’t know the terrain ahead of time. This means we do not yet know the height
f(x,y) at the position (x,y). We do, however, know our path through mountain;
as before, it is given by g(t) = (t3,t4).
Calculate the chain in height that you’ll experience along the path, i.e., calculate
the derivative of h(t) = f(g(t)). In this case, since we don’t know f, the answer
will be given in terms of the function f(x,y).
Solution: We’ll just copy solution A, above. This time, though, we must leave the
matrix of partial derivatives of f as
Df(x,y) = ![[ ]
∂f- ∂f-
∂x(x, y) ∂y (x, y)](chainruleex26x.png) | | |
since we don’t know what
f(
x,y) is. We can substitute in the values along the
path
g(
t):
Df(g(t)) = Df(t3,t4) = . | | |
Since
Dg(
t) is the same as in solution A, above, we calculate the derivative of
h
as
| h'(t) = Dh(t) | = Df(g(t))Dg(t) | |
|
| = ![[ ]
∂f-(t3,t4) ∂f-(t3,t4)
∂x ∂y](chainruleex28x.png) ![[ 2 ]
3t
4t3](chainruleex29x.png) | |
|
| = 3t2 (t3,t4) + 4t3 (t3,t4). | | |
We leave the answer in this form. Of course, as soon as we know what
f(
x,y) is,
we can simply compute its partial derivatives and plug the result into this
formula.
Example 3
We continue using the same function f(x,y) = x2y to describe the height of the
mountain at position (x,y). We embellish the above examples by letting
g : R2 → R2 be defined by g(s,t) = (t - s2,ts2). (We could think of having
many paths through the mountain that depend on a skill level s. Then,
(x,y) = g(s,t) could be the position of a person at time t with skill level
s.)
Compute
(f ∘g)(s,t) and
(f ∘g)(s,t), i.e., the partial derivatives with respect
to s and t of the height of a person in the mountains whose position is given by
g(s,t).
Solution: Let h(s,t) = (f ∘ g)(s,t) = f(g(s,t)). We need to calculate
(s,t)
and
(s,t). The chain rule says that
| Dh(s,t) = D(f ∘ g)(s,t) = Df(g(s,t))Dg(s,t). | | |
Since
Dh(s,t) = , | | |
the answers we want are just the two components of
Dh(
s,t). We just need
to calculate the matrices
Df(
g(
s,t)) and
Dg(
s,t), then multiply them
together.
To make it easier in case you have to do such a problem again, we’ll perform the
matrix multiplication before writing in the specific values for f(x,y) and g(s,t).
Then, we’ll end up with the chain rule written in component form, which may be
easier to use.
The function f(x,y) hasn’t changed, so its matrix of partial derivatives
is
Df(x,y) = . | | |
For the chain rule, we need this evaluated at (
x,y) =
g(
s,t)
Df(g(s,t)) = . | | |
Since
g :
R2 → R2, its matrix of partial derivatives is a 2
× 2 matrix. If we denote
its components as
g(
s,t) = (
g1(
s,t)
,g2(
s,t)), its matrix of partial derivatives
is
Dg(s,t) = . | | |
The chain rule
Dh(
s,t) =
Df(
g(
s,t))
Dg(
s,t) becomes
We can compute the matrix product on the right-hand side; the result is a 1
× 2
matrix (i.e., the same size of
Dh(
s,t)). We obtain one equation by matching the
first component of
Dh(
s,t) with the first component of this multiplied-out matrix.
We obtain a second equation by matching the second component of
Dh(
s,t) with
the second component of this multiplied-out matrix. The resulting two equations
are
(s,t) | = (g(s,t)) (s,t) + (g(s,t)) (s,t) | |
|
(s,t) | = (g(s,t)) (s,t) + (g(s,t)) (s,t). | | |
This is the chain rule written out in component form for
h :
R2 → R,
f :
R2 → R,
and
g :
R2 → R2.
Now, we compute the answer to our specific problem by substituting in for
f(x,y) = x2y and g(s,t) = (t - s2,ts2).
(x,y) | = 2xy | (g(s,t)) | = 2ts2(t - s2) | | | |
|
(x,y) | = x2 | (g(s,t)) | = (t - s2)2 | | | |
|
(s,t) | = -2s | (s,t) | = 2st | | | |
|
(s,t) | = 1 | (s,t) | = s2 | | | | |
Finally, we get our answers.
(f ∘ g)(s,t) = (s,t) | = (g(s,t)) (s,t) + (g(s,t)) (s,t) | |
|
| = 2ts2(t - s2)(-2s) + (t - s2)2(2st) | |
|
| = -4ts3(t - s2) + 2st(t - 2ts2 + s4) | |
|
| = -4s3t2 + 4s5t + 2st2 - 4s3t2 + 2s5t | |
|
| = -8s3t2 + 6s5t + 2st2 | | |
(f ∘ g)(s,t) = (s,t) | = (g(s,t)) (s,t) + (g(s,t)) (s,t) | |
|
| = 2ts2(t - s2)(1) + (t - s2)2(s2) | |
|
| = 2s2t2 - 2s4t + s2t2 - 2s4t + s6 | |
|
| = 3s2t2 - 4s4t + s6 | | |