Main content

## Multivariable calculus

### Course: Multivariable calculus > Unit 2

Lesson 8: Differentiating vector-valued functions (articles)# Multivariable chain rule, simple version

The chain rule for derivatives can be extended to higher dimensions. Here we see what that looks like in the relatively simple case where the composition is a single-variable function.

## What we're building to

- Given a multivariable function f, left parenthesis, x, comma, y, right parenthesis, and two single variable functions x, left parenthesis, t, right parenthesis and y, left parenthesis, t, right parenthesis, here's what the multivariable chain rule says:

- Written with vector notation, where $\vec{\textbf{v}}(t) = \left[\begin{array}{c} x(t) \\ y(t) \end{array} \right]$, this rule has a very elegant form in terms of the gradient of f and the vector-derivative of start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis.

## A more general chain rule

As you can probably imagine, the multivariable chain rule generalizes the chain rule from single variable calculus. The single variable chain rule tells you how to take the derivative of the composition of two functions:

What if instead of taking in a one-dimensional input, t, the function f took in a two-dimensional input, left parenthesis, x, comma, y, right parenthesis?

Well, in that case, it wouldn't make sense to compose it with a scalar-valued function g, left parenthesis, t, right parenthesis. Instead, let's say there are two separate scalar-valued functions x, left parenthesis, t, right parenthesis and y, left parenthesis, t, right parenthesis, and we plug these in as the coordinates of f. The overall composition will be a single variable function, with a single-number input t, and a single-number output f, left parenthesis, x, left parenthesis, t, right parenthesis, comma, y, left parenthesis, t, right parenthesis, right parenthesis, as shown in this diagram:

There is still a chain rule that lets you compute the derivative of this new single-variable function f, left parenthesis, x, left parenthesis, t, right parenthesis, comma, y, left parenthesis, t, right parenthesis, right parenthesis, and it involves the partial derivatives of f:

Keep in mind, an expression like start fraction, \partial, f, divided by, \partial, x, end fraction, start fraction, d, x, divided by, d, t, end fraction is shorthand for

That is, both are functions of t, but start fraction, \partial, f, divided by, \partial, x, end fraction is evaluated via the intermediate functions x, left parenthesis, t, right parenthesis and y, left parenthesis, t, right parenthesis.

## Written with vector notation

Rather than thinking of x, left parenthesis, t, right parenthesis and y, left parenthesis, t, right parenthesis as being separate functions, it's common to package them together into a single, vector-valued function:

Then instead of writing the composition as f, left parenthesis, x, left parenthesis, t, right parenthesis, comma, y, left parenthesis, t, right parenthesis, right parenthesis, you can write it as f, left parenthesis, start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis, right parenthesis.

With this notation, the multivariable chain rule can be written more compactly as a dot product between the gradient of f and the vector-derivative of start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis:

Written like this, the analogy with the single-variable derivative is clearer.

The gradient del, f plays the role of the derivative of f, and the vector derivative start bold text, v, end bold text, with, vector, on top, prime, left parenthesis, t, right parenthesis plays the role as the ordinary derivative of g.

## Intuition for why the chain rule works

As a warm up, consider the single variable chain rule for a composition like f, left parenthesis, g, left parenthesis, t, right parenthesis, right parenthesis. Here's how I like to understand that composition:

- First, g maps a point t on the number line to another point g, left parenthesis, t, right parenthesis the number line.
- Then f comes in and maps the point g, left parenthesis, t, right parenthesis to yet another point on the number line, f, left parenthesis, g, left parenthesis, t, right parenthesis, right parenthesis

Understanding the derivative of f, left parenthesis, g, left parenthesis, t, right parenthesis, right parenthesis requires understanding how a tiny change in t changes the final output.

So let's dive into what the chain rule is really saying.

- The term start color #1fab54, start fraction, d, g, divided by, d, t, end fraction, end color #1fab54 represents how a tiny change in t influences the intermediate output, g, left parenthesis, t, right parenthesis.

- The term start color #11accd, start fraction, d, f, divided by, d, g, end fraction, end color #11accd represents how a tiny change in g influences the final output f, left parenthesis, g, left parenthesis, t, right parenthesis, right parenthesis.

- The total change in f due to a small change in t is then the product of both these influences.

## Extend this intuition to more dimensions

The intuition is similar for the multivariable chain rule. You can think of start bold text, v, end bold text, with, vector, on top as mapping a point on the number line to a point on the x, y-plane, and f, left parenthesis, start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis, right parenthesis as mapping that point back down to some place on the number line. The question is, how does a small change in the initial input t change the total output f, left parenthesis, start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis, right parenthesis?

Let's break down what the multivariable chain rule is saying, spelling it out in terms of the component functions x, left parenthesis, t, right parenthesis and y, left parenthesis, t, right parenthesis:

- The term start color #1fab54, start fraction, d, x, divided by, d, t, end fraction, end color #1fab54 represents how a tiny change in t influences the intermediate output x, left parenthesis, t, right parenthesis.

- Likewise the term start color #e84d39, start fraction, d, y, divided by, d, t, end fraction, end color #e84d39 represents how a tiny change in t influences the second intermediate output y, left parenthesis, t, right parenthesis.

- The term start color #11accd, start fraction, \partial, f, divided by, \partial, x, end fraction, end color #11accd represents how a tiny change
**to the x-component**of an input to f influences its output, and similarly the term start color #11accd, start fraction, \partial, f, divided by, \partial, y, end fraction, end color #11accd accounts for how a small change**to the y-component**of the input changes f.

- One way a small change to t influences f, left parenthesis, x, left parenthesis, t, right parenthesis, comma, y, left parenthesis, t, right parenthesis, right parenthesis is that it first changes x, left parenthesis, t, right parenthesis, which in turn changes f. This effect is captured in the product start color #11accd, start fraction, \partial, f, divided by, \partial, x, end fraction, end color #11accd, start color #1fab54, start fraction, d, x, divided by, d, t, end fraction, end color #1fab54.

- The other way a change to t changes the output of f, left parenthesis, x, left parenthesis, t, right parenthesis, comma, y, left parenthesis, t, right parenthesis, right parenthesis is by first changing the second intermediate output y, left parenthesis, t, right parenthesis, which in turn affects the output of f. This effect is captured in the product start color #11accd, start fraction, \partial, f, divided by, \partial, y, end fraction, end color #11accd, start color #e84d39, start fraction, d, y, divided by, d, t, end fraction, end color #e84d39.
- Adding these two products gives the total change in f.

## Connection with directional derivative

You might notice that the dot product expression for the multivariable chain rule looks a lot like a directional derivative:

In fact, that's exactly what it is! The derivative start bold text, v, end bold text, with, vector, on top, prime, left parenthesis, t, start subscript, 0, end subscript, right parenthesis at a particular value t, start subscript, 0, end subscript gives a vector in the input space of f:

If start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis is interpreted as a parametric path inside this space, perhaps thought of as the trajectory of a particle, the derivative at a particular point in time t, start subscript, 0, end subscript gives the velocity vector of this particle at that time.

With this interpretation, the chain rule tells us that the derivative of the composition f, left parenthesis, start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis, right parenthesis is the

**directional derivative of f along the derivative of start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis**.This should make sense, because a tiny change by "d, t" to t should, by the meaning of the derivative, cause a tiny change d, start bold text, v, end bold text, with, vector, on top to the output of start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis. And the point of the directional derivative is that a tiny change d, start bold text, v, end bold text, with, vector, on top to the input of f should cause a change d, f as determined by start fraction, \partial, f, divided by, \partial, start bold text, v, end bold text, with, vector, on top, end fraction, equals, del, start subscript, start bold text, v, end bold text, with, vector, on top, end subscript, f.

## Example 1: With and without the new chain rule

Define f, left parenthesis, x, comma, y, right parenthesis like this:

And define start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis like this:

Find the derivative start fraction, d, divided by, d, t, end fraction, f, left parenthesis, start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis, right parenthesis.

**Solution without chain rule**:

Before throwing our fancy new tool at the problem, it's worth pointing out that this is something we can solve by first writing out the composition as a single variable function of t:

Now you can take the ordinary derivative:

But of course, the purpose of this example is to get a feel for what the chain rule feels like.

**Solution using chain rule**:

First, let's explicitly state the component functions of start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis:

According to the chain rule,

Taking the partial derivatives of f, left parenthesis, x, comma, y, right parenthesis, equals, x, squared, y and the ordinary derivatives of x, left parenthesis, t, right parenthesis, equals, cosine, left parenthesis, t, right parenthesis, y, left parenthesis, t, right parenthesis, equals, sine, left parenthesis, t, right parenthesis, we get

We want everything in terms of t, so we plug in x, equals, cosine, left parenthesis, t, right parenthesis and y, equals, sine, left parenthesis, t, right parenthesis.

Reassuringly, this is the same as the answer we got without using the chain rule. You might be thinking that this new chain rule makes things unnecessarily complicated, and the dirty little secret is that for concrete computations like this one, it is often not needed.

However, it is useful for writing equations in terms of an unknown function, as the next example shows.

## Example 2: Unknown function

Suppose the temperature across a two-dimensional region varies according to a function T, left parenthesis, x, comma, y, right parenthesis, which we do not know. You wander throughout this region, sampling temperatures as you go, and your x and y coordinates as functions of time are

In taking your measurements, you notice that the temperature never changes along your path. What can you say about the partial derivatives of T?

## Summary

- Given a multivariable function f, left parenthesis, x, comma, y, right parenthesis, and two single variable functions x, left parenthesis, t, right parenthesis and y, left parenthesis, t, right parenthesis, here's what the multivariable chain rule says:

- Written with vector notation, where $\vec{\textbf{v}}(t) = \left[\begin{array}{c} x(t) \\ y(t) \end{array} \right]$, this rule has a very elegant form in terms of the gradient of f and the vector-derivative of start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis.

## Want to join the conversation?

- 3rd paragraph (A more general chain rule), 1st equation states: derivative of f with respect to x ... I think it should be with respect to t: d/dt f(g(t)).(4 votes)
- yeh this part got me like "wat" but i guess its just a typo(2 votes)

- If I have something like P(s(t),t), then would the derivative of P with respect to t be just the partial derivative of P with respect to s multiplied by the derivative of s with respect to t, or is it a bit more complicated than that?(3 votes)
- Hi Rayden, I had a similar question.

Suppose that instead of P(s(t),t) you had P(s(t),r(t)), being r(t)=t. Now, try to apply the chain rule and you will get a sum of two terms. The term concerning s(t) is straightforward. The term concerning r(t) results in (dP(t)/dr).(dr/dt) = (dP(t)/dr).(dt/dt) = (dP(t)/dr).1 = dP(t)/dr = dP(t)/dr(t) = dP(t)/dt (remember that r(t)=t ). So, I guess the final result would be: Dp(s(t),t) = dP(t)/dt + (dP/ds).(ds/dt).(3 votes)

- Why this is not possible?

total change in f(x,y)= lim ( f(x(t+h),y(t+h)) - f(x(t),y(t)) ) / h

h->0

Also,what this expression tells ?

Thank you.(3 votes)- I'm not sure, but I guess what you've wrote is just another valid way of looking at it. If you consider x(t), y(t) as parametric path on a plane, you're calculating the variation of f on each point x,y depending on t. It seems to lead to kind of directional derivative of f along the path. Someone correct me if I am wrong, please.(2 votes)

- In the last equation under “Connection with the directional derivative” shouldn’t it be ∇_v’_f?(2 votes)
- True! It's the derivative of f evaluated at v(t) and taking the direction of v'(t).(1 vote)

- What is the answer to the challenge question?(2 votes)
- This is a bit confusing. Say f(x, y)=xy, x(t)=t and y(t)=t. If we want to find partial diff. df/dx, can't we substitute y=x in the expression for f and say that it is equal to 2x(=2t) instead of y(=t)?(1 vote)
- You could do that, but regardless, you would still have to find dx/dt (after writing out the chain rule). There are plenty of examples of chain rule where you could substitute functions like x(t) or y(t) into another function like f(x,y), yes it would make life easier and avoids chain rule altogether, however that doesn't teach you chain rule or the importance of it. Learning chain rule is important because you aren't always given explicit function definitions. Sometimes you are only given one multivariable function and are asked to find the partial of one variable with respect to another (for example, the partial of pressure with respect to volume in the van der Waals equation) and would need to know how to write out and do a multivariable chain rule.(2 votes)

- Could someone please tell me how to do the challenge question in the section "Intuition for why the chain rule works" (in the additional section at the end of the last bullet point)? Thank you.(1 vote)
- lim ℎ→0 (𝑓(𝑔(𝑡₀ + ℎ)) − 𝑓(𝑔(𝑡₀)))∕ℎ

= lim ℎ→0 (𝑓(𝑔(𝑡₀ + ℎ) − 𝑔(𝑡₀) + 𝑔(𝑡₀)) − 𝑓(𝑔(𝑡₀)))∕ℎ

= lim ℎ→0 (𝑓(ℎ⋅(𝑔(𝑡₀ + ℎ) − 𝑔(𝑡₀))∕ℎ + 𝑔(𝑡₀)) − 𝑓(𝑔(𝑡₀)))∕ℎ

= lim ℎ→0 (𝑓(ℎ⋅𝑔′(𝑡₀) + 𝑔(𝑡₀)) − 𝑓(𝑔(𝑡₀)))∕ℎ

= lim ℎ→0 (𝑓(𝑔(𝑡₀) + ℎ⋅𝑔′(𝑡₀)) − 𝑓(𝑔(𝑡₀)))∕(ℎ⋅𝑔′(𝑡₀))⋅𝑔′(𝑡₀)

Let 𝑘 = ℎ⋅𝑔′(𝑡₀)

Notice that ℎ → 0 ⇒ 𝑘 → 0

(assuming 𝑔′(𝑡₀) exists)

Thereby, we can write the limit as

lim 𝑘→0 (𝑓(𝑔(𝑡₀) + 𝑘) − 𝑓(𝑔(𝑡₀)))∕𝑘⋅𝑔′(𝑡₀)

= 𝑓′(𝑔(𝑡₀))⋅𝑔′(𝑡₀)(1 vote)