MAT257Y1/Unit 5
Unit 5 · Analysis II

Chain Rule & Higher Derivatives

Once the derivative is a linear map, the chain rule stops being a formula to memorise and becomes the only thing it could be: the derivative of a composition is the composition of the derivatives. Higher derivatives then arrive as multilinear maps, and the surprise of the unit is that mixed partials commute — but only under a hypothesis, and there is a function that shows why.

By the end you can
Why it matters & where it comes from
Why it exists

Almost nothing you differentiate is given directly; it is built by composing simpler maps. A chain rule that is a clean algebraic statement about linear maps is what lets you differentiate anything assembled from pieces, in any number of variables, without a new argument each time.

In the real world

Backpropagation is the chain rule applied right-to-left through a composition of hundreds of maps; the cost saving over left-to-right is entirely a statement about matrix shapes. Change of variables in physics is the same identity read the other way.

Story & open questions

Clairaut asserted the equality of mixed partials in 1740; a hypothesis-free version is false, and Schwarz gave the continuity condition that repairs it in 1873. Peano's counterexample from the 1890s is the one still used, and it is in this unit.

The chain rule

Theorem Chain rule

Let $f:A\to\mathbb{R}^m$ be differentiable at $a$ with $A$ open in $\mathbb{R}^n$, and let $g:B\to\mathbb{R}^p$ be differentiable at $b=f(a)$ with $f(A)\subseteq B$ open. Then $g\circ f$ is differentiable at $a$ and

$D(g\circ f)(a)=Dg(b)\circ Df(a).$

In matrices, $J(g\circ f)(a)=Jg(b)\,Jf(a)$: a $p\times m$ times an $m\times n$, giving $p\times n$. The shapes only fit one way, which is a useful memory aid.

Proof
Write $L=Df(a)$ and $M=Dg(b)$. By definition $f(a+h)=b+Lh+r(h)$ with $r(h)=o(\|h\|)$, and $g(b+k)=g(b)+Mk+s(k)$ with $s(k)=o(\|k\|)$.
Put $k=k(h)=Lh+r(h)$, so $g(f(a+h))=g(b)+M(Lh+r(h))+s(k(h))$. Subtracting $g(b)+MLh$ leaves $Mr(h)+s(k(h))$; we must show this is $o(\|h\|)$.
$\|Mr(h)\|\le\|M\|\,\|r(h)\|=o(\|h\|)$ since $M$ is bounded.
For the second term, $\|k(h)\|\le(\|L\|+1)\|h\|$ once $h$ is small. Given $\varepsilon>0$ choose $\eta$ with $\|s(k)\|\le\varepsilon\|k\|$ for $\|k\|<\eta$; then for small $h$, $\|s(k(h))\|\le\varepsilon(\|L\|+1)\|h\|$. Since $\varepsilon$ was arbitrary this is $o(\|h\|)$. ∎

Note where the proof would break if we only knew directional derivatives: $k(h)$ does not travel along a line.

Example Polar coordinates

Let $u(r,\theta)=f(r\cos\theta,r\sin\theta)$. Then $Ju=Jf\cdot Jg$ with $g$ the polar map of Unit 4, giving

$\partial u/\partial r=f_x\cos\theta+f_y\sin\theta,\qquad \partial u/\partial\theta=-f_xr\sin\theta+f_yr\cos\theta.$

Every "chain rule in several variables" formula from a first calculus course is one row of one matrix product.

Compose maps, then read off entries. Doing the matrix product first and interpreting afterwards is faster and far less error-prone than chasing subscripts through $\partial u/\partial r=\sum_j(\partial f/\partial x_j)(\partial x_j/\partial r)$.

Higher derivatives

Definition $C^k$

$f$ is $C^k$ on an open set if all partial derivatives up to order $k$ exist and are continuous there; $C^\infty$ (or smooth) if this holds for every $k$. Since $Df$ is itself a map into the space of matrices, $D^2f(a)$ is a linear map into linear maps — equivalently a bilinear map $\mathbb{R}^n\times\mathbb{R}^n\to\mathbb{R}^m$.

Definition Hessian

For scalar $f$, the Hessian at $a$ is the $n\times n$ matrix $Hf(a)$ with entries $\partial^2f/\partial x_i\partial x_j$. It represents the bilinear form $(h,k)\mapsto D^2f(a)(h,k)$.

Theorem Clairaut / Schwarz

If $\partial^2f/\partial x\,\partial y$ and $\partial^2f/\partial y\,\partial x$ exist near $a$ and are continuous at $a$, they agree at $a$. Hence the Hessian of a $C^2$ function is symmetric.

Consider the second difference $\Delta(h,k)=f(a+he_1+ke_2)-f(a+he_1)-f(a+ke_2)+f(a)$, which is visibly symmetric in the two coordinates.
Apply the mean value theorem in $x$ then in $y$: $\Delta=hk\,\partial^2f/\partial y\,\partial x(c)$ for some $c$ in the rectangle. Doing it in the other order gives $\Delta=hk\,\partial^2f/\partial x\,\partial y(c')$.
Divide by $hk$ and let $(h,k)\to0$. Both $c$ and $c'$ tend to $a$, so continuity of the two second partials at $a$ forces the values to coincide. ∎
Example Peano: mixed partials that disagree

$f(x,y)=xy\dfrac{x^2-y^2}{x^2+y^2}$ with $f(0,0)=0$.

On the $y$-axis $f(0,y)=0$, so $\partial f/\partial x(0,y)=\lim_{h\to0}f(h,y)/h=-y$. Differentiating in $y$ gives $\partial^2f/\partial y\,\partial x(0,0)=-1$.
By the symmetry $f(x,y)=-f(y,x)$ the other order gives $+1$.

Both mixed partials exist at the origin and differ. Neither is continuous there, so Clairaut is not contradicted — it is illustrated.

Taylor's theorem in $\mathbb{R}^n$

Theorem Second-order Taylor

If $f$ is $C^2$ on a ball around $a$, then for $h$ in that ball

$f(a+h)=f(a)+\nabla f(a)\cdot h +\tfrac12\,h^{T}Hf(a+\theta h)\,h$ for some $\theta\in(0,1),$

and consequently $f(a+h)=f(a)+\nabla f(a)\cdot h+\tfrac12h^{T}Hf(a)h+o(\|h\|^2)$.

The proof is the one-variable Taylor theorem applied to $\varphi(t)=f(a+th)$ on $[0,1]$; the chain rule supplies $\varphi'(t)=\nabla f(a+th)\cdot h$ and $\varphi''(t)=h^{T}Hf(a+th)h$.

Example A quadratic is its own expansion

$f(x,y)=x^2+4xy+y^2$ has $\nabla f(0,0)=(0,0)$ and constant Hessian $\begin{smallmatrix}2&4\\4&2\end{smallmatrix}$. The expansion at the origin reproduces $f$ exactly with zero remainder, as it must: every derivative of order three and higher vanishes.

Order matters more than the formula. The linear term decides whether $a$ is critical; the quadratic term decides what kind of critical point it is. Unit 8 does nothing but read that second term carefully.
Common pitfalls

• Writing the chain rule in the wrong order. $Df(a)\,Dg(b)$ usually does not even have compatible shapes.
• Applying Clairaut without continuity of the second partials. Peano's function is the standing counterexample.
• Assuming $C^1$ implies $C^2$. Each level of smoothness is a genuinely stronger hypothesis.
• Treating the Hessian as a linear map. It is a bilinear form; the matrix looks the same but the change-of-basis rule does not.
• Expanding to second order and calling the remainder $o(\|h\|)$. It is $o(\|h\|^2)$, and the sharper statement is the one you need.

Practice

Original problems written for this guide in the style of Spivak and Munkres exercises. Write a full solution before opening the answer.

Practice 1 · Composition by hand

With $f(t)=(t,t^2)$ and $g(x,y)=x^2y$, compute $(g\circ f)'(1)$ two ways.

Solution
Directly: $g(f(t))=t^4$, so the derivative at $1$ is $4$. By the chain rule, $Jg=(2xy,\,x^2)=(2,1)$ at $(1,1)$, and $Jf=(1,2t)^T=(1,2)^T$, and $(2,1)\cdot(1,2)=4$.
Practice 2 · Derivative of the inverse

If $f$ is invertible near $a$ with differentiable inverse, what is $D(f^{-1})(f(a))$?

Solution
Differentiate $f^{-1}\circ f=\mathrm{id}$ at $a$: the chain rule gives $D(f^{-1})(f(a))\,Df(a)=I$, so the derivative of the inverse is $Df(a)^{-1}$. Unit 6 supplies the missing hypothesis — that the inverse exists and is differentiable at all.
Practice 3 · Radial functions

For $u(x)=\varphi(\|x\|)$ on $\mathbb{R}^n$ minus the origin, compute $\nabla u$.

Solution
$\nabla\|x\|=x/\|x\|$, so $\nabla u(x)=\varphi'(\|x\|)\,x/\|x\|$. The gradient of a radial function is radial, which is the whole reason radial symmetry simplifies PDEs.
Practice 4 · Mixed partials

Verify Clairaut for $f(x,y)=x^3y^2+e^{xy}$.

Solution
$f_x=3x^2y^2+ye^{xy}$, so $f_{xy}=6x^2y+e^{xy}+xye^{xy}$. And $f_y=2x^3y+xe^{xy}$, so $f_{yx}=6x^2y+e^{xy}+xye^{xy}$. Equal, as guaranteed: $f$ is smooth.
Practice 5 · Euler's relation

Suppose $f$ is differentiable and homogeneous of degree $d$, meaning $f(tx)=t^df(x)$ for $t>0$. Show $x\cdot\nabla f(x)=df(x)$.

Solution
Differentiate both sides in $t$ at $t=1$. The left side gives $\nabla f(x)\cdot x$ by the chain rule, the right side gives $df(x)$.
Practice 6 · A Hessian and its signature

Find the Hessian of $f(x,y)=x^3-3xy^2$ at the origin and describe the critical point.

Solution
All second partials vanish at the origin, so the Hessian is zero and the second-order test says nothing. Looking at $f$ directly: along the $x$-axis it is $x^3$, which changes sign, so the origin is neither a maximum nor a minimum. Third-order behaviour decided it.
Practice 7 · Chain rule with a curve

If $\gamma$ is a differentiable curve inside the level set $\{f=c\}$, what is $\nabla f(\gamma(t))\cdot\gamma'(t)$?

Solution
Zero. $f\circ\gamma$ is constant, and the chain rule gives its derivative as that dot product. This is the proof that the gradient is normal to level sets.
Practice 8 · Laplacian in polar coordinates

Show $\Delta u=u_{rr}+\tfrac1ru_r+\tfrac1{r^2}u_{\theta\theta}$.

Solution
Apply the chain rule twice to $u(r,\theta)=f(r\cos\theta,r\sin\theta)$. The first derivatives are in the example above; differentiating again and using $\cos^2+\sin^2=1$ collapses the cross terms, leaving $f_{xx}+f_{yy}$ on one side and the stated combination on the other. It is a long computation and worth doing once carefully.

Expanded topic checklist

Course coverage. This unit is part of the complete MAT257Y1 topic map. It should cover the following items before you move on:

Textbook/source alignment

Spivak proves the chain rule in about a page; Munkres separates the partial-derivative bookkeeping from the linear-map argument and is easier to follow the first time. Confirm the assigned text and problem numbers against the current syllabus.

Core theorem map

Chain rule builds every later computation. Clairaut makes the Hessian symmetric, which is what lets Unit 8 diagonalise it. Taylor is the bridge between the derivative and the classification of critical points.

Study routine. Redo every multivariable chain rule you met in first-year calculus as a matrix product. When the two answers agree you have converted a memorised formula into a consequence.

Deep practice extensions

Use these after the main practice set. They are designed to force definition-level reasoning, theorem selection, and mixed application rather than routine calculation only.

Extension 1 · Why the order is forced

Explain by shapes why $Dg(b)\,Df(a)$ and not the reverse.

Guide
$Df(a)$ is $m\times n$ and $Dg(b)$ is $p\times m$. Only $p\times m$ times $m\times n$ multiplies.
Extension 2 · Hypothesis in Clairaut

Which hypothesis fails in Peano's example?

Guide
Continuity of the mixed second partials at the origin. Existence alone is not enough.
Extension 3 · Remainder order

To what order is the second-order Taylor remainder small?

Guide
$o(\|h\|^2)$ for $C^2$ functions, and $O(\|h\|^3)$ if $f$ is $C^3$ on a neighbourhood.
Extension 4 · Smoothness of compositions

Is a composition of $C^k$ maps $C^k$?

Guide
Yes. Each derivative of the composition is a polynomial in derivatives of the pieces, by repeated chain and product rules, and continuity is preserved by those operations.