#math/calculus A composite output can change through several intermediate variables at once. The multivariable chain rule follows every dependency path, multiplies the rates along it, and adds the contributions. If $ z=f(x,y),\qquad x=g(t),\qquad y=h(t), $ then $ \boxed{\frac{dz}{dt}=f_x\frac{dx}{dt}+f_y\frac{dy}{dt}}. $ ![[tikz-a2972432bd57.svg]] %% tikz-source ```latex \usetikzlibrary{arrows.meta,positioning} \begin{document} \begin{tikzpicture}[>=Stealth,node distance=1.3cm and 1.8cm, box/.style={draw,rounded corners,minimum width=1.25cm,minimum height=.72cm,fill=blue!7}, every node/.style={font=\small}] \node[box] (t) {$t$}; \node[box,above right=of t] (x) {$x=g(t)$}; \node[box,below right=of t] (y) {$y=h(t)$}; \node[box,right=3.0cm of t] (f) {$z=f(x,y)$}; \draw[->,thick] (t)--node[above left]{$x'$}(x); \draw[->,thick] (t)--node[below left]{$y'$}(y); \draw[->,thick] (x)--node[above]{$f_x$}(f); \draw[->,thick] (y)--node[below]{$f_y$}(f); \node[right=1.2cm of f,align=left] {$\displaystyle \frac{dz}{dt}=f_x\frac{dx}{dt}+f_y\frac{dy}{dt}$\\sum over every path from $t$ to $z$}; \end{tikzpicture} \end{document} ``` %% For $u=f(x,y,z)$ with all three coordinates depending on $t$, $ \frac{du}{dt} =f_x\frac{dx}{dt}+f_y\frac{dy}{dt}+f_z\frac{dz}{dt}. $ ## Key example — a duck swimming through changing temperature In the book, a duck follows the circular path $ x=\cos t, \qquad y=\sin t, $ through water whose temperature is $ T(x,y)=x^2e^y-xy^3. $ The temperature changes through both the $x$ and $y$ dependency paths. Since $ T_x=2xe^y-y^3, \qquad T_y=x^2e^y-3xy^2, $ and $x'=-\sin t$, $y'=\cos t$, the chain rule gives $ \frac{dT}{dt} =(2xe^y-y^3)(-\sin t)+(x^2e^y-3xy^2)\cos t. $ Substituting the path produces $ \frac{dT}{dt} =-2\cos t\sin t\,e^{\sin t}+\sin^4t +\cos^3t\,e^{\sin t}-3\cos^2t\sin^2t. $ Directly substituting $x(t),y(t)$ into $T$ and differentiating gives the same result. The two terms in the chain rule are necessary because the duck's temperature changes through two simultaneous coordinate motions. [[Calculus III Ch 14 - Ch 16.pdf#page=86|Textbook Example 1, PDF p. 86]] The rule is a sum, rather than one product, because the output changes through several intermediate variables. [[15D2 - General Chain Rule and Jacobians|Jacobian multiplication]] packages the same idea for vector-valued functions. > [!ML/AI] > For one neuron, let $a=wx+b$, $\hat y=\sigma(a)$, and $L=\tfrac12(\hat y-y)^2$. The chain rule gives $\partial L/\partial w=(\hat y-y)\sigma'(a)x$; backpropagation repeats exactly this calculation through every layer.