5.5 Higher partial derivatives and the equality of mixed partials
Differentiate a field twice and there are n² second partials, but for any field you will meet they come in equal pairs, f_xy = f_yx. This chapter proves that (Schwarz, Clairaut) with the mean value theorem on a rectangle, shows the function where it fails, and records what the pairing buys. It also sharpens the test of 5.3 for differentiability.
Taught in 375/376Apostol, not taughtBeyond the courseApostol Vol. 2, 8.23 (Theorems 8.12 and 8.13), 8.9 #10 to #12, 8.24 #1 to #3 and the end of 8.13Spagnolie, Lecture 24 ('F_xy = F_yx if they are continuous') and the Practice Final 2013, extra creditSchwarz (1873), Peano (1890): history only
Differentiate f(x,y) in x and the result is again a function of (x,y), so you may differentiate it again, in x or in y. With two variables there are four second derivatives fxx, fxy, fyx, fyy, and with n variables n2. Every example so far had fxy=fyx. This chapter asks whether that is a law, finds that it is nearly one, and proves exactly how nearly. It also uses the same mean value argument as 5.3 to sharpen the test for differentiability.
Before you start
1.4: the mean value theorem. 5.2: partial derivatives and the mixed partial computations of homework 11. 5.3: continuous partial derivatives imply differentiable, and the chain rule of 5.4, which makes second derivatives of composites work.
Quick checkThe mean value theorem says that for g continuous on [a,b] and differentiable on (a,b):
The change over the interval equals the slope at some interior point times the length. The proofs below use it twice in a row, once in each variable.Review: the mean value theorem
Quick checkWhich condition on the partial derivatives of f near a guarantees that f is differentiable at a?
Quick checkIn this book fxy means (fx)y. For f(x,y)=x2y3, what is fxy?
fx=2xy3, and the y-derivative of that is 6xy2. Here the other order, fyx, gives the same: fy=3x2y2 and (fy)x=6xy2.Review: partial derivatives
The picture: one rectangle, two ways to cut it
Take a rectangle with corners at the origin, (h,0), (0,k) and (h,k), and form the signed sum of f at the four corners, Δ(h,k)=f(h,k)−f(h,0)−f(0,k)+f(0,0). Divide by the area hk. The colour in the picture is that number. A mixed second derivative is exactly a limit of it: shrink k first and you get hfy(h,0)−fy(0,0), then shrink h and you reach fyx(0,0); shrink them in the other order and you reach fxy(0,0). For the smooth function the colours merge into one value as you zoom in, so the two orders give the same limit. For the other one, the colour depends only on the direction, and the two orders give +1 and −1. Everything in the chapter is a proof of what the picture shows.
The idea, in words
The corner sum Δ can be read in two ways. Subtract along vertical edges first: it is the change in the quantity f(x,b+k)−f(x,b) as x moves from a to a+h. By the mean value theorem that change is h times the x-derivative at some point. The x-derivative of f(x,b+k)−f(x,b) is fx(x,b+k)−fx(x,b), again a difference over a vertical edge, and the mean value theorem in y turns it into kfxy at a point. So Δ=hkfxy at some point inside the rectangle. Subtract along horizontal edges first and the same steps give Δ=hkfyx at some other point inside. Two points of the same small rectangle, both values equal to Δ/(hk). If the second partials are continuous, the values at the two points get close to each other as the rectangle shrinks, and both tend to the value at the corner.
Definitions
Definition T
Higher-order partial derivative
Let f be a scalar field on an open set. Its partial derivatives D1f,…,Dnf are again scalar fields, and may have partial derivatives. The second-order partials are DjDif for i,j=1,…,n (differentiate in xi first, then in xj), and in general a partial derivative of order k is Djk⋯Dj2Dj1f. In the plane, with x1=x, x2=y: this book’s fxy is D2D1f (”x first, then y”), Apostol’s D2,1f=D2(D1f) and Leibniz’s ∂y∂x∂2f. Notation conventions differ between books (and Spagnolie’s boards are not consistent), so read the definition each time. We will always say which order a statement uses; for a C2 field it never matters.
In one lineA partial derivative of a partial derivative: differentiate f with respect to one variable, then the result with respect to a variable, and so on k times; the result is a partial derivative of order k.
Why it existsSecond derivatives measure how a field bends, and higher ones are what Taylor's formula needs; they are partial derivatives of the fields that the first partials already are.
Definition T
Mixed partial derivative
A partial derivative of order k≥2 is mixed if the variables it differentiates in are not all the same. In two variables, fxy and fyx are the two mixed second-order partials.
In one lineA higher-order partial derivative in which at least two different variables occur, such as fxy and fyx in two variables.
Why it existsPure second partials like fxx are one-variable derivatives, while mixed ones record how the slope in one direction changes as you move in another, and that is where the order question comes from.
Definition A
Class C^k
Let S⊆Rn be open. A scalar field f:S→R is of class Ck if every partial derivative of order 0,1,…,k exists and is continuous on S. Class C0 is “continuous”; class C1 is the “continuously differentiable” of 5.3; C∞ means all orders. Polynomials, exp, sin, and sums, products, quotients and compositions of them are C∞ where defined (the partials are again such expressions, by the chain rule of 5.4). A vector field is Ck if each component is. The classes get smaller as k grows: x∣x∣ on R is C1 (its derivative is 2∣x∣) and not C2.
In one lineA field is of class Ck on an open set if all its partial derivatives of order at most k exist and are continuous there; C∞ means Ck for every k.
Why it existsIt is the one hypothesis that makes every theorem in this chapter and the next one true, and it extends 'continuously differentiable' (C1) of 5.3 to higher orders.
By the theorem of 5.3, a C1 field is differentiable. If f is C2 then each Dif is C1, hence differentiable, so the gradient field ∇f has a Jacobian matrix, whose (i,j) entry is DjDif. This matrix of second partials is what 5.6 calls the Hessian. Its symmetry, proved below, is why the spectral theorem (3.1) applies to it.
Partial derivatives and differentiability, sharpened
5.3 proved: if all the partials exist near a and are continuous at a, then f is differentiable at a. The proof used the mean value theorem on one coordinate at a time. If you look at where each hypothesis was used, one of the coordinates did not need it.
Theorem Bthe argument of Apostol 8.13, one step sharper
Differentiability from n minus one continuous partials
Suppose the partials D1f,…,Dnf exist on a ball B(a) and D2f,…,Dnf are continuous at a. Then f is differentiable at a and f(a+v)=f(a)+∇f(a)⋅v+∥v∥E(a,v) with E(a,v)→0 as v→O. (Which coordinate is the exceptional one does not matter; relabel.)
In one lineIf D1f,…,Dnf exist in a ball around a, and D2f,…,Dnf are continuous at a (while D1f merely exists at a), then f is differentiable at a with total derivative v↦∇f(a)⋅v.
Why it is trueIt shows how little is needed: one partial derivative of any single coordinate need not even be continuous, so a field can be differentiable at a point where it is not C1 in the sense of 5.3.
ProofApostol 8.13, adapted
The idea: Walk from a to a + v one coordinate at a time, as in 5.3. The first leg changes only the first coordinate: there the definition of the partial derivative at a gives the estimate. Every other leg uses the mean value theorem and continuity of that coordinate's partial at a.
f(a+v)−f(a)=∑k=1n[f(pk)−f(pk−1)].
Same path as in 5.3: p0=a, pk=a+(v1,…,vk,0,…,0), so pn=a+v. Telescoping sum.
First leg: f(p1)−f(a)=v1D1f(a)+r1 with ∣r1∣≤ε∣v1∣.
The first leg is the function t↦f(a+te1) at t=v1; its derivative at t=0 is D1f(a), which exists. Definition of the derivative, with an ε: there is δ1>0 with ∣f(a+v1e1)−f(a)−v1D1f(a)∣≤ε∣v1∣ for ∣v1∣<δ1.
Other legs: f(pk)−f(pk−1)=vkDkf(ck) with ck on the segment from pk−1 to pk.
For k≥2 the legs pk−1→pk differ in coordinate k only, and t↦f(pk−1+tek) is differentiable (the partial exists in the ball). The mean value theorem of 1.4.
For ∥v∥<δ: ∣Dkf(ck)−Dkf(a)∣<ε.
Dkf is continuous at a for k≥2, and ∥ck−a∥≤∥v∥. Choose δ≤δ1 so small that ∣Dkf(x)−Dkf(a)∣<ε for ∥x−a∥<δ and k=2,…,n.
f(a+v)−f(a)−∇f(a)⋅v≤ε∣v1∣+∑k≥2∣vk∣ε≤nε∥v∥. Since ε was arbitrary, f is differentiable at a. ■
Add the legs and subtract ∇f(a)⋅v=∑vkDkf(a). Use ∣vk∣≤∥v∥.Each leg contributes at most ε times |v_k|; that is a factor ε times a length, as the definition of differentiable demands.
Proof workshopGive the reason for each line of the sharper differentiability proofApostol 8.13, adapted
Each line of the proof is shown in order. Choose the reason that justifies it, then press Check.
f(a+v)−f(a)=∑k=1n[f(pk)−f(pk−1)], where pk changes the first k coordinates.
f(p1)−f(a)=v1D1f(a)+r1 with ∣r1∣≤ε∣v1∣.
For k≥2, f(pk)−f(pk−1)=vkDkf(ck).
∣Dkf(ck)−Dkf(a)∣<ε for ∥v∥ small.
∣f(a+v)−f(a)−∇f(a)⋅v∣≤nε∥v∥.
Worked example new (the sharper theorem at work; compare 5.3, the field $(x^2 + y^2)\sin\frac1{x^2 + y^2}$)
Show that f(x,y)=(1+y2)x2sin(1/x) for x=0, f(0,y)=0, is differentiable at the origin although it is not continuously differentiable there.
Solution.
The partials. For x=0: fx=(1+y2)(2xsinx1−cosx1), fy=2yx2sinx1. On the line x=0: fx(0,y)=limh→0h(1+y2)h2sin(1/h)=0, and fy(0,y)=0. Both partials exist at every point of the plane.
fx is not continuous at the origin. Along y=0 and x=2πn1, fx=−cos(2πn)=−1, but fx(0,0)=0. So f is not C1 and the theorem of 5.3 does not apply.
fy is continuous at the origin.∣fy(x,y)∣≤2∣y∣x2→0=fy(0,0). The sharper theorem needs D2f=fy continuous at the point, and D1f=fx only to exist.
Apply the theorem.fx exists in a ball around (0,0), fy exists near it and is continuous at it, so f is differentiable at (0,0) with total derivative v↦0. Direct check: ∣f(v)∣≤(1+y2)x2≤2∥v∥2 for ∥v∥≤1, so f(v)=∥v∥E with E→0.
Answer. Differentiable at the origin, with ∇f=O, while D1f is discontinuous there. The 5.3 test is sufficient and not necessary, and this example shows it can be sharpened but not reversed.
Worked example Apostol 8.24 #1
Apostol 8.24 #1. Find a scalar field f with D1f(0,0)=D2f(0,0)=0 whose derivative at the origin in the direction of i+j exists and equals 3. Explain why f cannot be differentiable at the origin.
Solution.
Try a homogeneous field of degree 1 vanishing on the axes.f(x,y)=x2+y23xy(x+y), f(0,0)=0. On the axes xy=0, so f=0 there and both partials at the origin are 0.
Direction (1,1).f(h,h)=2h23h⋅h⋅2h=3h, so hf(h,h)−f(0)=3 for every h=0, and f′(0;(1,1))=3. The limit is the constant 3.
Why not differentiable. If f were differentiable at O, then by 5.3 f′(O;y)=∇f(O)⋅y for every y, which for y=(1,1) is 0+0=0=3. The formula of 5.3 requires differentiability, and here it gives the wrong value.
Answer.f=x2+y23xy(x+y). In a general direction (a,b) the derivative is a2+b23ab(a+b), which exists but is not linear in (a,b): the same warning as in 5.2.
Worked example Apostol 8.24 #3
Apostol 8.24 #3. Let f(x,y)=x2+y6xy3 for (x,y)=(0,0) and f(0,0)=0. Show that f′(0;a) exists for every vector a and find it, and decide whether f is continuous at the origin.
Solution.
Directions. For a=(a1,a2): f(ha)=h2a12+h6a26h4a1a23, so hf(ha)−f(0)=a12+h4a26ha1a23. If a1=0 this tends to 0 as h→0. If a1=0, then f(ha)=0 for all h. Divide numerator and denominator by h2.
Conclusion for directions.f′(0;a)=0 for every a. Unlike the example of 5.2, this directional derivative is a linear function of a (the zero function): the gradient is O and f′(0;a)=∇f(0)⋅a for all a.
Continuity. Along the curve x=y3: f(y3,y)=y6+y6y3⋅y3=21, but f(0,0)=0. Points with f=21 come arbitrarily close to the origin.
Answer.f′(0;a)=0 for all a, yet f is not continuous at the origin, hence not differentiable. So even “all directional derivatives exist and equal ∇f⋅a” does not give differentiability: the approximation must be good along curves too, not only along lines.
How many partial derivatives are there?
In two variables a function has 2k ordered ways to differentiate k times. For a function of n variables there are nk ordered strings. We will prove that for Ck fields only the number of times each variable occurs matters. That is a choice of a multiset of size k from n variables, and the number of those is (kn+k−1) (put k identical balls into n boxes: k balls and n−1 dividers in a row). For n=3, k=3 it is (35)=10 instead of 27; for n=2, k=4 it is 5 instead of 16.
Your answerHow many different third-order partial derivatives does a C3 function of three variables have, once the order of differentiation does not matter?
Count the ways to write 3 as a sum of three non-negative whole numbers.
A third-order partial is determined by how many of the three differentiations are in x, in y, in z: the non-negative solutions of a+b+c=3. There are (33+3−1)=(35)=10: fxxx,fyyy,fzzz,fxxy,fxxz,fyyx,fyyz,fzzx,fzzy,fxyz.
A function whose mixed partials disagree
Before the theorem, the example it has to survive.
Worked example Apostol 8.23, 8.24 #2; Lecture 24 (the remark on continuity)
Let f(x,y)=x2+y2xy(x2−y2) for (x,y)=(0,0) and f(0,0)=0. Compute fx(0,y) and fy(x,0), and deduce fxy(0,0) and fyx(0,0).
Solution.
fx on the y-axis, from the definition. For y=0: hf(h,y)−f(0,y)=(h2+y2)hhy(h2−y2)=h2+y2y(h2−y2)→−y as h→0. At y=0, f(h,0)=0 so fx(0,0)=0=−0. f(0,y)=0 for all y, so the numerator is f(h,y) alone; cancel the h. So fx(0,y)=−y for every y.
fy on the x-axis. For x=0: kf(x,k)−f(x,0)=x2+k2x(x2−k2)→x as k→0, and fy(0,0)=0. Same computation with the roles swapped. So fy(x,0)=x for every x.
Differentiate once more.fxy(0,0)=dydfx(0,y)y=0=dyd(−y)=−1 and fyx(0,0)=dxdfy(x,0)x=0=dxd(x)=+1. fxy means (fx)y: take fx along the y-axis, where we know it, and differentiate in y. Likewise for fyx.
Cross-check with the rectangle. Since f=0 on both axes, Δ(h,k)=f(h,k) and Δ/(hk)=h2+k2h2−k2. Letting k→0 first gives 1 (then h→0: fyx(0,0)=1), letting h→0 first gives −1. Same two limits as in the picture.
Answer.fxy(0,0)=−1=+1=fyx(0,0) (Apostol: D2,1f(0,0)=−1, D1,2f(0,0)=1). The mixed partials exist at the origin and differ.
Your answerFor the function above, compute Δ(h,k)/(hk) at (h,k)=(3t,t) for any t=0. (Give a decimal.)
Δ=f(h,k) and Δ/(hk)=h2+k2h2−k2=9t2+t29t2−t2=108. The value depends only on the direction, not on t.
What goes wrong? The second partials exist everywhere, but not as continuous functions.
Worked example Apostol 8.23 (the mixed partials 'are not both continuous at the origin')
For the same f, find fxy(x,y) at points (x,y)=(0,0) and show it is not continuous at the origin; show also that f is of class C1.
Solution.
Partials away from the origin.fx=(x2+y2)2y(x4+4x2y2−y4) and fy=(x2+y2)2x(x4−4x2y2−y4). Quotient rule; verified symbolically.
They are continuous at the origin.∣x4+4x2y2−y4∣≤x4+4x2y2+y4=(x2+y2)2+2x2y2≤23(x2+y2)2, so ∣fx∣≤23∣y∣→0=fx(0,0), and likewise ∣fy∣≤23∣x∣. 2x2y2≤21(x2+y2)2. So f is C1 on the plane.
The mixed partial away from the origin. Differentiating fx in y gives fxy=(x2+y2)3(x2−y2)(x4+10x2y2+y4), and differentiating fy in x gives the same expression, so fyx=fxy there. Verified by computer algebra; the numerators agree.
Along the axes. On the x-axis (y=0): fxy=x6x2⋅x4=1. On the y-axis (x=0): fxy=y6(−y2)y4=−1. The limit of fxy at the origin depends on the direction: it does not exist.
Answer.fxy is not continuous at (0,0) (nor is fyx, which is the same function off the origin), and f is C1 but not C2 there. In the next section’s theorem it is exactly this continuity that is missing.
Your answerFor the same f, what is the limit of fxy(0,y) as y→0?
On the y-axis fxy(0,y)=(y2)3(−y2)(y4)=−1, whereas along the x-axis it is +1. The values of fxy and fyx at the origin (−1 and +1) are each the limit along one of the axes.
Quick checkBoth mixed partials of f=x2+y2xy(x2−y2) exist at the origin and are different. What does this tell us?
The theorem proved below needs continuity of the mixed partials at the point. This f is even C1, so it is differentiable at the origin, but it is not C2.
Schwarz’s theorem
Everything in the picture comes from one identity about the rectangle.
Lemma Athe argument of Apostol 8.23
The rectangle lemma
Let S be open, fx and fxy=(fx)y exist on S, and the closed rectangle R with opposite corners (a,b) and (a+h,b+k) (h,k=0) lie in S. Put Δ=f(a+h,b+k)−f(a+h,b)−f(a,b+k)+f(a,b). Then there is (ξ,η) in the interior of R with Δ=hkfxy(ξ,η). By the same argument with the roles of x and y swapped, if fy and fyx exist on S, then Δ=hkfyx(ξ′,η′) for some (ξ′,η′) in the interior of R.
In one lineIf fx and fxy exist on an open set containing the rectangle with corners (a,b) and (a+h,b+k), then Δ(h,k)=hkfxy(ξ,η) for some point (ξ,η) strictly inside the rectangle.
Why it is trueIt converts a combination of four values of f into a second derivative at an unknown interior point, which is how a limit of rectangles becomes a mixed partial.
ProofApostol 8.23
The idea: Group the four corners in pairs along vertical edges to get a one-variable function G with Delta equal to G(a + h) minus G(a). Mean value theorem in x, then mean value theorem in y.
Put G(x)=f(x,b+k)−f(x,b). Then Δ=G(a+h)−G(a) and G′(x)=fx(x,b+k)−fx(x,b).
Pair the corners with the same x-coordinate. G is differentiable on the closed interval between a and a+h since fx exists, so it is continuous there.
Δ=hG′(ξ)=h[fx(ξ,b+k)−fx(ξ,b)] for some ξ strictly between a and a+h.
The mean value theorem for G on the interval between a and a+h (1.4).
The bracket equals kfxy(ξ,η) for some η strictly between b and b+k.
The function y↦fx(ξ,y) is differentiable between b and b+k with derivative fxy(ξ,y) (this is what fxy means). Mean value theorem again.
Δ=hkfxy(ξ,η).
Combine the last two steps. For the second statement, swap x and y: use H(y)=f(a+h,y)−f(a,y), for which Δ=H(b+k)−H(b). ■
Theorem AApostol Thm 8.12; Spagnolie Lecture 24
Equality of mixed partials (Schwarz, Clairaut)
Let S⊆R2 be open with (a,b)∈S, and suppose the partial derivatives fx,fy,fxy,fyx exist on S. If fxy and fyx are both continuous at the point (a,b), then fxy(a,b)=fyx(a,b).
In one lineIf fx, fy, fxy, fyx exist on an open set containing (a,b) and fxy and fyx are both continuous at (a,b), then fxy(a,b)=fyx(a,b).
Why it is trueIt says that when the second derivatives behave (continuously), the order of differentiation does not matter, which makes the matrix of second derivatives symmetric and lets the spectral theorem decide the shape of a critical point.
ProofApostol 8.12; this is the picture above
The idea: Compute the same rectangle sum two ways with the rectangle lemma. Equate. Shrink the rectangle to the point and use continuity of both mixed partials.
Fix small h,k=0 and let Δ=f(a+h,b+k)−f(a+h,b)−f(a,b+k)+f(a,b).
Choose a ball around (a,b) inside S, and take ∣h∣,∣k∣ small enough that the closed rectangle with corners (a,b), (a+h,b+k) lies in the ball. Then the rectangle lemma applies.
Δ=hkfxy(ξ,η) for some (ξ,η) in the open rectangle.
Rectangle lemma, first form (needs fx, fxy).
Δ=hkfyx(ξ′,η′) for some other point (ξ′,η′) in the same open rectangle.
Rectangle lemma, second form (needs fy, fyx).
So fxy(ξ,η)=fyx(ξ′,η′).
Divide by hk=0.
Let (h,k)→(0,0): fxy(a,b)=fyx(a,b). ■
Both points lie within ∣h∣ and ∣k∣ of (a,b), so they tend to (a,b) as (h,k)→(0,0); the left side tends to fxy(a,b) and the right side to fyx(a,b), by continuity at (a,b) of each. A limit is unique.Only continuity at the single point (a, b) is used, not in a neighbourhood, and the proof needs both mixed partials.
Proof workshopRebuild the proof of Schwarz's theoremApostol 8.12
Tap the lines in the order a proof would write them. Each line can only use what is already above it.
The signed sum of f over the four corners of a small rectangle.
Group the corners in pairs with the same x-coordinate.
You need the corner sum before you can regroup it.
The mean value theorem for G, whose derivative is f x at the top edge minus f x at the bottom edge.
The function G has to be defined before you can apply the mean value theorem to it.
The mean value theorem in y for the function y goes to f x at xi and y.
First the x-step must be done, since it produced the bracket this step rewrites.
Group the corners along horizontal edges instead, and use the mean value theorem in y and then in x.
This repeats the argument given in the lines above, so it comes after it.
Divide by h k, then use that both points tend to the corner and both mixed partials are continuous there.
This is the conclusion; it needs both expressions for the corner sum.
Theorem AApostol Thm 8.13; Peano (1890)
Peano's refinement of Schwarz's theorem
Let fx, fy and fxy exist on an open set containing (a,b), with fxy continuous at (a,b). Then fyx(a,b) exists and fyx(a,b)=fxy(a,b).
In one lineIf fx, fy and fxy exist on an open set containing (a,b) and fxy is continuous at (a,b), then fyx(a,b) exists and equals fxy(a,b).
Why it is trueIt says only one of the two mixed partials needs to be continuous: the other is then forced to exist and to agree.
ProofApostol 8.13 (the proof there is longer)
The idea: The rectangle lemma gives the quotient Δ/(hk) as a value of the continuous function f_xy near the corner, so it is close to f_xy(a, b). Letting k go to zero turns the quotient into a difference quotient of f_y, which is the definition of f_yx.
Choose δ so that fxy is within ε of fxy(a,b) on the δ-ball.
Let ε>0. Continuity of fxy at (a,b) gives δ>0 with ∣fxy(p)−fxy(a,b)∣<ε whenever ∥p−(a,b)∥<δ.
For 0<∣h∣,∣k∣<δ/2: hkΔ(h,k)−fxy(a,b)<ε.
Rectangle lemma: Δ(h,k)/(hk)=fxy(ξ,η) with (ξ,η) inside the rectangle, which lies in the δ-ball when ∣h∣,∣k∣<δ/2.
Fix h and let k→0: hfy(a+h,b)−fy(a,b)−fxy(a,b)≤ε for 0<∣h∣<δ/2.
fy exists at (a+h,b) and at (a,b), so limk→0Δ(h,k)/k=fy(a+h,b)−fy(a,b) (definition of fy applied to each of the two columns of Δ).
So fyx(a,b)=limh→0hfy(a+h,b)−fy(a,b) exists and equals fxy(a,b).
Definition of the limit: the difference quotient of fy at (a,b) in the x-direction is within ε of fxy(a,b) for all small h, for every ε. ■
Corollary AApostol 8.23 and Lecture 24
Order does not matter for C^k fields
Let f be Ck on an open set S. If two strings of k differentiations (i1,…,ik) and (j1,…,jk) use each variable the same number of times, then Di1⋯Dikf=Dj1⋯Djkf on S. In particular for k=2 the matrix [DjDif] of a C2 field is symmetric.
In one lineIf f is of class Ck on an open set, then any two partial derivatives of order at most k that differentiate the same number of times in each variable are equal; in particular the matrix of second partials of a C2 field is symmetric.
Why it is trueIt lets you write ∂x2∂y∂3f without saying in what order, and it is the reason the third-order Taylor term has the coefficient 3 in 3Fxxyx2y.
Proofstandard
The idea: Any rearrangement of a string is a sequence of swaps of two neighbours. A swap of two neighbouring differentiations is Schwarz's theorem applied to the partial derivative that has already been taken, which still has two continuous derivatives.
For two differentiations, DjDif=DiDjf by Schwarz’s theorem.
k=2: every second partial of a C2 field is continuous, so the hypotheses of Schwarz's theorem hold at every point (the first and second partials exist by C2).
For general k, it suffices to show that swapping two adjacent differentiations does not change the result.
Rearranging a list into another with the same entries is a product of swaps of adjacent entries.
Let φ be the partial derivative applied before the two neighbours; it is of class C2.
Write the string as Di1⋯Dis−1(DisDis+1)φ where φ=Dis+2⋯Dikf is the part applied first. This φ is a partial derivative of order k−s−1≤k−2 of a Ck field, so it is C2.
So the two orders agree.
Schwarz's theorem for φ: DisDis+1φ=Dis+1Disφ. The remaining outer differentiations are then applied to equal fields. ■
Quick checkWhich hypothesis at (a,b) guarantees fxy(a,b)=fyx(a,b)?
That is Schwarz's theorem. Existence of the mixed partials is not enough (Peano's function), and differentiability of f says nothing about its second partials: the Peano function is even C1, hence differentiable at 0.
Quick checkHow many different fourth-order partial derivatives does a C4 function of two variables have, once order does not matter?
Only the number of x's (0 to 4) matters, so there are 5. The count is (42+4−1)=(45)=5.
Worked example Apostol 8.9 #10 to #12 style
Verify fxy=fyx for f(x,y)=cos(x2)/y (with y=0), and find fxyy.
Solution.
x first.fx=−y2xsin(x2), then fxy=y22xsin(x2). Chain rule on cos(x2); then differentiate y−1.
y first.fy=−y2cos(x2), then fyx=y22xsin(x2). The x-derivative of cos(x2) is −2xsin(x2), and there is an extra minus sign from −cos.
Third order.fxyy=∂y(y22xsin(x2))=−y34xsin(x2). The other orders fyxy and fyyx give the same by the corollary; for instance fyy=y32cos(x2) and ∂x of it is −y34xsin(x2).
Answer.fxy=fyx=y22xsin(x2) and fxyy=fyyx=−y34xsin(x2). The function is C∞ for y=0, so the theorem applies at every point.
Your answerFor f(x,y)=x2y3, what is fxy(1,2)?
fx=2xy3 and fxy=6xy2, which at (1,2) is 6⋅1⋅4=24.
Gradient fields and the necessary condition
Suppose a vector field g=(g1,g2) is the gradient of some C2 function f: g1=fx, g2=fy. Then D2g1=fxy and D1g2=fyx, which are equal by Schwarz’s theorem. So D2g1=D1g2 is a necessary condition for g to be a gradient. (Clairaut used exactly this equality in 1740, to find a condition that Pdx+Qdy must satisfy to be the differential of a function.)
Worked example Practice Final 2013, problem 11; Apostol 8.12 and 9.1
Practice Final 2013, extra credit. Suppose g:R2→R2 is C1. Is g necessarily the gradient of some scalar field? Test g=(2xy+3,x2−1) and g=(−y,x).
Solution.
Necessary condition. If g=∇f with f of class C2, then D2g1=D1g2. Both are fxy=fyx.
Test g=(−y,x).D2g1=−1 and D1g2=+1. They differ, so g is not a gradient. It is the swirl field of 5.1; going once around the origin with it never returns to the same height.
Test g=(2xy+3,x2−1).D2g1=2x=D1g2. The condition holds. It is necessary, not yet sufficient.
Find the potential. Integrate fx=2xy+3 in x: f=x2y+3x+c(y). Then fy=x2+c′(y) must equal x2−1, so c′=−1, c=−y (plus a constant). So f=x2y+3x−y. The condition made the x-dependence of c′ cancel, which is exactly what the integration needed.
Answer. No: a C1 field need not be a gradient, since D2g1=D1g2 can fail. For g=(2xy+3,x2−1) the answer is yes, f=x2y+3x−y.
Your answerThe field g=(2xy+3,x2−1) is the gradient of a function f with f(0,0)=0. What is f(1,2)?
f(x,y)=x2y+3x−y, so f(1,2)=2+3−2=3. (The y-derivative is x2−1 and the x-derivative is 2xy+3, as required.)
Beyond the course: for understanding· The condition is sufficient on a rectangle, and not on a punctured plane
For a C1 field on a rectangle or a disc centred at the origin (a region where the path from (0,0) along the x-axis and then straight up stays inside), D2g1=D1g2 is also sufficient: f(x,y)=∫0xg1(t,0)dt+∫0yg2(x,s)ds has fy=g2 and, differentiating under the integral and using the condition, fx=g1(x,0)+∫0yD2g1(x,s)ds=g1(x,y). On the punctured plane it fails. The field g=x2+y2(−y,x) satisfies D2g1=D1g2=(x2+y2)2y2−x2 everywhere defined, but it is the gradient of the angle θ, which cannot be defined as a single-valued function on the whole punctured plane (the angle grows by 2π as you walk once around the origin). Whether the necessary condition is sufficient depends on the shape of the domain: that is the beginning of de Rham cohomology (MATH 551 and beyond).
Where this came from· From Euler and Clairaut to Schwarz
In 1740 both Euler and Clairaut published a proposed proof that the order of differentiation does not matter. Clairaut’s use for it was the question of when an expression Pdx+Qdy comes from a function: he showed that Py=Qx is then needed. Those arguments were not rigorous. Lagrange gave a proof in 1797, which Cauchy improved in 1823, though it still assumed that the pure second partials fxx and fyy exist and are continuous; further proofs in the 1840s to 1860s were incomplete, and in 1867 Lindelöf gave an explicit example in which the two mixed partials are unequal. Hermann Schwarz gave the first rigorous proof in 1873. Giuseppe Peano’s short note of 1890 improved the theorem to the form of this chapter (Apostol’s 8.13: one mixed partial continuous forces the other to exist and agree). The function x2+y2xy(x2−y2) is the standard example, usually called Peano’s. The problem all of them were solving was how to recognise a gradient, and the answer, equality of mixed partials, turned out to need a hypothesis that nobody had thought to state.
Where it is used
Used inside maths· Inside maths: a symmetric Hessian, and the shape of the next chapter
For a C2 field the matrix H=[DjDif] of second partials is symmetric, so the spectral theorem (3.1) gives it real eigenvalues and orthogonal eigenvectors, and its quadratic form vTHv can be put in the form ∑λiwi2 by a rotation (3.2). That is the entire plan of 5.6: the second-order Taylor formula uses vTHv, and the sign of that form, read off from the eigenvalues, decides whether a critical point is a maximum, a minimum or a saddle. The Taylor coefficients of order k in n variables are the (kn+k−1) distinct partials of order k, each counted with the number of orderings that give it (the factor 3 in 3Fxxyx2y of Lecture 24 is 3 orderings of x,x,y). And equality of mixed partials is what let 5.4 collect fxy+fyx into 2fxy in the wave-equation and Laplace computations.
Used in the real world· Physics and AI: Maxwell's relations, and the cost of a Hessian
In thermodynamics the Helmholtz free energy F(T,V) of a gas has dF=−SdT−pdV, which says S=−FT and p=−FV. Equality of the mixed partials of F gives the Maxwell relation(∂V∂S)T=(∂T∂p)V. Entropy cannot be measured with an instrument, but pressure against temperature at fixed volume can. For one mole of an ideal gas, p=RT/V, so (∂T∂p)V=R/V; the relation then gives (∂V∂S)T=R/V, and doubling the volume at constant temperature raises the entropy by Rln2=8.314×0.693≈5.76J/K. At V=0.025m3 the slope is R/V=332.6Pa/K. In machine learning, the loss of a model with n=106 weights has n2=1012 second partials, but only n(n+1)/2≈5×1011 distinct ones because of this chapter’s theorem, which at 8 bytes each is still about 4 terabytes. That is why second-order methods never form the Hessian. They compute only the product Hv of the Hessian with a vector. It is the derivative in t of ∇f(x+tv), which two gradient evaluations approximate and automatic differentiation computes exactly for a small multiple of the cost of one gradient. Reading it as the gradient of the scalar ∇f⋅v uses the symmetry of H: that gradient is HTv, which equals Hv by this chapter’s theorem.
Python labTwo limits that do not commute
import numpy as npdef peano(x, y): d = x**2 + y**2 return 0.0 if d == 0 else x * y * (x**2 - y**2) / ddef smooth(x, y): return x**2 * y + np.sin(x * y)def Q(f, h, k): # the rectangle quotient Delta(h, k) / (h k) return (f(h, k) - f(h, 0) - f(0, k) + f(0, 0)) / (h * k)for name, f in [("smooth", smooth), ("Peano ", peano)]: print(name) print(" k -> 0 first (k = h/10^4), then h:", [round(Q(f, h, h * 1e-4), 4) for h in (1e-1, 1e-2, 1e-3)]) print(" h -> 0 first (h = k/10^4), then k:", [round(Q(f, k * 1e-4, k), 4) for k in (1e-1, 1e-2, 1e-3)]) print(" along the diagonal h = k: ", [round(Q(f, t, t), 4) for t in (1e-1, 1e-2, 1e-3)]) print(" along the direction (3, 1): ", [round(Q(f, 3 * t, t), 4) for t in (1e-1, 1e-2, 1e-3)])# the mixed partials at the origin: finite differences of finite differencesh = 1e-5fx = lambda f, x, y: (f(x + h, y) - f(x - h, y)) / (2 * h)fy = lambda f, x, y: (f(x, y + h) - f(x, y - h)) / (2 * h)for name, f in [("smooth", smooth), ("Peano ", peano)]: s = 1e-3 fxy = (fx(f, 0, s) - fx(f, 0, -s)) / (2 * s) # x first, then y fyx = (fy(f, s, 0) - fy(f, -s, 0)) / (2 * s) # y first, then x print(name, "f_xy(0,0) ~", round(fxy, 4), " f_yx(0,0) ~", round(fyx, 4))
Try this.Run it. For the smooth function all four ways of shrinking the rectangle approach 1 (the direction (3, 1) gives 1.3, 1.03, 1.003): 1.1, 1.01, 1.001 along the first row, 1.0 along the second, and so on. For Peano's function the answers are +1, -1, 0 and 0.8, one for each way, and they do not move as the rectangle shrinks. The last two lines compute the mixed partials at the origin by finite differences of finite differences: for the smooth function f_xy and f_yx both come out 1; for Peano's function about -1 for f_xy and about +1 for f_yx. Change the direction (3, 1) to (1, 0.1) and check Q = (1 - 0.01)/(1 + 0.01) = 0.9802.
Traps
Watch out· Which order does the notation mean?
∂x∂y∂2f means differentiate in y first, then in x (the operator closest to f acts first). The subscript fxy means x first, then y (this book, reading left to right). Apostol’s D1,2f=D1(D2f) is y first. The same symbol reads in opposite orders in different books. For a C2 function the difference is invisible, which is why the confusion survives; at Peano’s origin it flips the sign.
Watch out· Both mixed partials existing does not make them equal
At the origin, Peano’s function has fxy=−1 and fyx=+1, both existing. Schwarz’s theorem needs continuity of the second partials at the point (both, or one by Peano’s refinement). “Exist” is not enough.
Watch out· Equal mixed partials do not mean continuous
The converse of Schwarz’s theorem is false too: a function can have fxy=fyx at a point without the second partials being continuous there. Equality is a consequence of a hypothesis, not a test for it.
Watch out· C^1 does not give second derivatives
A C1 field has first partials that are continuous; they need not be differentiable. The function x∣x∣ is C1 and has no second derivative at 0. All the theorems of this chapter about second partials assume C2, or at least the existence of the second partials.
Watch out· Count distinct partials with the right formula
For a Ck field of n variables there are (kn+k−1) distinct partials of order k, not nk and not (kn). Three variables, third order: 10, not 27 and not 1.
Problems
checkApostol 8.9 #10 (MATH 375 HW 11)
Compute fxy and fyx for f(x,y)=x4+y4−4x2y2.
Solution
fx=4x3−8xy2, so fxy=−16xy. fy=4y3−8x2y, so fyx=−16xy. Equal, as a polynomial is C∞.
check
How many distinct second-order partials does a C2 function of 4 variables have? How many distinct fifth-order partials does a C5 function of 2 variables have?
Solution
Second order, 4 variables: (24+2−1)=(25)=10 (that is n(n+1)/2 with n=4). Fifth order, 2 variables: (52+5−1)=(56)=6: fx5,fx4y,…,fy5.
checkPractice Final 2013, extra credit (the necessary condition)
Is g(x,y)=(y2,x2) the gradient of a C2 function? Is g(x,y)=(x2,y2)?
Solution
For (y2,x2): D2g1=2y and D1g2=2x, which differ (for example at (1,0): 0 against 2), so it is not a gradient. For (x2,y2): D2g1=0=D1g2, and indeed it is ∇(3x3+y3).
checkApostol 8.24 #2 (the same function)
For Peano’s function, state fx(0,0), fy(0,0), fxy(0,0) and fyx(0,0) and say which hypothesis of Schwarz’s theorem fails.
Solution
fx(0,0)=fy(0,0)=0 (since f vanishes on both axes), fxy(0,0)=−1 and fyx(0,0)=+1. The second partials exist but are not continuous at (0,0): fxy tends to 1 along the x-axis and to −1 along the y-axis. Both continuity hypotheses fail (and by Peano’s refinement, so does the hypothesis on fxy alone).
useApostol 8.14 #10 style, with 5.4
Let f be C2 and let g(t)=f(t,t2). Find g′′(t) in terms of the partials of f, and evaluate at t=1 for f=x2y+xy3.
Solution
By the second-derivative rule of 5.4 with r=(t,t2), r′=(1,2t), r′′=(0,2): g′′=fxx+4tfxy+4t2fyy+2fy (using fxy=fyx). For f=x2y+xy3: fxx=2y, fxy=2x+3y2, fyy=6xy, fy=x2+3xy2. At (1,1): g′′(1)=2+4⋅5+4⋅6+2⋅4=54. Check: g=t2⋅t2+t⋅t6=t4+t7, g′′=12t2+42t5, which at t=1 is 54. ✓
use
Find a function f with fx=2xy2+cosx and fy=2x2y+1, or show there is none.
Solution
Test: D2(2xy2+cosx)=4xy and D1(2x2y+1)=4xy. Equal, so a potential may exist. Integrate fx in x: f=x2y2+sinx+c(y). Then fy=2x2y+c′(y) must equal 2x2y+1, so c=y. Hence f=x2y2+sinx+y (plus a constant).
use
Show that f(x,y)=x2+y2x3y, f(0,0)=0, is differentiable at the origin, find its gradient there, and find fxy(0,0) and fyx(0,0). Is f of class C2?
Solution
∣f∣≤x2+y2∣x∣⋅x2∣y∣≤∣x∣∣y∣≤21∥v∥2, so f(v)=∥v∥E(v) with E→0: differentiable at O with ∇f(O)=O. Away from the origin fx=(x2+y2)2y(3x2(x2+y2)−2x4)=(x2+y2)2yx2(x2+3y2) and fy=(x2+y2)2x3(x2−y2). On the y-axis fx(0,y)=0, so fxy(0,0)=0. On the x-axis fy(x,0)=x, so fyx(0,0)=1. They differ, so f is not C2 at the origin.
provenew (uses 5.4)
Prove that if f is C2 on R2 and fxy≡0, then f(x,y)=φ(x)+ψ(y) for some functions φ,ψ.
Solution
Plan.fx has zero y-derivative, so fx depends on x alone; integrate in x.
∂y(fx)=fxy=0 on all of R2, so for each fixed x the function y↦fx(x,y) has derivative 0 on R and is constant (1.4): fx(x,y)=α(x), where α(x)=fx(x,0). Let φ be an antiderivative of α (it exists since α is continuous). Then ∂x(f−φ(x))=0, so for each fixed y the function x↦f(x,y)−φ(x) is constant: f(x,y)=φ(x)+ψ(y) with ψ(y)=f(0,y)−φ(0). ■
proveApostol 8.9 #20 and #21(b)
Let S be an open convex set (the segment between any two of its points lies in S). Prove that if f′(x;y)=0 for every x∈S and every y, then f is constant on S. (Hint: the mean value theorem for scalar fields from 5.2.)
Solution
Plan. Join two points by a segment and apply the mean value theorem of 5.2 on it.
Let p,q∈S and y=q−p. The segment {p+ty:0≤t≤1} lies in S by convexity. By the mean value theorem for scalar fields (5.2, Apostol 8.4), f(q)−f(p)=f′(z;y) for some z on the segment. By hypothesis f′(z;y)=0, so f(q)=f(p). Since p,q were arbitrary, f is constant. ■ (Every ball is convex, because ∥tp+(1−t)q−a∥≤t∥p−a∥+(1−t)∥q−a∥<r, which recovers the ball case of 5.2.)
prove
Prove that if f is C3 then fxyx=fxxy=fyxx (in the book’s order: the first letter is the first differentiation).
Solution
Plan. Swap neighbours one at a time, each swap being Schwarz’s theorem for a C2 field.
In operator form fxyx=DxDyDxf, fxxy=DyDxDxf and fyxx=DxDxDyf. Put φ=Dxf, which is C2. Schwarz’s theorem for φ gives DxDyφ=DyDxφ, that is, fxyx=fxxy. Schwarz’s theorem for f gives DxDyf=DyDxf everywhere; apply Dx to both sides: DxDxDyf=DxDyDxf, that is, fyxx=fxyx. ■ (In general, any two orders with the same counts agree: this is the corollary.)
provenew (a necessary condition)
Prove that if g=(g1,…,gn) is the gradient of a C2 scalar field, then Djgi=Digj for all i,j; equivalently, the Jacobian matrix of g is symmetric.
Solution
Plan. Write the entries as second partials of f and apply Schwarz’s theorem.
If g=∇f, then gi=Dif, so Djgi=DjDif and Digj=DiDjf. These are second partials of a C2 field, and equal by Schwarz’s theorem. The (i,j) entry of the Jacobian is Djgi and the (j,i) entry is Digj, so the Jacobian is symmetric. ■
stretchnew (the picture of this chapter as a theorem)
Let fx and fxy exist near (a,b) with fxy continuous at (a,b). Prove that the double limit (h,k)→(0,0)limhkΔ(h,k) exists and equals fxy(a,b). Deduce that for Peano’s function fxy cannot be continuous at the origin.
Solution
Plan. The rectangle lemma writes the quotient as a value of fxy at a point of the rectangle.
For small h,k=0 the lemma gives Δ(h,k)/(hk)=fxy(ξ,η) with (ξ,η) within ∣h∣ and ∣k∣ of (a,b). Given ε>0, continuity of fxy at (a,b) gives δ with ∣fxy(p)−fxy(a,b)∣<ε for ∥p−(a,b)∥<δ, so ∣Δ/(hk)−fxy(a,b)∣<ε whenever h2+k2<δ/2. ■ For Peano’s function Δ/(hk)=h2+k2h2−k2 is 0 along h=k and 0.8 along (3t,t), so the double limit does not exist; by the theorem fxy is therefore not continuous at the origin, which we also saw directly.
stretch
Let f be C2 on a disc. Show that the second derivative of f in the direction of a unit vector u=(cosθ,sinθ), defined as dt2d2f(a+tu)t=0, equals fxxcos2θ+2fxysinθcosθ+fyysin2θ. For which θ is it largest, and what is that largest value in terms of the matrix [fxxfxyfxyfyy]?
Solution
By the second-derivative rule along a path (5.4) with r(t)=a+tu, r′=u, r′′=O: dt2d2f(a+tu)=uTHu with H the matrix of second partials, which is the displayed formula (using fxy=fyx). By the spectral theorem (H is symmetric), the maximum of uTHu over unit vectors is the largest eigenvalue of H, attained at the corresponding eigenvector (3.2). So the direction of greatest curvature is an eigenvector of the largest eigenvalue, and the greatest curvature is that eigenvalue. This is the idea of 5.6.
Summary
A higher-order partial derivative is a partial derivative of a partial derivative; a mixed one differentiates in at least two different variables. A field is of class Ck if all partials of order at most k exist and are continuous. C1 implies differentiable (5.3), and C2 makes the gradient differentiable with the matrix of second partials as its Jacobian.
Sharpening 5.3. Existence of all partials near a with n−1 of them continuous at a already gives differentiability at a (proved with the mean value theorem on one coordinate at a time). It is still sufficient and not necessary.
Schwarz’s theorem. If fx,fy,fxy,fyx exist near (a,b) and fxy,fyx are continuous at (a,b), then fxy(a,b)=fyx(a,b). Proof: the rectangle sum Δ equals hkfxy at one interior point and hkfyx at another (mean value theorem twice, in two orders), so the two values get close as the rectangle shrinks. Peano’s refinement: continuity of one mixed partial forces the other to exist and agree.
The counterexample.f=x2+y2xy(x2−y2) has fx(0,y)=−y and fy(x,0)=x, hence fxy(0,0)=−1=+1=fyx(0,0). It is C1 and not C2: fxy tends to 1 along the x-axis and to −1 along the y-axis. The rectangle quotient hkΔ=h2+k2h2−k2 depends on direction only.
Order does not matter for Ck fields; the number of distinct partials of order k in n variables is (kn+k−1). The matrix of second partials of a C2 field is symmetric, so the spectral theorem applies to it (5.6).
Gradient fields.Djgi=Digj is necessary for g to be a gradient (Practice Final extra credit: (−y,x) is not one) and sufficient on a rectangle or disc, though not on the punctured plane.
Watch and read
The same ideas explained by someone else. Use these when an explanation here does not land.
MATH 375: Lecture 24 writes 'F_xy = F_yx if they are continuous (so H = H^T)' and uses it to make the Hessian symmetric; Apostol proves it in 8.23 and the 2013 practice final used it in the extra-credit problem about gradient fields. Homework 11 (8.9 #10 to #12) checked it on examples. Apostol's Theorems 8.12 and 8.13 and his counterexample are proved in full here, as is the sufficiency theorem 8.13 of 5.3 in its sharper form.
MATH 521: 521 proves Schwarz's theorem for functions of two variables with the same rectangle argument, then Fubini-type theorems (interchanging two limits or two integrals), which need the same kind of hypothesis. The Peano example is the standard example of two limits that do not commute.
MATH 340 / CS 532: A loss function with continuous second derivatives has a symmetric Hessian, so Newton and quasi-Newton methods store n(n+1)/2 numbers and use the spectral theorem. The Hessian-vector product, computed without forming the Hessian, relies on this symmetry.
Physics: Thermodynamics' Maxwell relations are the equality of mixed partials of an energy function; they turn quantities that are hard to measure (entropy changes) into ones that are easy (pressure against temperature).