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, 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:
start underbrace, start fraction, d, divided by, d, t, end fraction, f, left parenthesis, start color #11accd, x, end color #11accd, left parenthesis, t, right parenthesis, comma, start color #bc2612, y, end color #bc2612, left parenthesis, t, right parenthesis, right parenthesis, end underbrace, start subscript, start text, D, e, r, i, v, a, t, i, v, e, space, o, f, space, c, o, m, p, o, s, i, t, i, o, n, space, f, u, n, c, t, i, o, n, end text, end subscript, equals, start fraction, \partial, f, divided by, \partial, start color #11accd, x, end color #11accd, end fraction, start fraction, d, start color #11accd, x, end color #11accd, divided by, d, t, end fraction, plus, start fraction, \partial, f, divided by, \partial, start color #bc2612, y, end color #bc2612, end fraction, start fraction, d, start color #bc2612, y, end color #bc2612, divided by, d, t, end fraction
  • Written with vector notation, where v(t)=[x(t)y(t)]\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.
start underbrace, 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, end underbrace, start subscript, start text, D, e, r, i, v, a, t, i, v, e, space, o, f, space, c, o, m, p, o, s, i, t, i, o, n, space, f, u, n, c, t, i, o, n, end text, end subscript, equals, start overbrace, del, f, dot, start bold text, v, end bold text, with, vector, on top, prime, left parenthesis, t, right parenthesis, end overbrace, start superscript, start text, D, o, t, space, p, r, o, d, u, c, t, space, o, f, space, v, e, c, t, o, r, s, end text, end superscript

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:
start fraction, d, divided by, d, x, end fraction, f, left parenthesis, g, left parenthesis, t, right parenthesis, right parenthesis, equals, start fraction, d, f, divided by, d, g, end fraction, start fraction, d, g, divided by, d, t, end fraction, equals, f, prime, left parenthesis, g, left parenthesis, t, right parenthesis, right parenthesis, g, prime, left parenthesis, t, right parenthesis
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?
f, left parenthesis, x, comma, y, right parenthesis, equals, dots, start text, s, o, m, e, space, e, x, p, r, e, s, s, i, o, n, space, o, f, space, x, space, a, n, d, space, y, end text, dots
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:
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, 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:
Dissect multivariable chain rule
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
start fraction, \partial, f, divided by, \partial, x, end fraction, left parenthesis, x, left parenthesis, t, right parenthesis, comma, y, left parenthesis, t, right parenthesis, right parenthesis, start fraction, d, x, divided by, d, t, end fraction, left parenthesis, t, right parenthesis
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:
v(t)=[x(t)y(t)]\vec{\textbf{v}}(t) = \left[\begin{array}{c} x(t) \\ y(t) \end{array} \right]
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:
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)\begin{aligned} \quad \frac{d}{dt} f(\vec{\textbf{v}}(t)) &= \underbrace{ \dfrac{\partial f}{\partial x}(\vec{\textbf{v}}(t)) \dfrac{dx}{dt}+ \dfrac{\partial f}{\partial y}(\vec{\textbf{v}}(t)) \dfrac{dy}{dt} }_{\text{Rewrite this sum as a dot product}} \\\\ &= \underbrace{ \left[ \begin{array}{c} \dfrac{\partial f}{\partial x}(\vec{\textbf{v}}(t)) \\ \\ \dfrac{\partial f}{\partial y}(\vec{\textbf{v}}(t)) \\ \end{array} \right] }_{\nabla f(\vec{\textbf{v}}(t))} \cdot \underbrace{ \left[ \begin{array}{c} \dfrac{dx}{dt} \\\\ \dfrac{dy}{dt} \end{array} \right] }_{\vec{\textbf{v}}'(t)}\\\\ &= \nabla f(\vec{\textbf{v}}(t)) \cdot \vec{\textbf{v}}'(t) \end{aligned}
Written like this, the analogy with the single-variable derivative is clearer.
ddtf(g(t))=f(g(t))g(t)=dfdgdgdt\begin{aligned} \dfrac{d}{dt} f(g(t)) = f'(g(t)) g'(t) = \dfrac{df}{dg} \cdot \dfrac{dg}{dt} \end{aligned}
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.
Composition of f and g
So let's dive into what the chain rule is really saying.
start fraction, d, divided by, d, x, end fraction, f, left parenthesis, g, left parenthesis, t, right parenthesis, right parenthesis, equals, start color #11accd, start fraction, d, f, divided by, d, g, end fraction, end color #11accd, dot, start color #1fab54, start fraction, d, g, divided by, d, t, end fraction, end color #1fab54
  • 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?
Composition of f and t, e, x, t, b, f, v, with, vector, on top
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:
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, equals, start fraction, d, divided by, d, t, end fraction, f, left parenthesis, x, left parenthesis, t, right parenthesis, comma, y, left parenthesis, t, right parenthesis, right parenthesis, equals, 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, plus, 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
  • 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:
f(v(t))v(t)\begin{aligned} \quad \nabla f(\vec{\textbf{v}}(t)) \cdot \vec{\textbf{v}}'(t) \end{aligned}
Derivative is a velocity vector tangent to trajectory.
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:
v(t0)=[x(t0)y(t0)]\begin{aligned} \quad \vec{\textbf{v}}'(t_0) = \left[ \begin{array}{c} x'(t_0) \\ y'(t_0) \end{array} \right] \end{aligned}
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:
f(x,y)=x2y\begin{aligned} f(x, y) = x^2y \end{aligned}
And define start bold text, v, end bold text, with, vector, on top, left parenthesis, t, right parenthesis like this:
v(t)=[cos(t)sin(t)]\begin{aligned} \vec{\textbf{v}}(t) = \left[ \begin{array}{c} \cos(t) \\ \sin(t) \end{array} \right] \end{aligned}
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:
f(v(t))=f(cos(t),sin(t))=cos(t)2sin(t)\begin{aligned} \quad f(\vec{\textbf{v}}(t)) &= f(\cos(t), \sin(t)) \\ &= \cos(t)^2\sin(t) \end{aligned}
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)\begin{aligned} \dfrac{d}{dt} \cos(t)^2\sin(t) &= \cos(t)^2(\cos(t)) + 2\cos(t)(-\sin(t))\sin(t) \\ &=\boxed{ \cos^3(t) - 2\cos(t)\sin^2(t)} \end{aligned}
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:
x(t)=cos(t)y(t)=sin(t)\begin{aligned} x(t) &= \cos(t) \\ y(t) &= \sin(t) \end{aligned}
According to the chain rule,
ddtf(v(t))=fxdxdt+fydydt\begin{aligned} \dfrac{d}{dt} f(\vec{\textbf{v}}(t)) &= \dfrac{\partial f}{\partial x} \dfrac{dx}{dt} + \dfrac{\partial f}{\partial y} \dfrac{dy}{dt} \\ \end{aligned}
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
x(x2y)ddt(cos(t))+y(x2y)ddt(sin(t))=(2xy)(sin(t))+(x2)(cos(t))\begin{aligned} &\quad \dfrac{\partial}{\partial \blueE{x}}(\blueE{x}^2 y) \dfrac{d}{dt}(\cos(t)) + \dfrac{\partial}{\partial \redE{y}}(x^2 \redE{y}) \dfrac{d}{dt}(\sin(t)) \\\\ &= (2\blueE{x}y)(-\sin(t)) + (x^2)(\cos(t)) \end{aligned}
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.
(2xy)(sin(t))+(x2)(cos(t))(2cos(t)sin(t))(sin(t))+(cos(t)2)cos(t)=2cos(t)sin2(t)+cos3(t)\begin{aligned} &(2\blueE{x}y)(-\sin(t)) + (x^2)(\cos(t)) \\\\ &(2\cos(t)\sin(t))(-\sin(t)) + (\cos(t)^2)\cos(t) \\\\ = &\boxed{-2\cos(t)\sin^2(t) + \cos^3(t)} \end{aligned}
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
x(t)=30cos(2t)y(t)=40sin(3t)\begin{aligned}\quad x(t) &= 30\cos(2t) \\ y(t) &= 40\sin(3t) \end{aligned}
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, 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:
start underbrace, start fraction, d, divided by, d, t, end fraction, f, left parenthesis, start color #11accd, x, end color #11accd, left parenthesis, t, right parenthesis, comma, start color #bc2612, y, end color #bc2612, left parenthesis, t, right parenthesis, right parenthesis, end underbrace, start subscript, start text, D, e, r, i, v, a, t, i, v, e, space, o, f, space, c, o, m, p, o, s, i, t, i, o, n, space, f, u, n, c, t, i, o, n, end text, end subscript, equals, start fraction, \partial, f, divided by, \partial, start color #11accd, x, end color #11accd, end fraction, start fraction, d, start color #11accd, x, end color #11accd, divided by, d, t, end fraction, plus, start fraction, \partial, f, divided by, \partial, start color #bc2612, y, end color #bc2612, end fraction, start fraction, d, start color #bc2612, y, end color #bc2612, divided by, d, t, end fraction
  • Written with vector notation, where v(t)=[x(t)y(t)]\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.
start underbrace, 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, end underbrace, start subscript, start text, D, e, r, i, v, a, t, i, v, e, space, o, f, space, c, o, m, p, o, s, i, t, i, o, n, space, f, u, n, c, t, i, o, n, end text, end subscript, equals, start overbrace, del, f, dot, start bold text, v, end bold text, with, vector, on top, prime, left parenthesis, t, right parenthesis, end overbrace, start superscript, start text, D, o, t, space, p, r, o, d, u, c, t, space, o, f, space, v, e, c, t, o, r, s, end text, end superscript

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.