If you're seeing this message, it means we're having trouble loading external resources on our website.

Jeżeli jesteś za filtrem sieci web, prosimy, upewnij się, że domeny *.kastatic.org i *.kasandbox.org są odblokowane.

Główna zawartość

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.

Do czego zmierzamy

  • Given a multivariable function f(x,y), and two single variable functions x(t) and y(t), here's what the multivariable chain rule says:
ddtf(x(t),y(t))Derivative of composition function=fxdxdt+fydydt
  • Written with vector notation, where v(t)=[x(t)y(t)], this rule has a very elegant form in terms of the gradient of f and the vector-derivative of v(t).
ddtf(v(t))Derivative of composition function=fv(t)Dot product of vectors

A more general chain rule

Jak się prawdopodobnie domyślasz, wzór na pochodną złożenia funkcji wielu zmiennych jest uogólnieniem reguły łańcuchowej dla funkcji jednej zmienej:
ddxf(g(t))=dfdgdgdt=f(g(t))g(t)
What if instead of taking in a one-dimensional input, t, the function f took in a two-dimensional input, (x,y)?
f(x,y)=some expression of x and y
Well, in that case, it wouldn't make sense to compose it with a scalar-valued function g(t). Instead, let's say there are two separate scalar-valued functions x(t) and y(t), 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(x(t),y(t)), as shown in this diagram:
Diagram showing the composition of a function with one input and two outputs with a function that has two inputs and one output.
There is still a chain rule that lets you compute the derivative of this new single-variable function f(x(t),y(t)), and it involves the partial derivatives of f:
Dissect multivariable chain rule
Keep in mind, an expression like fxdxdt is shorthand for
fx(x(t),y(t))dxdt(t)
That is, both are functions of t, but fx is evaluated via the intermediate functions x(t) and y(t).

Written with vector notation

Rather than thinking of x(t) and y(t) as being separate functions, it's common to package them together into a single, vector-valued function:
v(t)=[x(t)y(t)]
Then instead of writing the composition as f(x(t),y(t)), you can write it as f(v(t)).
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 v(t):
ddtf(v(t))=fx(v(t))dxdt+fy(v(t))dydtRewrite this sum as a dot product=[fx(v(t))fy(v(t))]f(v(t))[dxdtdydt]v(t)=f(v(t))v(t)
Written like this, the analogy with the single-variable derivative is clearer.
ddtf(g(t))=f(g(t))g(t)=dfdgdgdt
The gradient f plays the role of the derivative of f, and the vector derivative v(t) 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(g(t)). Here's how I like to understand that composition:
  • First, g maps a point t on the number line to another point g(t) the number line.
  • Then f comes in and maps the point g(t) to yet another point on the number line, f(g(t))
Understanding the derivative of f(g(t)) requires understanding how a tiny change in t changes the final output.
Composition of f and g
So let's dive into what the chain rule is really saying.
ddxf(g(t))=dfdgdgdt
  • The term dgdt represents how a tiny change in t influences the intermediate output, g(t).
  • The term dfdg represents how a tiny change in g influences the final output f(g(t)).
  • 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 v as mapping a point on the number line to a point on the xy-plane, and f(v(t)) 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(v(t))?
Composition of f and textbfv
Let's break down what the multivariable chain rule is saying, spelling it out in terms of the component functions x(t) and y(t):
ddtf(v(t))=ddtf(x(t),y(t))=fxdxdt+fydydt
  • The term dxdt represents how a tiny change in t influences the intermediate output x(t).
  • Likewise the term dydt represents how a tiny change in t influences the second intermediate output y(t).
  • The term fx represents how a tiny change to the x-component of an input to f influences its output, and similarly the term fy accounts for how a small change to the y-component of the input changes f.
  • One way a small change to t influences f(x(t),y(t)) is that it first changes x(t), which in turn changes f. This effect is captured in the product fxdxdt.
  • The other way a change to t changes the output of f(x(t),y(t)) is by first changing the second intermediate output y(t), which in turn affects the output of f. This effect is captured in the product fydydt.
  • 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:
f(v(t))v(t)
Derivative is a velocity vector tangent to trajectory.
In fact, that's exactly what it is! The derivative v(t0) at a particular value t0 gives a vector in the input space of f:
v(t0)=[x(t0)y(t0)]
If v(t) 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 t0 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(v(t)) is the directional derivative of f along the derivative of v(t).
This should make sense, because a tiny change by "dt" to t should, by the meaning of the derivative, cause a tiny change dv to the output of v(t). And the point of the directional derivative is that a tiny change dv to the input of f should cause a change df as determined by fv=vf.

Example 1: With and without the new chain rule

Define f(x,y) like this:
f(x,y)=x2y
And define v(t) like this:
v(t)=[cos(t)sin(t)]
Find the derivative ddtf(v(t)).
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:
f(v(t))=f(cos(t),sin(t))=cos(t)2sin(t)
Now you can take the ordinary derivative:
ddtcos(t)2sin(t)=cos(t)2(cos(t))+2cos(t)(sin(t))sin(t)=cos3(t)2cos(t)sin2(t)
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 v(t):
x(t)=cos(t)y(t)=sin(t)
According to the chain rule,
ddtf(v(t))=fxdxdt+fydydt
Taking the partial derivatives of f(x,y)=x2y and the ordinary derivatives of x(t)=cos(t), y(t)=sin(t), we get
x(x2y)ddt(cos(t))+y(x2y)ddt(sin(t))=(2xy)(sin(t))+(x2)(cos(t))
We want everything in terms of t, so we plug in x=cos(t) and y=sin(t).
(2xy)(sin(t))+(x2)(cos(t))(2cos(t)sin(t))(sin(t))+(cos(t)2)cos(t)=2cos(t)sin2(t)+cos3(t)
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(x,y), 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
x(t)=30cos(2t)y(t)=40sin(3t)
In taking your measurements, you notice that the temperature never changes along your path. What can you say about the partial derivatives of T?

Podsumowanie

  • Given a multivariable function f(x,y), and two single variable functions x(t) and y(t), here's what the multivariable chain rule says:
ddtf(x(t),y(t))Derivative of composition function=fxdxdt+fydydt
  • Written with vector notation, where v(t)=[x(t)y(t)], this rule has a very elegant form in terms of the gradient of f and the vector-derivative of v(t).
ddtf(v(t))Derivative of composition function=fv(t)Dot product of vectors

Chcesz dołączyć do dyskusji?

Na razie brak głosów w dyskusji
Rozumiesz angielski? Kliknij tutaj, aby zobaczyć więcej dyskusji na angielskiej wersji strony Khan Academy.