hanegreefs.com/Math I
Chapter 8 of 8

Functions of several variables and optimisation

Functions of two or more variables, distance and level curves, limits and continuity, partial and directional derivatives, the second derivative test with D = AC − B2, and constrained optimisation by substitution and with a Lagrange multiplier.

Syllabus: Syllabus ch. 8 · Sessions: Lecture 11, WPO 10 · About 55 minutes

Functions of several variablesNeutral

Many economic quantities depend on more than one input: output on labour and capital, utility on two goods, profit on two prices. A function f : ℝ2 → ℝ assigns a number z = f(x, y) to each point of its domain in the plane; its graph is a surface in three dimensions.

The distance between points in ℝn generalises Pythagoras: d(P, Q) = √((x1 − y1)2 + ... + (xn − yn)2). With it, limits and continuity work as before: f(x, y) → L when (x, y) → (a, b) means f gets close to L whenever the point is close to (a, b), along every possible path.

A level curve f(x, y) = k collects all points with the same value, like the contour lines on a map. In economics, level curves of a utility function are indifference curves and those of a production function are isoquants.

Worked example

Domain and a level curve

f(x, y) = ln(x + y) and g(x, y) = x2 + y2.

1

Domain of f

x + y > 0: the half-plane above the line y = −x
2

Level curve g = 9

x2 + y2 = 9, a circle with radius 3
Answer

The heat maps in the labs show level structure as shades: darker is higher.

Partial derivativesImportant

The partial derivative fx = ∂f/∂x is the derivative with respect to x while y is held constant; fy likewise. It is the slope of the surface in the x-direction or the y-direction. All single-variable rules apply, with the other variable treated as a number.

Worked example

Partials of f(x, y) = x2y + exy

Treat the other variable as a constant.

1

With respect to x

fx = 2xy + y exy
2

With respect to y

fy = x2 + x exy
3

Second order

fxy = 2x + exy + xy exy = fyx
Answer

For smooth functions the mixed partials are equal (Schwarz's theorem), which is a handy check.

The gradient ∇f = (fx, fy) points in the direction of steepest increase. The directional derivative in the direction of a unit vector u = (u1, u2) is Duf = fx u1 + fy u2 = ∇f · u. Example: for f = x2 + 3xy at (1, 2), ∇f = (8, 3), and in the direction (3, 4)/5 the slope is (24 + 12)/5 = 7.2.

Economic reading: for a production function Q(L, K), QL is the marginal product of labour and QK the marginal product of capital.

Unconstrained optimisationImportant

A local extremum of a smooth f(x, y) can only occur at a critical point, where fx = 0 and fy = 0. To classify it, compute the second partials at that point, A = fxx, B = fxy, C = fyy, and the determinant D = AC − B2:

ConditionConclusion
D > 0 and A > 0local minimum
D > 0 and A < 0local maximum
D < 0saddle point (up in one direction, down in another)
D = 0the test says nothing (outside the course scope)
Worked example

Classify the critical points of f(x, y) = x3 − 3x + y2 − 4y

Solve the first order conditions, then test each point.

1

First order conditions

fx = 3x2 − 3 = 0 and fy = 2y − 4 = 0, so (1, 2) and (−1, 2)
2

Second partials

A = 6x, B = 0, C = 2
3

At (1, 2)

D = 12 > 0 and A = 6 > 0: local minimum, f = −6
4

At (−1, 2)

D = −12 < 0: saddle point
Answer

Always test every critical point separately.

Worked example

A firm with two products

Profit π(x, y) = 50x + 40y − x2 − xy − y2.

1

First order conditions

50 − 2x − y = 0 and 40 − x − 2y = 0
2

Solve

x = 20, y = 10
3

Test

A = −2, B = −1, C = −2, D = 4 − 1 = 3 > 0 with A < 0: maximum
Answer

Maximum profit π(20, 10) = 700. The second derivative test lab handles any quadratic function of x and y.

Constrained optimisationImportant

Often not every combination is allowed: a budget, a fixed total, a production target. To optimise f(x, y) subject to g(x, y) = c there are two routes.

Substitution: if the constraint is easy to solve for one variable, plug it into f and optimise a one-variable function. Lagrange multiplier: form L(x, y, λ) = f(x, y) − λ(g(x, y) − c) (the syllabus writes + λ, which only flips the sign of λ) and solve the three equations Lx = 0, Ly = 0 and Lλ = 0, the last of which is the constraint itself.

Worked example

Substitution: minimise (x − 2)2 + (y + 2)2 with y − x = 2

The constraint gives y = x + 2.

1

Plug in

h(x) = (x − 2)2 + (x + 4)2
2

Differentiate

h'(x) = 2(x − 2) + 2(x + 4) = 4x + 4 = 0, so x = −1
3

Back to y

y = 1, and h'' = 4 > 0: a minimum
Answer

The minimum is f(−1, 1) = 9 + 9 = 18: the squared distance from the point (2, −2) to the line y = x + 2.

Worked example

Lagrange: maximise utility U = xy with budget 2x + 4y = 40

L = xy − λ(2x + 4y − 40).

1

Lx = 0 and Ly = 0

y = 2λ and x = 4λ, so x = 2y
2

Constraint

2(2y) + 4y = 40 gives y = 5 and x = 10
3

Multiplier

λ = y/2 = 2.5
Answer

The best bundle is (10, 5) with U = 50. λ = 2.5 is the extra utility from one more unit of budget: the marginal utility of money.

Common trapSolving Lx = 0 and Ly = 0 is not enough: the constraint Lλ = 0 is the third equation, and you need all three.

Key takeaways

  • fx: differentiate in x with y held constant; mixed partials are equal for smooth f.
  • Gradient = direction of steepest increase; directional derivative = ∇f · u with |u| = 1.
  • Critical point: fx = fy = 0.
  • D = AC − B2: D > 0 with A > 0 minimum, A < 0 maximum; D < 0 saddle.
  • Constraint: substitute when easy, otherwise Lagrange with three equations.
  • λ measures how the optimum responds to relaxing the constraint.

Loading cards
Question
Click, tap or press space to flip
Answer

Multiple choice (9)

Question 1 · Chapter 8

For f(x, y) = x2y3, fy equals...

Why: x2 is a constant when differentiating in y.
Question 2 · Chapter 8

For f(x, y) = e2x sin y, fxy equals...

Why: fx = 2e2x sin y, then differentiate in y.
Question 3 · Chapter 8

At a critical point A = 4, B = 3, C = 2. The point is...

Why: D = 8 − 9 = −1 < 0.
Question 4 · Chapter 8

At a critical point A = −3, B = 1, C = −2. The point is...

Why: D = 6 − 1 = 5 > 0 and A < 0.
Question 5 · Chapter 8

The critical point of f = x2 + y2 − 2x + 6y is...

Why: 2x − 2 = 0 and 2y + 6 = 0.
Question 6 · Chapter 8

Maximise xy subject to x + y = 10. The maximum is...

Why: y = 10 − x gives 10x − x2, maximal at x = 5.
Question 7 · Chapter 8

In L = f − λ(g − c), the equation Lλ = 0 is...

Why: Differentiating in λ returns the constraint.
Question 8 · Chapter 8

The gradient of f = 3x + 4y at any point is...

Why: Constant partials.
Question 9 · Chapter 8

The directional derivative of f = 3x + 4y in the direction (3, 4)/5 is...

Why: (9 + 16)/5.

Exam-style open questions (3)

Open question · Chapter 8

Classify critical points

Find and classify the critical points of f(x, y) = x2 + xy + y2 − 3x.

Show the worked outline
  • fx = 2x + y − 3 = 0, fy = x + 2y = 0.
  • Solve: x = 2, y = −1.
  • A = 2, B = 1, C = 2, D = 3 > 0 with A > 0: local minimum, f(2, −1) = −3.
Open question · Chapter 8

Lagrange

Minimise the cost C = 4L + 9K of producing Q = LK = 36.

Show the worked outline
  • L = 4L + 9K − λ(LK − 36).
  • 4 = λK and 9 = λL, so 4L = 9K.
  • With LK = 36: L = 9, K = 4, cost 72, λ = 1.
Open question · Chapter 8

Check with substitution

Solve the January 2024 constraint question in both ways: minimise (x − 2)2 + (y + 2)2 subject to y − x = 2, first by substitution and then with a Lagrange multiplier.

Show the worked outline
  • Substitution: y = x + 2 gives 4x + 4 = 0, x = −1, y = 1, value 18.
  • Lagrange: 2(x − 2) = −λ and 2(y + 2) = λ with y − x = 2.
  • Adding the first two gives x + y = 0; with y − x = 2 this is x = −1, y = 1, λ = 6.
  • Both routes give the minimum 18 at (−1, 1).

LabSecond derivative test lab

Try the minimum, maximum and saddle examples.

LabLagrange multiplier lab

Includes the January 2024 exam question and a utility maximisation.