Unit 3, lesson 23

Lagrange Multipliers

Why the gradient of a function is parallel to the constraint gradient at a constrained extremum, how to solve the resulting system, and which extra points and checks the method needs.

  • Theory part 45
  • Practice part 46
  • Optimization

Picture a hiking trail drawn on a hilly map. You want the highest point you reach while staying on the trail, which is usually not the top of the hill. At that point the trail runs along a contour line instead of crossing it, and that simple picture is the whole idea behind Lagrange multipliers.

Key terms

Constrained extrema

Definition Let ff be defined on a set containing SS, where SS is the set of points that satisfy one or more equations, the constraints. The function ff has a local maximum on SS at a point a\mathbf{a} of SS if there is a ball BB centered at a\mathbf{a} with f(x)≤f(a)f(\mathbf{x}) \le f(\mathbf{a}) for every x\mathbf{x} in S∩BS \cap B, and an absolute maximum on SS if f(x)≤f(a)f(\mathbf{x}) \le f(\mathbf{a}) for every x\mathbf{x} in SS. Minima are defined with the inequalities reversed. Only points of SS are compared.

In plain words You are allowed to move only along the constraint. A constrained maximum is the best you can do there, even if ff is larger elsewhere.

Example Maximize f(x,y)=xyf(x, y) = xy on the line x+y=10x + y = 10. Substituting y=10−xy = 10 - x gives 10x−x210x - x^2, which is largest at x=5x = 5. The constrained maximum is f(5,5)=25f(5, 5) = 25, although xyxy has no maximum at all on the whole plane. Substitution works here because the constraint is easy to solve, which is often not the case.

Parallel gradients

Definition Let ff and gg have continuous first partial derivatives on an open set UU in Rn\mathbb{R}^n, and let S={x∈U:g(x)=c}S = \{\mathbf{x} \in U : g(\mathbf{x}) = c\}. If ff restricted to SS has a local extremum at a\mathbf{a} and ∇g(a)≠0\nabla g(\mathbf{a}) \ne \mathbf{0}, then there is a number λ\lambda, called a Lagrange multiplier, with

∇f(a)=λ∇g(a).\nabla f(\mathbf{a}) = \lambda \nabla g(\mathbf{a}).

So candidates are found by solving the n+1n + 1 equations ∇f=λ∇g\nabla f = \lambda \nabla g and g=cg = c for the n+1n + 1 unknowns x1,…,xn,λx_1, \dots, x_n, \lambda. The multiplier may be zero, which happens when ∇f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}.

Here is why the condition holds. Take any C1C^1 curve r(t)\mathbf{r}(t) in SS with r(0)=a\mathbf{r}(0) = \mathbf{a}. Differentiating g(r(t))=cg(\mathbf{r}(t)) = c at t=0t = 0 gives ∇g(a)⋅r′(0)=0\nabla g(\mathbf{a}) \cdot \mathbf{r}'(0) = 0, and since f(r(t))f(\mathbf{r}(t)) has a local extremum at t=0t = 0, also ∇f(a)⋅r′(0)=0\nabla f(\mathbf{a}) \cdot \mathbf{r}'(0) = 0. Because ∇g(a)≠0\nabla g(\mathbf{a}) \ne \mathbf{0}, the implicit function theorem shows that such curves reach every vector orthogonal to ∇g(a)\nabla g(\mathbf{a}) as a velocity r′(0)\mathbf{r}'(0). So ∇f(a)\nabla f(\mathbf{a}) is orthogonal to everything that ∇g(a)\nabla g(\mathbf{a}) is orthogonal to, and that forces it to be a multiple of ∇g(a)\nabla g(\mathbf{a}).

In plain words At a constrained high or low point, moving along the constraint does not change ff to first order. So ∇f\nabla f has no component along the constraint and must point straight across it, in the same direction as ∇g\nabla g or the opposite one.

Example Find the extreme values of f(x,y)=x+2yf(x, y) = x + 2y on the circle x2+y2=5x^2 + y^2 = 5. Here ∇g=⟨2x,2y⟩\nabla g = \langle 2x, 2y \rangle is nonzero on the circle, and the system is

1=2λx,2=2λy,x2+y2=5.\begin{gathered} 1 = 2\lambda x, \qquad 2 = 2\lambda y, \\[0.4em] x^2 + y^2 = 5. \end{gathered}

The first equation shows λ≠0\lambda \ne 0 and x≠0x \ne 0, so dividing is allowed and y=2xy = 2x. Then 5x2=55x^2 = 5, which gives the points (1,2)(1, 2) and (−1,−2)(-1, -2) with values 55 and −5-5. The circle is closed and bounded and ff is continuous, so the maximum is 55 and the minimum is −5-5.

Several equality constraints

Definition Let f,g1,…,gmf, g_1, \dots, g_m with m<nm < n have continuous first partial derivatives on an open set UU in Rn\mathbb{R}^n, and let SS be the set of points of UU with g1=c1,…,gm=cmg_1 = c_1, \dots, g_m = c_m. If ff restricted to SS has a local extremum at a\mathbf{a} and the vectors ∇g1(a),…,∇gm(a)\nabla g_1(\mathbf{a}), \dots, \nabla g_m(\mathbf{a}) are linearly independent, then there are numbers λ1,…,λm\lambda_1, \dots, \lambda_m with

∇f(a)=λ1∇g1(a)+…+λm∇gm(a).\begin{aligned} \nabla f(\mathbf{a}) &= \lambda_1 \nabla g_1(\mathbf{a}) + \dots \\[0.4em] &\quad + \lambda_m \nabla g_m(\mathbf{a}). \end{aligned}

Together with the mm constraints this gives n+mn + m equations for n+mn + m unknowns.

In plain words With two constraints in space you move along a curve, the intersection of two surfaces. At an extremum, ∇f\nabla f must lie in the plane spanned by the two constraint gradients.

Example Find the highest and lowest points on the ellipse where the cylinder x2+y2=2x^2 + y^2 = 2 meets the plane x+y+z=1x + y + z = 1, so f=zf = z. The system is

⟨0,0,1⟩=λ⟨2x,2y,0⟩+μ⟨1,1,1⟩,x2+y2=2,x+y+z=1.\begin{aligned} \langle 0, 0, 1 \rangle &= \lambda \langle 2x, 2y, 0 \rangle + \mu \langle 1, 1, 1 \rangle, \\[0.4em] x^2 + y^2 &= 2, \qquad x + y + z = 1. \end{aligned}

The third component gives μ=1\mu = 1, and then 2λx=−12\lambda x = -1 and 2λy=−12\lambda y = -1. So λ≠0\lambda \ne 0 and x=yx = y, hence x=y=±1x = y = \pm 1. The points are (1,1,−1)(1, 1, -1) and (−1,−1,3)(-1, -1, 3). The ellipse is closed and bounded, so the highest value of zz is 33 and the lowest is −1-1.

Independent constraint gradients

Definition A point a\mathbf{a} of the constraint set is regular when ∇g1(a),…,∇gm(a)\nabla g_1(\mathbf{a}), \dots, \nabla g_m(\mathbf{a}) are linearly independent. For one constraint this means ∇g(a)≠0\nabla g(\mathbf{a}) \ne \mathbf{0}. For two constraints in R3\mathbb{R}^3 it means

∇g1(a)×∇g2(a)≠0.\nabla g_1(\mathbf{a}) \times \nabla g_2(\mathbf{a}) \ne \mathbf{0}.

By the implicit function theorem, near a regular point the constraint set is smooth of dimension n−mn - m (a curve, a surface or a higher dimensional analogue), and its tangent directions are exactly the vectors orthogonal to every ∇gi(a)\nabla g_i(\mathbf{a}). This is the hypothesis that makes the multiplier theorem true.

In plain words Independence makes sure the constraints really cut the space down by one dimension each, so the set you move on has a well defined tangent plane or tangent line. Always check it before trusting the multiplier equations.

Example In the cylinder and plane problem,

⟨2x,2y,0⟩×⟨1,1,1⟩=⟨2y,−2x,2x−2y⟩.\begin{aligned} &\langle 2x, 2y, 0 \rangle \times \langle 1, 1, 1 \rangle \\[0.4em] &\quad = \langle 2y, -2x, 2x - 2y \rangle. \end{aligned}

This is zero only when x=y=0x = y = 0, and no such point lies on the cylinder x2+y2=2x^2 + y^2 = 2. So every point of the ellipse is regular and the two candidates found above are the only possible extrema.

Singular constraint points

Definition A point of the constraint set where the constraint gradients are linearly dependent, for one constraint a point where ∇g=0\nabla g = \mathbf{0}, is a singular point of the constraint. The multiplier theorem says nothing there, so an extremum may occur at a singular point without any λ\lambda satisfying the Lagrange equations. Singular points must be added to the list of candidates, together with any points where ff or gg fails to have continuous partial derivatives.

In plain words Where the constraint curve has a cusp or crosses itself, the picture of a smooth trail breaks down. Check those points by hand.

Example Minimize f(x,y)=xf(x, y) = x on the cusp curve y2=x3y^2 = x^3, so g=y2−x3g = y^2 - x^3. Both functions have continuous partial derivatives everywhere, so the only extra candidates are singular points. The equations 1=−3λx21 = -3\lambda x^2 and 0=2λy0 = 2\lambda y force λ≠0\lambda \ne 0, so y=0y = 0, then x=0x = 0 from the curve, and the first equation becomes 1=01 = 0. There are no Lagrange solutions at all. Yet every point of the curve has x3=y2≥0x^3 = y^2 \ge 0, hence x≥0x \ge 0, so the minimum is 00, reached only at the origin, where ∇g=⟨−3x2,2y⟩=⟨0,0⟩\nabla g = \langle -3x^2, 2y \rangle = \langle 0, 0 \rangle. The origin is a singular point, and the extremum sits exactly there. There is no maximum, since xx is unbounded on the curve.

Feasible boundaries

Definition The feasible set is the set of all points that satisfy every constraint. If some constraints are inequalities, such as x≥0x \ge 0 or G(x,y)≤cG(x, y) \le c, the feasible set can have interior points, smooth boundary pieces and points where those pieces meet. The full candidate list then contains the critical points of ff in the interior, the Lagrange points on each smooth boundary piece given by an equation with nonzero gradient, and the endpoints, corners and singular points of the boundary.

In plain words Lagrange multipliers handle the smooth parts of an edge. The inside of the region and the places where edges meet still need their own checks.

Example Find the extreme values of f(x,y)=x2+2y2f(x, y) = x^2 + 2y^2 on the disk x2+y2≤1x^2 + y^2 \le 1. Inside, ∇f=⟨2x,4y⟩\nabla f = \langle 2x, 4y \rangle is zero only at (0,0)(0, 0), where f=0f = 0. On the circle g=x2+y2=1g = x^2 + y^2 = 1, with ∇g≠0\nabla g \ne \mathbf{0}, the equations are

2x=2λx,4y=2λy.2x = 2\lambda x, \qquad 4y = 2\lambda y.

If x≠0x \ne 0 then λ=1\lambda = 1, so y=0y = 0 and x=±1x = \pm 1, with f=1f = 1. If x=0x = 0 then y=±1y = \pm 1, with f=2f = 2. Keeping the case x=0x = 0 instead of dividing by xx is what finds these points. The maximum is 22 at (0,±1)(0, \pm 1) and the minimum is 00 at the origin.

Candidate verification

Definition The Lagrange conditions are necessary, not sufficient. A point that satisfies them may be a maximum, a minimum or neither. To finish a problem, collect all candidates (Lagrange points, singular points, interior critical points and boundary endpoints or corners) and then justify which is which. If the feasible set is closed and bounded and ff is continuous there, the extreme value theorem guarantees an absolute maximum and minimum, and comparing the values of ff at the candidates identifies them. If the feasible set is not compact, existence must be argued separately, for instance with an inequality or the behavior of ff far away.

In plain words The method hands you suspects, not verdicts. Compactness lets you decide by comparing numbers, and without it you need a reason.

Example Look at f(x,y)=x+yf(x, y) = x + y on the hyperbola xy=1xy = 1. The equations 1=λy1 = \lambda y and 1=λx1 = \lambda x give x=yx = y, so the candidates are (1,1)(1, 1) with f=2f = 2 and (−1,−1)(-1, -1) with f=−2f = -2. The hyperbola is not bounded. On the branch with x>0x > 0 the values are x+1x≥2x + \tfrac{1}{x} \ge 2, and on the branch with x<0x < 0 they are at most −2-2 and go to −∞-\infty. So (1,1)(1, 1) is a local minimum on the constraint and (−1,−1)(-1, -1) a local maximum, and ff has no absolute maximum or minimum. The local maximum value is even smaller than the local minimum value.

Check yourself

  1. Find the extreme values of f(x,y)=xyf(x, y) = xy on the ellipse x2+4y2=8x^2 + 4y^2 = 8.
Show the answer

The constraint gradient ⟨2x,8y⟩\langle 2x, 8y \rangle is nonzero on the ellipse. The equations are y=2λxy = 2\lambda x and x=8λyx = 8\lambda y. If y=0y = 0 then x=0x = 0, which is not on the ellipse, so y≠0y \ne 0 and y=16λ2yy = 16\lambda^2 y gives λ=±14\lambda = \pm \tfrac{1}{4}, that is y=±x2y = \pm \tfrac{x}{2}. Then 2x2=82x^2 = 8, so x=±2x = \pm 2. The maximum is 22 at (2,1)(2, 1) and (−2,−1)(-2, -1), and the minimum is −2-2 at (2,−1)(2, -1) and (−2,1)(-2, 1), since the ellipse is closed and bounded.

  1. Find the minimum of x2+y2x^2 + y^2 on the hyperbola xy=1xy = 1 and justify that it is a minimum.
Show the answer

The constraint gradient ⟨y,x⟩\langle y, x \rangle is never zero on the hyperbola. The equations 2x=λy2x = \lambda y and 2y=λx2y = \lambda x give 2x2=λxy=2y22x^2 = \lambda xy = 2y^2, so x2=y2x^2 = y^2, and with xy=1xy = 1 this means x=y=±1x = y = \pm 1. Both points give the value 22. The hyperbola is not bounded, so comparing values is not enough. The inequality (x−y)2≥0(x - y)^2 \ge 0 gives x2+y2≥2xy=2x^2 + y^2 \ge 2xy = 2 for every point of the hyperbola, so 22 is the minimum. There is no maximum.

  1. Find the extreme values of f(x,y)=2x+yf(x, y) = 2x + y on the quarter circle x2+y2=1x^2 + y^2 = 1 with x≥0x \ge 0 and y≥0y \ge 0.
Show the answer

On the open arc the constraint gradient ⟨2x,2y⟩\langle 2x, 2y \rangle is nonzero, and ⟨2,1⟩=λ⟨2x,2y⟩\langle 2, 1 \rangle = \lambda \langle 2x, 2y \rangle gives x=2yx = 2y. Of the two solutions on the circle only the one with x,y>0x, y > 0 lies on the arc, so the point is (25,15)\left(\tfrac{2}{\sqrt{5}}, \tfrac{1}{\sqrt{5}}\right) with f=5f = \sqrt{5}. The arc has endpoints (1,0)(1, 0) and (0,1)(0, 1), with f=2f = 2 and f=1f = 1. The arc is closed and bounded, so the maximum is 5\sqrt{5} and the minimum is 11 at the endpoint (0,1)(0, 1), a point the multiplier equations alone would miss.

How this lesson connects

It also uses Gradients and regular level sets, Absolute extrema and Linear independence and dot products.