The Mixed Derivative Theorem

x then y or y then x: the same answer.

Two routes to one derivative

A function f(x, y) has two mixed second partial derivatives. One differentiates in x first and then in y, written ∂²f/∂y∂x. The other differentiates in y first and then in x, written ∂²f/∂x∂y.

The routes pass through different first derivatives, ∂f/∂x on one and ∂f/∂y on the other. The mixed derivative theorem says that they arrive at the same function: for a well-behaved f, the order of mixed partial differentiation makes no difference. It is also known as Schwarz’s theorem, or Clairaut’s theorem.

Checking it

Take f(x, y) = x²y³. In x first: ∂f/∂x = 2xy³, and differentiating that in y gives 6xy². In y first: ∂f/∂y = 3x²y², and differentiating that in x gives 6xy². Both routes give 6xy², which is 24 at (1, 2).

Take f(x, y) = e^(xy). In x first: ∂f/∂x = y e^(xy), and in y the product rule gives e^(xy) + x y e^(xy). In y first: ∂f/∂y = x e^(xy), and in x the product rule gives e^(xy) + x y e^(xy). Both are (1 + xy)e^(xy), which is 3e² ≈ 22.17 at (1, 2).

Why the order does not matter

Take a small rectangle with corners (a, b), (a + h, b), (a, b + k) and (a + h, b + k). Find the change in f across the rectangle in the x direction along its top edge, and subtract the same change along its bottom edge. That is f(a + h, b + k) − f(a, b + k) − f(a + h, b) + f(a, b).

Now do it the other way round: the change in the y direction along the right edge, minus the change along the left edge. That is the same four heights with the same four signs. Divided by h k, the first way approximates ∂²f/∂y∂x and the second approximates ∂²f/∂x∂y, and they are one number.

For x²y³ on the rectangle from (1, 2) to (1.5, 2.5), the corner heights are 8, 18, 15.625 and 35.15625. The combination is 35.15625 − 15.625 − 18 + 8 = 9.53125, and divided by 0.5 × 0.5 it is 38.125. The mixed derivative 6xy² at the center of the rectangle, (1.25, 2.25), is 37.97, and the two get closer as the rectangle shrinks.

xyhk

The four corners where x²y³ is measured: (1, 2), (1.5, 2), (1, 2.5) and (1.5, 2.5), with heights 8, 18, 15.625 and 35.15625. The two arrows are the steps h and k, both 0.5. Taking the x differences first or the y differences first uses these same four heights with the same signs.

When it can fail

The theorem needs the mixed partial derivatives to be continuous near the point. Polynomials, exponentials, sines and cosines, and the functions built from them away from a zero denominator, all satisfy that, so for nearly every surface you meet the order does not matter.

The standard exception is f(x, y) = xy(x² − y²)/(x² + y²), with f(0, 0) = 0. Along the y-axis its x-slope is ∂f/∂x = −y, and along the x-axis its y-slope is ∂f/∂y = x. So at the origin ∂²f/∂y∂x = −1, while ∂²f/∂x∂y = 1. The mixed derivatives of this function are not continuous at the origin, so the theorem does not apply there.

The usual mistakes

Expecting the mixed derivatives to differ because their middle steps differ. 2xy³ and 3x²y² are different functions, but both lead to 6xy².

Expecting them to agree only at special points. For x²y³ they are the same function, 6xy², at every point.

Lowering only one power. For x³y³, differentiating in y gives 3x³y², and then in x gives 9x²y²: each differentiation brings its own power down and lowers it by one.

Price and advertising

In the application below, a shop’s weekly sales depend on the price p and the advertising a. One mixed derivative says how advertising changes the effect of the price, and the other says how the price changes the effect of advertising. By the theorem they are the same number.

Worked example: An Online Shop's Price and Advertising: How Each Changes the Sales, and How Each Changes the Effect of the Other

Question An online shop sells a phone case at p dollars and spends a hundred dollars a week on advertising. Its weekly sales are modeled by S(p, a) = 20√a(40 − p) cases, for prices from $10 to $35 and advertising from $400 to $3600 a week. At present p = 20 and a = 16. (a) Find the weekly sales, and ∂ S∂ p and ∂ S∂ a at present, and say what each one means. (b) Find both mixed partial derivatives at present: ∂2 S∂ a   ∂ p, which differentiates first in p and then in a, and ∂2 S∂ p   ∂ a, which takes the other order. Say what each one tells the shop. Then use one of them to estimate ∂ S∂ p if the advertising rises to $2000 a week, and compare the estimate with the exact value.

  1. 1.(a) At present, S(20, 16) = 20 × √16 × (40 − 20) = 20 × 4 × 20 = 1600 cases a week.

    1600320010203040price p, dollarscases sold a weeka = 16(a) S = 20 × 4 × 20 = 1600 cases a week
    1600320010203040price p, dollarscases sold a weeka = 16(a) S = 20 × 4 × 20 = 1600 cases a week
    (a) At a price of $20 with $1600 of advertising a week, the shop sells 1600 cases. The line is the cross-section a = 16: sales against price.
  2. 2.Holding a constant, ∂ S∂ p = −20√a = −80: each extra dollar on the price loses about 80 sales a week. Holding p constant, ∂ S∂ a = 20(40 − p) × 12√a = 10(40 − p)√a = 2004 = 50: each extra $100 of advertising brings about 50 more sales a week.

    1600320010203040price p, dollarscases sold a weeka = 16slope −80(a) S = 20 × 4 × 20 = 1600 cases a weekin p: −20√a = −80, in a: 200/4 = 50
    1600320010203040price p, dollarscases sold a weeka = 16slope −80(a) S = 20 × 4 × 20 = 1600 cases a weekin p: −20√a = −80, in a: 200/4 = 50
    The gradient of that line is ∂ S∂ p = −80 cases per dollar; with the price held, each extra $100 of advertising adds about ∂ S∂ a = 50 cases.
  3. 3.(b) Differentiate ∂ S∂ p = −20√a with respect to a: ∂2 S∂ a   ∂ p = −10√a = −104 = −2.5. Each extra $100 of advertising makes the sales lost per dollar of price about 2.5 cases larger.

    1600320010203040price p, dollarscases sold a weeka = 16slope −80a = 20(a) S = 20 × 4 × 20 = 1600 cases a weekin p: −20√a = −80, in a: 200/4 = 50(b) the p-rate, then in a: −10/√a = −2.5
    1600320010203040price p, dollarscases sold a weeka = 16slope −80a = 20(a) S = 20 × 4 × 20 = 1600 cases a weekin p: −20√a = −80, in a: 200/4 = 50(b) the p-rate, then in a: −10/√a = −2.5
    (b) At a = 20 the line is steeper: ∂ S∂ p changes by about −2.5 for each extra $100 of advertising.
  4. 4.Differentiate ∂ S∂ a = 10(40 − p)√a with respect to p: ∂2 S∂ p   ∂ a = −10√a = −2.5. Each extra dollar on the price makes $100 of advertising bring about 2.5 fewer sales. The two mixed derivatives are equal, as the mixed derivative theorem says, since every second partial derivative of S is continuous for a > 0.

    1600320010203040price p, dollarscases sold a weeka = 16slope −80a = 20mixed: −2.5(a) S = 20 × 4 × 20 = 1600 cases a weekin p: −20√a = −80, in a: 200/4 = 50(b) the p-rate, then in a: −10/√a = −2.5the a-rate, then in p: −10/√a = −2.5
    1600320010203040price p, dollarscases sold a weeka = 16slope −80a = 20mixed: −2.5(a) S = 20 × 4 × 20 = 1600 cases a weekin p: −20√a = −80, in a: 200/4 = 50(b) the p-rate, then in a: −10/√a = −2.5the a-rate, then in p: −10/√a = −2.5
    Differentiating in the other order gives the same −2.5: each extra dollar on the price takes about 2.5 cases off what $100 of advertising brings.
  5. 5.Raising the advertising from a = 16 to a = 20 changes ∂ S∂ p by about −2.5 × 4 = −10, to about −90 cases per dollar. Exactly, ∂ S∂ p = −20√20 ≈ −89.4, so the estimate is within 0.6 of it.

    1600320010203040price p, dollarscases sold a weeka = 16slope −80a = 20mixed: −2.5slope about −90(a) S = 20 × 4 × 20 = 1600 cases a weekin p: −20√a = −80, in a: 200/4 = 50(b) the p-rate, then in a: −10/√a = −2.5the a-rate, then in p: −10/√a = −2.5a = 20: −80 − 2.5 × 4 = −90 per dollar
    1600320010203040price p, dollarscases sold a weeka = 16slope −80a = 20mixed: −2.5slope about −90(a) S = 20 × 4 × 20 = 1600 cases a weekin p: −20√a = −80, in a: 200/4 = 50(b) the p-rate, then in a: −10/√a = −2.5the a-rate, then in p: −10/√a = −2.5a = 20: −80 − 2.5 × 4 = −90 per dollar
    The estimate of the gradient at a = 20 is −90 cases per dollar; the exact gradient is −20√20 ≈ −89.4.

Answer: (a) 1600 cases a week; ∂ S∂ p = −80 cases per dollar and ∂ S∂ a = 50 cases per $100 of advertising; (b) both mixed derivatives are −2.5; the estimate of ∂ S∂ p at $2000 a week is −90 cases per dollar, against −20√20 ≈ −89.4 exactly

Common mistakes

  • Expecting the two mixed derivatives to differ because they describe different effects for the shop. The mixed derivative theorem makes them equal wherever the second partial derivatives are continuous, which holds here for every a > 0.
  • Differentiating √a as 1√a. The derivative of a12 is 12a−12 = 12√a, so ∂ S∂ a at present is 50 cases, not 100.

More partial derivatives problems, worked step by step →

Practice The Mixed Derivative Theorem in the app