To extremise a field f on the set where g = c, look for points where the gradient of f is a multiple of the gradient of g, because there the level curve of f touches the constraint without crossing it. The multiplier is a number you solve for, and it equals the rate at which the best value changes when the constraint moves. The proof reduces to an ordinary extremum by solving the constraint with the implicit function theorem, and a bordered Hessian decides between maximum and minimum.
Taught in 375/376Apostol, not taughtBeyond the courseMATH 376, Worksheets 1 and 3 and Homework 1 (the Lagrange warm-up)MATH 375, Lecture 24 (extrema on a region, check the boundary)Apostol Vol. 2, 9.14 and 9.15Lagrange, Mécanique analytique (1788)Rudin, Principles of Mathematical Analysis, Thm 9.28 (the implicit function step)Markowitz, Portfolio Selection, Journal of Finance (1952)
You have a field f and you may not look at the whole plane or space: only at points that satisfy an equation, such as a circle, a plane, or a budget. Where is f largest on that set, and where is it smallest? The rule from 5.2 (∇f=O at an interior extremum) cannot be the answer, because the constraint set has no interior points: stepping off it breaks the constraint. In JEE you solved such problems by substituting one equation into the other to leave one variable. That works when the constraint can be solved for a variable, and the implicit function theorem of 5.7 says it can be, locally, at a regular point, even when you cannot write the formula. Lagrange’s idea is to do the substitution without doing it: the condition for an extremum can be written in a form where the symmetry between the variables is kept, and where the extra unknown λ that appears turns out to be a quantity with a meaning.
Before you start
5.6: critical points, the second-derivative test, and why an absolute extremum on a compact set exists. 5.7: regular points, and level sets as graphs. 5.3: the gradient is perpendicular to level sets.
Quick checkThe minimum of f(x,y)=x2+y2 on the line x+y=2 is at (1,1). Is ∇f(1,1)=O?
The rule ∇f=O is for interior points of the domain: it compares f(a) with the values at points in every direction around a. On a line only two directions are allowed, and f does not change to first order along the line, which is a weaker statement.Review: where the derivative must vanish
Quick checkAt a point of the circle x2+y2=1, which vector is perpendicular to the circle?
The circle is a level curve of g, and the gradient of a field is perpendicular to its level curves (the velocity of a curve inside the level set is perpendicular to it).Review: gradient and level sets
Quick checkFor g(x,y,z)=x2+y2+z2, which points of the level set g=0 are regular points?
A regular point of a single equation has ∇g=O. The set x2+y2+z2=0 is the single point O and ∇g(O)=O. For g=c with c>0 every point of the sphere is regular.Review: regular points
The picture: when two curves touch
Slide the dot along the blue constraint. The orange curves are level curves of f. As the dot slides, it crosses some level curves and so f changes: the plot on the right goes up or down. At a few special positions the plot is flat, and on the left the two arrows point the same way (or exactly opposite ways). There the level curve of f through the dot is tangent to the constraint: it touches it and turns back, and the constraint stays on one side of it. That is the maximum or minimum. Choose the second and third pictures to see a minimum and the eigenvalue structure; choose the last one to see where the method breaks.
The idea, in words
Apostol’s picture (9.14) of the nearest point to the origin: inflate a ball (a level set of f(x)=∥x∥) from radius 0 until it first touches the constraint surface. At the first contact the ball and the surface are tangent. Two tangent surfaces have the same tangent plane, hence the same normal line, hence parallel gradients. The first contact is the minimum of f on the surface, since any smaller ball has not reached it.
Why· The same fact without pictures
Take any curve r(t) lying in the constraint set, through the candidate point a at t=0. The function t↦f(r(t)) has an extremum at t=0, so its derivative is 0 there, and by the path theorem of 5.3 that derivative is ∇f(a)⋅r′(0). So ∇f(a) is perpendicular to every tangent vector r′(0) of the constraint. But ∇g(a) is also perpendicular to all of them. In the plane or in space with one constraint, the vectors perpendicular to the tangent vectors form a single line, so ∇f(a) and ∇g(a) lie on one line: ∇f(a)=λ∇g(a).
Where this came from· Lagrange and the statics of constrained bodies
Joseph-Louis Lagrange wanted one method for the statics and dynamics of bodies whose parts are tied together by constraints (a bead on a wire, a rigid rod, the links of a chain). In his Mécanique analytique (1788) he combined the principle of virtual velocities, due to Johann Bernoulli, with the multipliers that now carry his name; the rule had appeared in his earlier work on the calculus of variations, and the 1788 treatise is where he stated it in its modern form. The mechanical meaning survives: in mechanics the multipliers are the forces by which the constraints push on the system, and the theorem later in this chapter shows that in optimisation the multiplier is the derivative of the best value with respect to the constraint, the price of the constraint.
Definitions and the theorem
Definition T
Constrained extremum
Let f:U→R and g=(g1,…,gm):U→Rm be fields on an open set U⊆Rn with m<n, and let S={x∈U:g(x)=c} (the constraint set, the common level set of the gi). A point a∈S is a local constrained maximum of f if there is a ball B(a,r) with f(x)≤f(a) for every x∈S∩B(a,r); a local constrained minimum with ≥. Together: constrained extrema. As in 5.6, absolute ones compare with all of S. This is the 376 definition: ‘a local extremum at P on g=k’.
In one lineA point a with g(a)=c such that f(x)≤f(a) (a maximum) or f(x)≥f(a) (a minimum) for all nearby x that also satisfy g(x)=c.
Why it existsIt is the precise form of 'largest or smallest value of f on the constraint', and it only compares f(a) with values on the constraint set, never with values off it.
Definition T
Lagrange multiplier
When ∇f(a)=λ1∇g1(a)+⋯+λm∇gm(a), the numbers λ1,…,λm are the Lagrange multipliers of f with respect to the constraints at a. The sign convention varies (f−λg here, f+λg in some books); the points found are the same and only the sign of λ changes.
In one lineA number λi in the equation ∇f(a)=∑iλi∇gi(a); there is one multiplier for each constraint.
Why it existsIt is the coefficient that expresses the gradient of f in terms of the constraint gradients; it turns a search over a curved set into algebraic equations and, by the theorem below, measures how much the best value would change if the constraint were loosened.
Definition T
Lagrangian
The Lagrangian is L(x,λ)=f(x)−∑i=1mλi(gi(x)−ci). Its partial derivatives are ∂xk∂L=∂xk∂f−∑iλi∂xk∂gi (the k-th component of ∇f−∑λi∇gi) and ∂λi∂L=−(gi−ci) (the i-th constraint). Setting all n+m of them to 0 is the system the method solves.
In one lineThe field L(x,λ)=f(x)−∑iλi(gi(x)−ci) of n+m variables, whose critical points are exactly the solutions of ∇f=∑λi∇gi together with the constraints.
Why it existsIt packages the n+m equations of the method into one 'find the critical points' problem, so that the machinery of 5.6 can be reused.
Theorem TMATH 376 Worksheet 3 #5 (m = 1, n = 3) and Warm-up; Apostol 9.14; Rudin Thm 9.28
Lagrange multiplier theorem
Let f,g1,…,gm be continuously differentiable on an open set U⊆Rn, m<n, and S={g=c}. Suppose f∣S has a local extremum at a∈S and a is a regular point of g. Then there are unique λ1,…,λm∈R with
∇f(a)=λ1∇g1(a)+⋯+λm∇gm(a).
In one lineIf f,g1,…,gm are C1, f has a local constrained extremum at a, and a is a regular point of g (the gradients ∇gi(a) are linearly independent), then ∇f(a)=∑λi∇gi(a) for unique numbers λi.
Why it is trueIt reduces a problem on a curved set to n+m equations in n+m unknowns, and it names the one hypothesis that cannot be skipped: the constraint gradients must be independent.
ProofWorksheet 3 #5 (in space), Rudin Thm 9.28 (general)
The idea: At a regular point the implicit function theorem lets us solve the constraint for m of the variables as functions of the other n minus m, so the constraint set is a graph and f restricted to it is an ordinary function of n minus m free variables with an interior extremum. Its gradient is zero. Writing that gradient with the chain rule, and defining lambda to match the m solved coordinates, gives the equation in the other coordinates automatically.
Write x=(u,w) with u∈Rn−m, w∈Rm, and a=(au,aw), such that the m×m matrix Dwg(a) is invertible.
The m×n Jacobian Dg(a) has rank m (regular point), so some m of its columns are independent (2.6). Renumber the variables so that these are the last m columns. Then Dwg(a) is invertible.
There is a C1 function h near au with h(au)=aw and g(u,h(u))=c, and near a the constraint set is the graph {(u,h(u))}.
Implicit function theorem (5.7) for g(u,w)−c=O.
Define φ(u)=f(u,h(u)). It has an ordinary local extremum at au, an interior point of an open set of Rn−m.
Every u near au gives the point (u,h(u)) of S near a, and every point of S near a is of this form. So φ inherits the extremum of f∣S at the point au.
So ∇φ(au)=O.
Partial derivatives vanish at an interior extremum (5.2).
∇uf(a)+Dh(au)T∇wf(a)=O.
Chain rule (5.4): u↦(u,h(u)) has Jacobian [IDh], so the gradient of the composite is ∇uf+DhT∇wf, with everything evaluated at a.
Dh(au)=−Dwg(a)−1Dug(a).
Differentiate the identity g(u,h(u))=c (chain rule): Dug+DwgDh=0, and solve with the invertible Dwg.
Put λ=(Dwg(a)T)−1∇wf(a)∈Rm.
Define λ so that the last m components of the claimed equation hold: ∇wf=(Dwg)Tλ=∑iλi∇wgi. This is possible because (Dwg)T is invertible.This is the 'where does the idea come from' step. We have m numbers to choose and m equations to satisfy, and the matrix is invertible exactly because the point is regular.
∇uf(a)=Dug(a)Tλ=∑iλi∇ugi(a).
Substitute Dh=−Dwg−1Dug into the equation of the fifth step; transposing gives DhT=−DugT(DwgT)−1. Then ∇uf=−DhT∇wf=DugT(DwgT)−1∇wf=DugTλ.
So ∇f(a)=∑iλi∇gi(a), with unique λi. ■
The u-components and the w-components together make the whole vector. Uniqueness: if two lists of multipliers worked, their difference would be a linear relation among the independent gradients ∇gi(a), so it is zero.
Proof workshopRebuild the proof of the Lagrange multiplier theoremRudin Thm 9.28; MATH 376 Worksheet 3 #5
Tap the lines in the order a proof would write them. Each line can only use what is already above it.
Rank m means m independent columns; renumber the variables so they come last.
The block of the Jacobian for the solved variables is invertible.
You must have the invertible block before you can solve for w.
Points of the constraint near a are exactly the points u and h of u, so f restricted to the constraint is phi; then Fermat's rule and the chain rule.
The restricted function phi only exists once the constraint set is a graph.
The chain rule on a constant function, solved with the invertible block.
The formula for the derivative of h is needed to rewrite the equation of the previous line.
The transposed block is invertible, so the m equations in the w-components can be solved for the m unknown multipliers.
This is the choice that makes the second half of the equation work; it uses the invertibility again.
Substitute the formula for the derivative of h, transpose, and recognise the multiplier vector.
You need both the formula for Dh and the definition of lambda to finish.
Quick checkIn the proof, why does the extremum of f∣S at a become an ordinary extremum of φ with ∇φ=O?
Fermat's rule (zero derivative at an interior extremum) needs the point to be interior to the domain. The domain of f∣S has no interior in Rn, but after parametrising S by u it is an open set of Rn−m. That is the whole role of the implicit function theorem here.
Why· The picture behind the proof, in space (the version from Worksheet 3 #5)
In R3 with one constraint g=c and ∇g(P)=O, say gz(P)=0. Near P the level set is a graph z=h(x,y), parametrised by r(u,v)=(u,v,h(u,v)), and the two tangent vectors ru, rv span the tangent plane (5.7). Differentiating g(r)=c shows ∇g⋅ru=∇g⋅rv=0; differentiating f(r), which has a critical point, shows ∇f⋅ru=∇f⋅rv=0. The vectors perpendicular to a plane in space form one line, so ∇f is a multiple of ∇g (here ∇g=O). In the visualiser above, this is the red arrow lining up with the purple one.
Watch out· Two hypotheses the theorem needs, and one thing it does not say
(1) The point must be regular: ∇g(a)=O for one constraint, independent gradients for several. If it is not, the theorem says nothing, and the point must be examined separately (the cusp y2=x3 in the examples). (2) f,g must be C1. (3) The theorem is a necessary condition: it produces candidates. It does not say that an extremum exists, nor which candidate is the maximum. You need an existence argument (a continuous function on a compact set has a largest and a smallest value, 4.3 and 5.6) or a growth argument.
The recipe
A preview· The method, as used in MATH 376 (WS3 solution key)
Write the constraint as g=c. List the points of the constraint where ∇g=O (or where the gradients of several constraints are dependent). They are candidates of their own.
Solve ∇f=∑λi∇gi together with g=c: n+m equations for n coordinates and m multipliers. The usual trick is to solve each coordinate in terms of λ, substitute in the constraint, and find λ; or to divide one component equation by another (after checking the divisor is not 0).
List all candidate points.
Evaluate f at each candidate. Decide the maximum and the minimum by an existence argument (compact set, or f→∞ along every unbounded direction) or by geometry. If asked for a distance, use the squared distance (same minimiser, no square root).
Examples from the course
Worked example MATH 376 Worksheet 1 #5
Find the largest and smallest values of f(x,y)=xy on the circle x2+y2=1.
Solution.
Set up.g=x2+y2, constraint g=1. ∇g=(2x,2y) is zero only at the origin, which is not on the circle. Step 1 of the recipe: there are no singular candidates.
Write the equations.∇f=(y,x)=λ(2x,2y), so y=2λx and x=2λy. Components of ∇f=λ∇g.
Eliminate λ. Substitute x=2λy into y=2λx: y=4λ2y. If y=0 then x=0, not on the circle. So y=0 and 4λ2=1, λ=±21. Dividing by y is allowed once we have checked y=0 separately; this is the step where solutions are lost if you divide too early.
Find the points.λ=21 gives y=x and 2x2=1: ±(22,22), f=21. λ=−21 gives y=−x: ±(22,−22), f=−21. Put each λ in y=2λx and then in the circle.
Decide. The circle is closed and bounded and xy is continuous, so a largest and a smallest value exist (5.6, 4.3), and they are among the four candidates. Existence from compactness; the theorem only gives candidates.
Answer. Maximum 21 at the two points where x,y have the same sign; minimum −21 where they have opposite signs. (Check by substitution: x=cost, y=sint gives xy=21sin2t.)
Your answerWhat is the largest value of xy on the circle x2+y2=1?
∇(xy)=(y,x) and ∇g=(2x,2y).
The candidates are (±22,±22) with xy=±21; the largest is 21. Check: xy≤2x2+y2=21.
Worked example MATH 376 Worksheet 3 #4
Find the point of the plane x+2y+z=10 closest to (1,2,0) and the distance.
Solution.
Squared distance. Minimise f=(x−1)2+(y−2)2+z2 subject to g=x+2y+z=10. The squared distance has the same minimiser and no square root.
Singular points.∇g=(1,2,1)=O everywhere. The theorem applies at every point.
Equations.2(x−1)=λ, 2(y−2)=2λ, 2z=λ, so x=2λ+1, y=λ+2, z=2λ. Solve each coordinate in terms of λ.
Constraint.(2λ+1)+2(λ+2)+2λ=3λ+5=10, so λ=35. Substitute into the plane.
Point and distance.(x,y,z)=(611,311,65) and f=(65)2+(35)2+(65)2=36150, so the distance is 65. The offsets from (1,2,0) are 65,35,65.
Why a minimum exists. The plane is unbounded, but f→∞ far away, so f has a smallest value; it must be at a candidate, and there is only one. Existence by growth.
Answer.(611,311,65), distance 65≈2.041. It agrees with the formula 1+4+1∣1+4+0−10∣. The offset from (1,2,0) to the closest point is 65(1,2,1), parallel to the normal ∇g=(1,2,1), as the picture says.
Your answerWhat is the shortest distance from (1,2,0) to the plane x+2y+z=10? (Give a decimal.)
The distance from (x0,y0,z0) to ax+by+cz=d is ∣ax0+by0+cz0−d∣/a2+b2+c2.
1+4+1∣1+2⋅2+0−10∣=65≈2.0412, and the Lagrange computation gives the same.
Worked example MATH 376 Worksheet 1 #6
Find the extreme values of f=x2+y2+z2 on the line where the planes x+y+z=1 and x−y+2z=2 meet.
Solution.
Check independence.∇g1=(1,1,1) and ∇g2=(1,−1,2) are not multiples of each other, at every point. Every point is regular; the two-constraint theorem applies.
Equations.∇f=(2x,2y,2z)=λ1(1,1,1)+λ2(1,−1,2), so x=2λ1+λ2, y=2λ1−λ2, z=2λ1+2λ2. Solve each coordinate. (The Worksheet writes L=f+λ(g1−1)+μ(g2−2), so its multipliers are the negatives of these; the points are the same.)
Constraints.x+y+z=23λ1+2λ2=1 and x−y+2z=22λ1+6λ2=λ1+3λ2=2. So 3λ1+2λ2=2 and λ1+3λ2=2. Two linear equations in the two multipliers.
Solve.λ1=72, λ2=74. Then (x,y,z)=(73,−71,75) and f=499+1+25=75. Substitute.
Decide. The feasible set is a line and f→∞ along it, so the single candidate is the minimum and there is no maximum. Growth argument.
Answer. Minimum 75 at (73,−71,75); no maximum. The sympy lab below reports the multipliers 72,74 for this same problem.
Worked example MATH 376 Worksheet 3 #2
Minimise 50x+100y subject to 100xy=1000, with x,y>0.
Solution.
Clean the constraint.xy=10 means g=xy=100 for x,y>0. Same set, no square root.
Singular points.∇g=(y,x)=O for x,y>0. No extra candidates.
Equations.50=λy and 100=λx. Dividing the second by the first, 2=x/y, so x=2y. λ=0 (else 50=0) and y>0, so the division is legal.
Constraint.2y2=100, y=52, x=102. Substitute x=2y into xy=100.
Cost and existence. The cost is 50⋅102+100⋅52=10002≈1414. On the curve y=100/x the cost 50x+10000/x→∞ as x→0+ and as x→∞, so a minimum exists and it is the only candidate. Existence by growth.
Answer.x=102≈14.14, y=52≈7.07, minimum cost 10002≈1414. The input with the lower price (here x, at 50 against 100) is bought in the larger amount, x/y=price of xprice of y=2, which is what the equal exponents in xy give.
Worked example MATH 376 Worksheet 3 #3
Minimise f=x on the curve y2=x3. Why does the Lagrange recipe fail?
Solution.
Write the constraint.g=y2−x3=0 with ∇g=(−3x2,2y). Step 1 of the recipe.
Singular points.∇g=O only at (0,0), which is on the curve. That point is a separate candidate, not covered by the theorem.
Try Lagrange.∇f=(1,0)=λ(−3x2,2y): the first component needs 1=−3λx2, so x=0; the second needs λy=0, so y=0 (since λ=0). But y=0 and y2=x3 force x=0. Contradiction. The system has no solutions at all.
The true minimum. On the curve x3=y2≥0, so x≥0, and x=0 is attained at the origin. Direct inspection.
Answer. The minimum is 0 at (0,0), the single singular point, where no multiplier exists. This is why step 1 of the recipe (find the points with ∇g=O) cannot be skipped. In the visualiser, choose the last picture and slide to 0.
Quick checkYou solve ∇f=λ∇g with g=c and find exactly one solution. What else must you do before calling it the minimum?
The theorem is a necessary condition under the hypothesis ∇g=O. Points with ∇g=O are separate candidates (the cusp). A single candidate can be a maximum, a saddle of f on the constraint, or the only candidate of a problem with no minimum. The sign of λ has no meaning here.
Worked example MATH 376 Homework 1 #1
Find the shortest distance from (1,2,3) to the northern hemisphere {x2+y2+z2=1,z≥0}.
Solution.
Use the whole sphere. Minimise f=(x−1)2+(y−2)2+(z−3)2 on g=x2+y2+z2=1. ∇g=2(x,y,z)=O on the sphere. The constraint is smooth on the full sphere; the boundary z=0 of the hemisphere would add a second kind of candidate, to be checked at the end.
Equations.2(x−1)=2λx, and similarly for y,z, so (1−λ)x=1, (1−λ)y=2, (1−λ)z=3. Move λx to the left and divide by 2.
Find λ. Square and add: (1−λ)2(x2+y2+z2)=1+4+9=14, and on the sphere the bracket is 1, so 1−λ=±14. Use the constraint.
The points.(x,y,z)=±14(1,2,3). Divide each equation by 1−λ.
Choose. The plus sign has z>0, so q=14(1,2,3) is in the hemisphere. The distance to q is (1−141)14=14−1, and to −q it is 14+1. (1,2,3)−q is a multiple of (1,2,3).
The boundary. The closest point of the whole sphere already lies in the hemisphere, so the boundary circle z=0 is not a competitor. A minimum over a larger set that lies in the smaller set is also the minimum over the smaller set.
Answer.14−1≈2.742, at 14(1,2,3). (For a point v outside the unit ball the closest point of the sphere is v/∥v∥ and the distance is ∥v∥−1.)
Worked example new (the style of MATH 375 Lecture 24: interior critical points, then check the boundary)
Find the largest and smallest values of f(x,y)=x2+2y2−x on the closed unit disc x2+y2≤1.
Solution.
Interior.∇f=(2x−1,4y)=O at (21,0), an interior point, with f=41−21=−41. The zero-gradient rule applies in the interior (5.6).
Boundary by a multiplier. On x2+y2=1: 2x−1=2λx and 4y=2λy. The second gives y=0 or λ=2. If y=0, then x=±1: f(1,0)=0, f(−1,0)=2. If λ=2, then 2x−1=4x, x=−21, y=±23, and f=41+23+21=49. Case split on the factor y rather than dividing by it.
Boundary by substitution. With x=cost, y=sint: f=cos2t+2sin2t−cost=2−cos2t−cost. As a function of c=cost∈[−1,1] this is 2−c2−c, with derivative −2c−1=0 at c=−21, value 49, and endpoint values 0 (c=1) and 2 (c=−1). The two methods give the same candidates and values.
Compare. Candidates: −41 (interior), 0, 2, 49 (boundary). The disc is compact, so the largest and smallest values exist (5.6). Absolute extrema on a compact set: compare interior critical points with boundary candidates.
Answer. Maximum 49 at (−21,±23); minimum −41 at the interior point (21,0). Note that the minimum on the boundary alone is 0: the true minimum is not on the boundary.
Your answerWhat is the largest value of x2+2y2−x on the closed unit disc?
Interior critical point value −41; boundary candidates 0, 2 and 49 (at x=−21, y=±23). The largest is 49.
Worked example Apostol 9.15 #2
Find the greatest and least distances from the origin to the curve 5x2+6xy+5y2=8.
Solution.
Set up. Minimise and maximise f=x2+y2 (the squared distance) on g=5x2+6xy+5y2=8. ∇g=(10x+6y,6x+10y) is zero only at the origin, which is not on the curve. No singular candidates.
Equations.∇f=(2x,2y)=λ∇g, that is [5335][xy]=λ1[xy]. Here ∇g=2A[xy], so ∇f=λ∇g reads 2[xy]=2λA[xy]. We have λ=0, else x=y=0, which is off the curve. Dividing by 2λ says (x,y) is an eigenvector of A=[5335] with eigenvalue λ1.
Eigenvalues.A has eigenvalues 8 (eigenvector (1,1)) and 2 (eigenvector (1,−1)). Trace 10, determinant 16: μ2−10μ+16=0.
Points. Along (1,1): (x,y)=s(1,1) and g=16s2=8, so s2=21, f=2s2=1. Along (1,−1): g=4s2=8, s2=2, f=2s2=4. Substitute in the constraint, then compute f=x2+y2.
Decide. The curve is closed and bounded, so both extremes are attained; they are the two values found.
Answer. Nearest distance 1, at ±(22,22); farthest distance 2, at ±(2,−2). The multiplier turned the problem into an eigenvalue problem: for a quadratic constraint xTAx=8 the squared distance is 8/μ where μ runs over the eigenvalues, and the principal axes of 3.2 are the ends of the ellipse’s axes. (Third picture of the visualiser.)
Your answerWhat is the greatest distance from the origin to the curve 5x2+6xy+5y2=8?
On the ellipse xTAx=8, so ∥x∥2=8/(eigenvalue) along an eigenvector.
Along the eigenvector (1,−1) with eigenvalue 2: 2⋅∥(x,y)∥2=8 on the curve, so the squared distance is 4 and the distance 2. Along (1,1) with eigenvalue 8 it is 8/8=1.
Worked example Apostol 9.15 #7
Find the shortest distance from (1,0) to the parabola y2=4x.
Solution.
Set up. Minimise f=(x−1)2+y2 on g=y2−4x=0. ∇g=(−4,2y) is never O. No singular points.
Equations.2(x−1)=−4λ and 2y=2λy. Components of ∇f=λ∇g.
Split on the second.y(1−λ)=0. If y=0, then x=0 (from y2=4x), the point (0,0). If λ=1, then 2(x−1)=−4 gives x=−1, and y2=−4: impossible. Never divide by y without treating y=0 separately.
Conclude. The only candidate is (0,0), at distance 1. A minimum exists since f→∞ far along the curve. One candidate plus an existence argument.
Answer.1, at the vertex (0,0). Check by substitution: on the parabola f=(x−1)2+4x=(x+1)2 for x≥0, smallest at x=0.
Which candidate is which? The second-order test
The theorem produces candidates. For a maximum or minimum we used geometry or existence so far. When that is not available, there is a second-order test, which is the Hessian test of 5.6 restricted to the tangent space of the constraint.
Definition B
Bordered Hessian
Let f,g1,…,gm be C2, a a regular point with multipliers λi. The Hessian of the Lagrangian in the x variables is H=D2f(a)−∑iλiD2gi(a), a symmetric n×n matrix (5.5). The bordered Hessian is B=[0Dg(a)TDg(a)H], with the m×n block Dg(a) above and its transpose beside H. The tangent space is T=kerDg(a) (5.7).
In one lineThe (n+m)×(n+m) symmetric matrix B=[0Dg(a)TDg(a)H], where H=D2f(a)−∑λiD2gi(a) is the Hessian in x of the Lagrangian.
Why it existsIt puts the constraint gradients around the Hessian like a border, so that a single determinant (for two variables) or a few minors decide between maximum and minimum on the tangent space.
Theorem BRudin-style via 5.4 and 5.6; Apostol 9.14 (remark); Spivak ch. 5
Second-order test for constrained extrema
Let f,gi be C2 near a regular point a of g with g(a)=c, ∇f(a)=∑λi∇gi(a), H=D2f(a)−∑λiD2gi(a) and T=kerDg(a).
(i) If vTHv>0 for every v∈T∖{O}, then a is a strict local constrained minimum of f. If vTHv<0 for every such v, a strict local constrained maximum.
(ii) If a is a local constrained minimum, then vTHv≥0 for all v∈T; for a local constrained maximum, vTHv≤0.
In one lineAt a regular point with multipliers λi: if vTHv>0 for all nonzero v in the tangent space then a is a strict local constrained minimum; if <0, a strict local maximum; a local minimum forces vTHv≥0 on the tangent space.
Why it is trueIt is the second-derivative test with the constraint accounted for: only the directions along the constraint matter, and the curvature of the constraint itself enters through the term −∑λiD2gi in H.
ProofSpivak ch. 5; this version uses 5.4 and 5.6
The idea: Parametrise the constraint by the free variables, as in the proof of the multiplier theorem. On the constraint, f equals the Lagrangian, and the Lagrangian has zero gradient at a, so the second derivative of the restricted function is the Hessian of the Lagrangian pulled back to the tangent space. Then apply the ordinary second-derivative test of 5.6 to the restricted function.
Solve the constraint near a as w=h(u) with h of class C2, and let X(u)=(u,h(u)).
As in the multiplier theorem. Since f,g are C2, h is C2: Dh=−Dwg−1Dug is built from C1 functions.
Define φ(u)=f(X(u))=L(X(u),λ) with L(x,λ)=f(x)−∑λi(gi(x)−ci) and λ the fixed multipliers.
For x on the constraint, g(x)=c, so the terms λi(gi−ci) vanish: L(x,λ)=f(x) there.
At au: D2φ(au)=ZTHZ.
Second derivatives of a composite (5.4): D2φ=ZT(D2L)Z+∑k∂xk∂LD2Xk, where Z=DX(au)=[IDh]. The sum has the factors ∂xk∂L(a)=0, because ∇xL(a)=∇f(a)−∑λi∇gi(a)=O.
So vTHv>0 on T∖{O} says exactly that D2φ(au) is positive definite.
5.7: the columns of Z are the tangent vectors (ej,Dhej), a basis of T=kerDg(a). So v∈T means v=Zs for a unique s∈Rn−m, and vTHv=sTZTHZs.
Positive definite: φ has a strict local minimum at au, hence f has a strict local constrained minimum at a. The statements for maxima and (ii) are the same with signs changed or with ‘semidefinite’. ■
∇φ(au)=O (proof of the multiplier theorem) and the second-derivative test of 5.6, together with its converse for a minimum (a minimum needs a positive semidefinite Hessian).
Corollary Bstandard; Apostol 9.14 remark
Bordered determinant test in two variables
Let n=2, m=1, a a regular point, gx=gx(a), gy=gy(a) and Lxx,Lxy,Lyy the entries of H. Then
If detB>0, a is a strict local constrained maximum; if detB<0, a strict local constrained minimum.
In one lineFor f(x,y) with one constraint g at a regular point: detB>0 means a strict local constrained maximum, detB<0 a strict local constrained minimum, where B is the 3×3 bordered Hessian.
Why it is trueIt gives a one-line test for the most common case, and shows how the bordering encodes the restriction to the tangent line.
Proofstandard
The idea: The tangent space is the line spanned by (minus g_y, g_x). Compute v-transpose H v for that vector and compare it with the determinant.
detB=−gx2Lyy+2gxgyLxy−gy2Lxx.
Expand along the first row: 0−gx(gxLyy−Lxygy)+gy(gxLxy−Lxxgy).
The tangent line is spanned by v=(−gy,gx).
T=kerDg={v:gxv1+gyv2=0} is the line through v=(−gy,gx) (nonzero since the point is regular).
vTHv=gy2Lxx−2gxgyLxy+gx2Lyy=−detB.
Multiply out vTHv=Lxxv12+2Lxyv1v2+Lyyv22 with v1=−gy, v2=gx.
So detB<0 gives vTHv>0: a strict local minimum; detB>0 gives a strict local maximum.
Every nonzero tangent vector is a nonzero multiple of v, so wTHw has the same sign as vTHv. Then the second-order test: −detB>0 means minimum, <0 means maximum. ■
For more variables the same idea is a test on the leading principal minors of B (the determinants of its top-left k×k blocks). With n variables and m constraints, look at the n−m minors of orders 2m+1,…,m+n. If all have the sign of (−1)m the point is a strict local minimum. If they alternate in sign, starting with the sign of (−1)m+1 at order 2m+1, it is a strict local maximum. For n=2, m=1 there is the single minor detB of order 3, and the rule is the one proved above. We state the general rule without proof; its source is the same reduction to the tangent space. Check on x2+y2+z2 with the constraint x+y+z=1 (n=3, m=1): the minors of orders 3 and 4 are −4 and −12, both with the sign of (−1)1, so the point is a minimum.
Worked example MATH 376 Worksheet 1 #5, second-order check (new)
Classify the four candidates of xy on x2+y2=1 with the bordered Hessian.
Solution.
Hessian of the Lagrangian. With L=xy−λ(x2+y2−1): Lxx=Lyy=−2λ, Lxy=1. D2f=[0110] and D2g=2I.
At (22,22), λ=21.Lxx=Lyy=−1, gx=gy=2. gx2Lyy−2gxgyLxy+gy2Lxx=−2−4−2=−8, so detB=+8>0. Positive: maximum.
At (22,−22), λ=−21.Lxx=Lyy=1, gx=2, gy=−2. The bracket is 2+4+2=8, so detB=−8<0. Negative: minimum.
The other two are the negatives of these points; the same values hold by symmetry.
Answer. Maxima (value 21) where x,y have the same sign, minima (value −21) where they differ, in agreement with the compactness argument. A second example: minimising x+y on xy=1, x>0: at (1,1), λ=1, Lxx=Lyy=0, Lxy=−1, gx=gy=1, bracket =0+2+0=2, detB=−2<0: a minimum, value 2 (the inequality x+x1≥2).
Quick checkAt a candidate for the problem 'maximise f on g=c' the bordered determinant is detB=−6 (two variables, one constraint). What is the candidate?
By the corollary, vTHv=−detB=6>0 on the tangent line, so f increases in both directions along the constraint: a strict local minimum. The sign convention to remember: detB>0 maximum, detB<0 minimum.
What the multiplier means
Theorem Bstandard (the shadow price of economics); Lagrange's mechanical interpretation
The multiplier is the price of the constraint
Let f,g be C1 with m=1, and suppose for c in an interval there is a C1 curve c↦x∗(c) of regular constrained extrema with g(x∗(c))=c and ∇f(x∗(c))=λ(c)∇g(x∗(c)). Then V(c)=f(x∗(c)) has V′(c)=λ(c).
In one lineIf the constrained optimum x∗(c) depends differentiably on c and V(c)=f(x∗(c)), then V′(c)=λ(c): the multiplier is the rate at which the best value changes when the constraint g=c is moved.
Why it is trueIt explains why the multiplier is worth computing: it tells you how much a unit of loosening the constraint is worth (a price), and its size tells you how binding the constraint is.
Proofstandard
The idea: Differentiate V with the chain rule, replace the gradient of f by lambda times the gradient of g, and differentiate the constraint to see that the remaining dot product equals 1.
V′(c)=∇f(x∗(c))⋅x∗′(c).
Chain rule along the curve x∗(c) (5.3).
=λ(c)∇g(x∗(c))⋅x∗′(c).
The multiplier equation at x∗(c).
∇g(x∗(c))⋅x∗′(c)=1, so V′(c)=λ(c). ■
Differentiate the identity g(x∗(c))=c with the chain rule: the right side has derivative 1.This is the whole content: moving the constraint by dc moves the point by dx with ∇g⋅dx=dc, and the first-order change of f is λdc.
Worked example
Check the price theorem on: minimise x2+y2 subject to x+y=c.
Solution.
Solve.∇f=(2x,2y)=λ(1,1), so x=y=2λ, and the constraint gives λ=c, x=y=2c. Lagrange.
The best value.V(c)=4c2+4c2=2c2. Substitute.
Compare.V′(c)=c=λ(c). The theorem holds: loosening x+y=c by one unit raises the minimum squared distance at rate c.
Answer.V′(c)=λ=c. For several constraints, ∂V/∂ci=λi.
Convexity: when a candidate is automatically the best
Definition B
Convex function
A set C⊆Rn is convex if it contains the segment between any two of its points (a ball, a plane, all of Rn). A function f:C→R is a convex function if f(tx+(1−t)y)≤tf(x)+(1−t)f(y) for all x,y∈C and t∈[0,1], that is, the graph lies below every chord. It is concave if −f is convex. Examples: ∥x∥2, ex, xTAx with A positive semidefinite; lnx is concave.
In one lineA function f on a convex set with f(tx+(1−t)y)≤tf(x)+(1−t)f(y) for all x,y and t∈[0,1]: the graph lies below every chord.
Why it existsIt is the property that makes every critical point a global minimum, which is why convex problems are the ones that optimisation solves reliably (5.10).
Theorem Bstandard (Boyd and Vandenberghe, Convex Optimization, 3.1.3)
Gradient inequality for convex functions
If f is convex and differentiable on an open convex set C, then for all x,y∈C: f(y)≥f(x)+∇f(x)⋅(y−x).
In one lineA differentiable convex function lies above each of its tangent planes: f(y)≥f(x)+∇f(x)⋅(y−x).
Why it is trueIt says the linearization is a lower bound, so a zero gradient forces the global minimum; it also drives the convergence proofs of gradient descent.
Proofstandard
The idea: Compare the chord with the tangent: the difference quotient of f in the direction y minus x increases with the step, so it is at most its value at the full step, and its limit at step 0 is the directional derivative.
f(x+t(y−x))≤(1−t)f(x)+tf(y).
Convexity with the point x+t(y−x)=(1−t)x+ty, 0<t≤1.
tf(x+t(y−x))−f(x)≤f(y)−f(x).
Subtract f(x) and divide by t>0.
So ∇f(x)⋅(y−x)≤f(y)−f(x).
Let t→0+: the left side tends to f′(x;y−x)=∇f(x)⋅(y−x) by 5.3. ■
Theorem Bstandard
Positive semidefinite Hessian implies convex
Let f be C2 on an open convex set C with vTHf(x)v≥0 for all x∈C, v∈Rn. Then f is convex on C.
In one lineIf f is C2 on an open convex set and its Hessian is positive semidefinite everywhere, then f is convex; in particular 21xTAx−bTx is convex when A is symmetric positive semidefinite.
Why it is trueIt turns convexity into the eigenvalue test of 3.2, so you can check it for any smooth function.
Proofstandard
The idea: Show the tangent-plane inequality on each segment with the one-variable mean value theorem, then average the two tangent-plane inequalities at the point on the chord.
ψ′ is non-decreasing on [0,1] (its derivative is ≥0, mean value theorem of 1.4).
Fix x,y and put ψ(t)=f(x+t(y−x)). Then ψ′(t)=∇f(⋅)⋅(y−x) and ψ′′(t)=(y−x)THf(⋅)(y−x)≥0 (chain rule twice, 5.4).
f(y)−f(x)≥ψ′(0)=∇f(x)⋅(y−x).
Mean value theorem: ψ(1)−ψ(0)=ψ′(ξ) for some ξ∈(0,1), and ψ′(ξ)≥ψ′(0).
tf(x)+(1−t)f(y)≥f(z)=f(tx+(1−t)y). ■
Apply this at z=tx+(1−t)y twice: f(x)≥f(z)+∇f(z)⋅(x−z) and f(y)≥f(z)+∇f(z)⋅(y−z). Multiply by t and 1−t and add: the gradient terms cancel because t(x−z)+(1−t)(y−z)=O.
Corollary Bstandard
A convex Lagrangian gives a global minimum
Suppose ∇xL(a,λ)=O, g(a)=c and L(⋅,λ) is convex and differentiable. Then f(x)≥f(a) for every x with g(x)=c. In particular this holds whenever f is convex and the constraints are linear, Mx=c.
In one lineIf x↦L(x,λ)=f(x)−∑λi(gi(x)−ci) is convex and a satisfies ∇f(a)=∑λi∇gi(a) and g(a)=c, then a is an absolute minimum of f on {g=c}.
Why it is trueThis is the case where the recipe needs no existence argument and no second-order test: for convex f with linear constraints (least squares, quadratic programs, maximum entropy) every Lagrange point is the global optimum.
Proofstandard
The idea: On the constraint set f equals the Lagrangian; a convex function with zero gradient at a is minimal at a.
For feasible x, f(x)=L(x,λ) and f(a)=L(a,λ).
For g(x)=c the terms λi(gi−ci) vanish.
L(x,λ)≥L(a,λ)+∇xL(a,λ)⋅(x−a)=L(a,λ).
Gradient inequality for the convex function L(⋅,λ), with ∇xL(a,λ)=O.
So f(x)≥f(a) for all feasible x.
Combine. If f is convex and gi linear, then L is convex (sum of a convex and a linear function). ■
Quick checkMinimise ∥x∥2 on the set Mx=c (an affine subspace). You solve 2x=MTλ, Mx=c and find one solution. What does the corollary say?
The Lagrangian ∥x∥2−λT(Mx−c) is convex in x, so the Lagrange point is an absolute minimum, with no existence argument and no Hessian. This minimum-norm solution is the pseudoinverse solution x=M+c of 3.4.
Where it is used
Used inside maths· Inside maths: eigenvalues, inequalities and minimum-norm solutions
Eigenvalues are Lagrange multipliers. The maximum of xTAx on ∥x∥=1, for A symmetric, is found by ∇(xTAx)=2Ax=λ⋅2x, so every candidate is an eigenvector and the value there is xTAx=λ. The sphere is compact, so the maximum is attained: it is the largest eigenvalue. This is the Rayleigh bound used in 5.6, and it proves the spectral theorem’s first step (3.1). The same argument with ATA shows σ1=max∥x∥=1∥Ax∥ (3.4). Inequalities. The maximum of a⋅x on ∥x∥=1 is ∥a∥ (the Cauchy–Schwarz inequality, problem below). To maximise xyz on x+y+z=s with x,y,z≥0: the maximum exists on the compact triangle and is not on the boundary (where xyz=0); ∇=(yz,xz,xy)=λ(1,1,1) forces x=y=z=3s; so xyz≤(3s)3, the AM–GM inequality for three numbers. Minimum-norm solutions. Among all solutions of an underdetermined system Mx=c the shortest is x=MT(MMT)−1c (the corollary above): for the two planes of Worksheet 1 #6 this is the point (73,−71,75), whose norm squared is 75.
Used in the real world· Entropy, portfolios, margins and budgets: four real Lagrange problems
Maximum entropy (physics and machine learning). Among all probability distributions p=(p1,…,pn) the entropyH(p)=−∑pilnpi measures how spread out p is. E. T. Jaynes (1957) proposed this as a rule of inference: among all distributions that fit what you know, pick the one with the largest entropy, because it assumes nothing more. Maximise it subject to ∑pi=1: −lnpi−1=λ for every i, so all pi are equal, pi=n1, H=lnn (for n=8: ln8=2.079 nats, which is 3 bits). Add a constraint on the average of a quantity Ei (energy): ∑piEi=e. The equation becomes −lnpi−1=λ0+βEi, so pi=e−βEi/Z with Z=∑e−βEi, the Boltzmann distribution, and the multiplier β is the inverse temperature. The Hessian of H is −diag(1/pi), negative definite, so H is concave, and the corollary applied to −H (convex) says this is the global maximum. Numbers: three levels with E=(0,1,2) and mean energy 21: with x=e−β the mean is 1+x+x2x+2x2=21, that is 3x2+x−1=0, x=6−1+13=0.4343, p=(0.616,0.268,0.116), H=0.901 nats against ln3=1.099 for the uniform distribution (which has mean 1). For a six-sided die forced to average 4.5, the maximum-entropy distribution has β=−0.371 and p=(0.054,0.079,0.114,0.165,0.240,0.347), H=1.614 nats against ln6=1.792. And the softmax of a neural network is the same: maximising ∑pizi+H(p) over distributions gives pi=ezi/∑jezj with the maximum value ln∑jezj, so the output layer of a classifier (3.8, 5.10) returns the maximum-entropy distribution compatible with its scores zi.
Portfolio optimisation (finance). Harry Markowitz (1952) proposed choosing portfolio weights w to minimise the variance wTΣw for a target expected return: constraints 1Tw=1 and μTw=r. Lagrange gives 2Σw=λ11+λ2μ, and together with the two constraints this is one linear system (its matrix is the bordered matrix 2Σ1TμT100μ00). Take three assets with expected returns μ=(6%,10%,14%), standard deviations 20%,30%,40% and covariances Σ12=0.006, Σ23=0.012, Σ13=0 (so Σ=0.040.00600.0060.090.01200.0120.16). The target r=9% gives w=(0.485,0.281,0.235) with standard deviation 16.9%. Dropping the return constraint (only 1Tw=1) gives the minimum-variance portfolio w=1TΣ−11Σ−11=(0.622,0.231,0.147) with standard deviation 16.2% and return 8.1%. The quadratic objective is convex, so these Lagrange points are global minima (corollary). (Weights here happen to be positive; a ban on short selling adds inequality constraints.)
Support vector machines (a light look). To separate points with labels yi=±1 by a plane w⋅x+b=0 with the widest empty margin, minimise 21∥w∥2 subject to yi(w⋅xi+b)≥1. These are inequality constraints; the Lagrangian 21∥w∥2−∑αi(yi(w⋅xi+b)−1) now needs multipliers αi≥0 (the Karush–Kuhn–Tucker conditions, B). Setting the derivatives in w and b to zero gives w=∑αiyixi and ∑αiyi=0, and substituting back leaves the dual problem: maximise ∑αi−21∑i,jαiαjyiyjxi⋅xj. It involves the data only through dot products xi⋅xj, which is why one can replace them by kernels. Tiny example: x1=(2,0) with y1=+1 and x2=(0,0) with y2=−1. The constraint ∑αiyi=0 forces α1=α2=α, the dual is 2α−21α2∥x1−x2∥2=2α−2α2, maximal at α=21, and w=α(x1−x2)=(1,0). From y1(w⋅x1+b)=1: 2+b=1, b=−1. The plane is x=1, halfway between the points, and the margin from each point is 1/∥w∥=1.
Economics: budgets and shadow prices. A consumer with income m buys x and y at prices px,py to maximise U=x0.4y0.6 subject to pxx+pyy=m. Lagrange gives Ux=λpx and Uy=λpy, so the marginal rate of substitution Ux/Uy equals the price ratio px/py, and x=px0.4m, y=py0.6m. With m=100, px=2, py=5: x=20, y=12, U=200.4120.6=14.72, and λ=Ux/px=0.1472=U/m. By the price theorem, λ is the utility gained per extra unit of money: raising m from 100 to 101 raises the best utility by 0.147 (here U is homogeneous of degree 1, so the best utility is exactly 0.1472m).
Your answerIn the maximum-entropy example with energies 0,1,2 and mean energy 21, what is x=e−β? (Give a decimal.)
Write pi∝xEi and set the mean equal to 21.
The mean is 1+x+x2x+2x2=21, so 2x+4x2=1+x+x2, that is 3x2+x−1=0, and x=6−1+13≈0.4343.
Your answerA consumer maximises U=x0.4y0.6 with budget 100 and prices px=2, py=5. What is the best amount of x?
With exponents 0.4 and 0.6 the consumer spends 40% of the income on x.
The first-order conditions give pxx=0.4m, so x=20.4⋅100=20 (and pyy=0.6m, y=12).
Python labSolve the Lagrange system with sympy and check against brute force
import numpy as npimport sympy as spx, y, z = sp.symbols('x y z', real=True)def lagrange(f, gs, vs): """Solve grad f = sum(l_i grad g_i) with g_i = 0. Returns (point, multipliers, f value) triples.""" ls = sp.symbols('l1:%d' % (len(gs) + 1), real=True) L = f - sum(l * g for l, g in zip(ls, gs)) eqs = [sp.diff(L, v) for v in vs] + list(gs) out = [] for s in sp.solve(eqs, list(vs) + list(ls), dict=True): out.append(([s[v] for v in vs], [s[l] for l in ls], sp.simplify(f.subs(s)))) return outprint("A. xyz on the unit sphere")for p, l, val in lagrange(x*y*z, [x**2 + y**2 + z**2 - 1], [x, y, z]): print(" ", [sp.nsimplify(c) for c in p], " lambda =", l[0], " f =", val, "~", round(float(val), 5))print("B. x^2+y^2+z^2 on x+y+z=1 and x-y+2z=2")for p, l, val in lagrange(x**2 + y**2 + z**2, [x + y + z - 1, x - y + 2*z - 2], [x, y, z]): print(" ", p, " multipliers =", l, " f =", val)print("C. minimise x on y^2 = x^3: the recipe finds")print(" ", lagrange(x, [y**2 - x**3], [x, y]), " (no candidates, yet the minimum 0 is at the origin)")rng = np.random.default_rng(0)v = rng.normal(size=(400000, 3)); v /= np.linalg.norm(v, axis=1)[:, None]vals = v[:, 0] * v[:, 1] * v[:, 2]print("sampled max, min of xyz on the sphere:", vals.max().round(4), vals.min().round(4), " 1/(3*sqrt(3)) =", round(1/(3*3**0.5), 4))
Try this.Run it. Problem A (xyz on the sphere) has fourteen solutions: six on the axes, where xyz = 0 and the point is a saddle of f on the sphere, and eight at the corners of a cube, where xyz is plus or minus 0.19245. The brute-force sampling agrees that these are the largest and smallest values. Problem B reports the multipliers 2/7 and 4/7. Problem C returns the empty list: the recipe finds nothing, yet the minimum 0 exists at the origin, the point where the gradient of the constraint vanishes. Change f in A to x + y + z or x**2 + 2*y**2 + 3*z**2 and see how the candidates change. Add the constraint z - x - y for a second constraint on A and read off the two multipliers.
Traps
Watch out· Skipping the singular points
Points where ∇g=O (or the constraint gradients are dependent) are candidates of their own and the equation ∇f=λ∇g cannot find them. The cusp y2=x3 (Worksheet 3 #3) is built to catch this: Lagrange returns no solution, and the minimum is at the singular point. Apostol’s example of a plane meeting a cylinder along a line (stretch problem below) is the same trap with two constraints.
Watch out· Dividing by something that can be zero
From y=4λ2y you may not cancel y without first treating y=0 (Worksheet 1 #5: y=0 forces x=0, off the circle). In the disc example the equation 4y=2λy splits into y=0 or λ=2. Lost cases are lost extrema.
Watch out· Candidates are not answers
One solution does not mean it is the minimum. Say why an extremum exists (the constraint set is compact, or f→∞ along every unbounded direction) or classify with the bordered Hessian or convexity. Worksheet 1 #6 has a minimum and no maximum, because the constraint is a line.
Watch out· The Lagrangian's critical point is a saddle, not a minimum
For xy on the circle, at the maximum (22,22) with λ=21, the Hessian of L(x,y,λ) in all three variables is −11−21−1−2−2−20, with eigenvalues −2,−2,2: indefinite. The 5.6 test applied to L in all variables is meaningless; the right matrix is the Hessian in x restricted to the tangent space (the bordered Hessian).
Watch out· Inequality constraints and the boundary of a region
For a region such as a disc, find the interior critical points with ∇f=O (5.6) and then treat the boundary with a multiplier; compare all values. Two constraints need independent gradients. For true inequality constraints the multipliers have a sign (KKT), which the equality case does not.
Watch out· Sign and size of lambda
The sign of λ depends on writing f−λg or f+λg. Do not read meaning from it before fixing the convention. With L=f−λ(g−c) the price theorem says V′(c)=+λ.
Problems
check
Write and solve the Lagrange equations for the maximum of x+2y on x2+y2=5.
Solution
∇f=(1,2)=λ(2x,2y) gives x=2λ1, y=λ1=2x. Then 5x2=5, x=±1. The points are (1,2) with f=5 and (−1,−2) with f=−5. The circle is compact, so the maximum is 5 at (1,2) (and the minimum is −5). Check: x+2y=(1,2)⋅(x,y)≤5⋅5=5 by Cauchy–Schwarz.
check
How many unknowns and how many equations are there when you maximise f(x1,x2,x3,x4) on two constraints g1=c1, g2=c2?
Solution
Unknowns: four coordinates and two multipliers, six. Equations: four from ∇f=λ1∇g1+λ2∇g2 and two constraints, six. In general n+m equations in n+m unknowns.
checkApostol 9.15 #1
Find the extreme values of z=xy subject to x+y=1.
Solution
∇(xy)=(y,x)=λ(1,1) gives x=y, and x+y=1 gives x=y=21, z=41. The constraint is a line (not compact): by substitution z=x(1−x)=41−(x−21)2, a downward parabola. So 41 is the maximum and there is no minimum (z→−∞).
check
Show that replacing L=f−λg by L′=f+λg changes the multiplier’s sign but not the candidate points.
Solution
∇L′=O means ∇f=−λ∇g and g=c. So (x,λ) solves the system for L′ exactly when (x,−λ) solves it for L. The points x are the same; only λ changes sign.
useApostol 9.15 #5
Find the extreme values of f(x,y,z)=x−2y+2z on the sphere x2+y2+z2=1.
Solution
∇f=(1,−2,2)=λ(2x,2y,2z), so (x,y,z)=2λ(1,−2,2). On the sphere, 4λ21+4+4=1, so λ=±23 and (x,y,z)=±3(1,−2,2). Values: f=±31+4+4=±3. The sphere is compact: maximum 3, minimum −3 (this is ∥(1,−2,2)∥=3, Cauchy–Schwarz).
useApostol 9.15 #13
Find the greatest and least distances from the ellipse x2+4y2=4 to the line x+y=4.
Solution
The distance from (x,y) to the line is 2∣x+y−4∣. On the ellipse x+y has extremes found by (1,1)=λ(2x,8y): x=2λ1, y=8λ1, so x=4y; then 16y2+4y2=4, y=±51, x=±54, and x+y=±5. Since ∣x+y∣≤5<4, the distance is 24−(x+y): greatest 24+5≈4.410, least 24−5≈1.247.
useApostol 9.15 #6
Find the points of the surface z2−xy=1 nearest to the origin.
Solution
Minimise f=x2+y2+z2 on g=z2−xy=1. ∇g=(−y,−x,2z) is zero only at the origin, which is not on the surface. Equations: 2x=−λy, 2y=−λx, 2z=2λz. If z=0: λ=1, then 2x=−y and 2y=−x give x=y=0, z=±1, f=1. If z=0: −xy=1 and 4xy=λ2xy so λ=±2; λ=2 gives y=−x, x2=1, points ±(1,−1,0) with f=2; λ=−2 gives y=x and −x2=1, impossible. A minimum exists since f→∞ on the closed surface. The nearest points are (0,0,±1), distance 1.
usenew (economics, with the price theorem)
Maximise U=xy subject to 4x+y=40. Find the best bundle and λ, and check λ=dV/dm for m=40.
Solution
∇U=(2xyy,2xyx)=λ(4,1), so xy=4 (ratio of the two equations: xy=14), y=4x. Budget: 4x+4x=40, x=5, y=20, U=100=10. Then λ=pyUy=2xyx=205=41. For general income m: x=8m, y=2m, V(m)=16m2=4m, so V′(m)=41=λ. ✓.
provenew (Cauchy–Schwarz)
Use Lagrange multipliers to show that max{a⋅x:∥x∥=1}=∥a∥ for a=O, and deduce ∣a⋅x∣≤∥a∥∥x∥.
Solution
Plan. Find the candidates, use compactness for existence, then scale.
∇(a⋅x)=a=λ∇(∥x∥2)=2λx, so x=2λa and ∥x∥=1 gives 2∣λ∣=∥a∥: the candidates are x=±∥a∥a, with values ±∥a∥. The unit sphere is compact, so the maximum exists; it is ∥a∥. For a general nonzero x apply this to x/∥x∥: a⋅∥x∥x≤∥a∥, and replacing x by −x gives the absolute value. ■
provenew (Rayleigh quotient)
Let A be a real symmetric matrix. Prove that max{xTAx:∥x∥=1} equals the largest eigenvalue of A.
Solution
Plan. Lagrange turns the maximisation into an eigenvalue equation.
The sphere is compact and xTAx is continuous, so the maximum is attained at some x0. Every point of the sphere is regular for g=∥x∥2 (∇g=2x=O). By the theorem, ∇(xTAx)=2Ax0=λ⋅2x0 (using ∇(xTAx)=2Ax, 3.8, for symmetric A), so Ax0=λx0: x0 is an eigenvector. Then x0TAx0=λ∥x0∥2=λ, so the maximum value is an eigenvalue. Conversely for any eigenvalue μ with unit eigenvector u, uTAu=μ is attained on the sphere, so the maximum is at least every eigenvalue. Hence the maximum is the largest eigenvalue. ■
provenew (AM–GM)
Prove that (abc)1/3≤3a+b+c for a,b,c≥0 by maximising xyz on x+y+z=s, x,y,z≥0.
Solution
Plan. Existence by compactness, boundary excluded because the product vanishes there, interior by Lagrange.
Fix s>0. The triangle T={x+y+z=s,x,y,z≥0} is closed and bounded, so xyz attains a maximum on T. On the boundary of T some coordinate is 0 and xyz=0, while the interior has xyz>0, so the maximum is at an interior point. There ∇(xyz)=(yz,xz,xy)=λ(1,1,1). Multiplying the first equation by x and the second by y gives xyz=λx=λy, and λ=xyz/x=0, so x=y; likewise y=z. So x=y=z=3s and the maximum is (3s)3. Taking s=a+b+c (the case s=0 is trivial), abc≤(3a+b+c)3. ■
provenew (n = 2, m = 1, directly)
Prove the multiplier theorem for f,g of two variables, ∇g(a)=O, without using the general implicit function proof: use a curve in the level set.
Solution
Plan. A regular level curve has a tangent vector; f along it is stationary; the perpendicular line in the plane is one-dimensional.
By the corollary of 5.7, near a the level curve g=c is the image of a C1 curve r(t) with r(0)=a and r′(0)=O spanning kerDg(a), so r′(0)⊥∇g(a). The function t↦f(r(t)) has a local extremum at the interior point t=0, so its derivative is 0: by the path theorem (5.3) ∇f(a)⋅r′(0)=0. In the plane the vectors perpendicular to the nonzero vector r′(0) form a line, and it contains both ∇f(a) and ∇g(a)=O. So ∇f(a)=λ∇g(a). ■
stretchApostol 9.14 (the example where the method fails)
Minimise f(x,y,z)=x2+y2 on the set z=0, z2=(y−1)3. Show that the method of Lagrange multipliers applied to g1=z, g2=z2−(y−1)3 finds no candidate, and explain.
Solution
The constraint set: z=0 forces (y−1)3=0, so y=1: it is the line {(x,1,0)}. On it f=x2+1, minimal at (0,1,0) with value 1. There ∇g1=(0,0,1) and ∇g2=(0,−3(y−1)2,2z)=O: the gradients are linearly dependent, so (0,1,0) is not a regular point. And ∇f=(0,2,0) is not in the span of ∇g1,∇g2, which is the z-axis direction. So no multipliers exist. The theorem requires independent gradients; here the two surfaces (a plane and a cylinder) are tangent along the line, which is why the dependence appears.
stretchnew (finance; links 2.10 and 5.8)
Derive the minimum-variance portfolio w=1TΣ−11Σ−11 for a positive definite covariance matrix Σ, and compute it for two uncorrelated assets with variances 0.04 and 0.09.
Solution
Minimise wTΣw subject to 1Tw=1. ∇=2Σw=λ1, so w=2λΣ−11 (Σ is invertible, being positive definite). The constraint gives 2λ1TΣ−11=1, hence the formula. The objective is convex (Σ positive definite, hence the convexity theorem above) and the constraint linear, so by the corollary this is the global minimum. For Σ=diag(0.04,0.09), Σ−11=(25,11.11) and 1TΣ−11=36.11, so w=(0.6923,0.3077)=(139,134), with variance 0.130.04⋅0.09=0.02769 (standard deviation 16.6%, less than the 20% of the safer asset alone: diversification).
Summary
A constrained extremum of f on {g=c} is not a point with ∇f=O. The Lagrange multiplier theorem: if a is a regular point of the constraint (the gradients ∇gi(a) are independent) and f∣S has a local extremum at a, then ∇f(a)=∑λi∇gi(a). Picture: the level curve of f touches the constraint, so their normals are parallel.
Proof: by the implicit function theorem the constraint is a graph over n−m free variables, f restricted to it has an interior extremum, so its gradient is zero, and defining λ from the solved coordinates makes the equation hold in the free coordinates too.
Recipe: (1) find the singular points of the constraint; (2) solve ∇f=∑λi∇gi and g=c (n+m equations); (3) list candidates; (4) compare values and justify existence (compactness, growth) or classify. Use squared distances, and never divide by a quantity that may be 0.
The theorem gives candidates only. Classification: compact feasible set, growth, convexity (a convex Lagrangian makes any Lagrange point a global minimum), or the second-order test: vTHv on the tangent space with H=D2f−∑λiD2gi; for two variables and one constraint detB>0 means a maximum and detB<0 a minimum.
The multiplier is the price of the constraint: V′(c)=λ, where V(c) is the best value.
Eigenvalues are Lagrange multipliers: the extremes of xTAx on the unit sphere are the extreme eigenvalues; σ1 is max∥Ax∥.
Real problems: maximum entropy gives the Boltzmann distribution and the softmax; the Markowitz portfolio solves a linear (bordered) system; SVM margins come from a dual problem; utility maximisation gives the budget tangency and shadow prices.
Failure modes: singular points (the cusp y2=x3), dependent gradients (plane and cylinder), lost cases from dividing by a variable, and treating the Lagrangian’s critical point as if it were a minimum of L.
Watch and read
The same ideas explained by someone else. Use these when an explanation here does not land.
MATH 376: Worksheet 1 (problems 5 and 6), Worksheet 3 (problems 2 to 5) and Homework 1 problem 1 are the problems of this chapter: xy on the circle, the sum of squares on two planes, Cobb–Douglas cost, the singular point y² = x³, the proof of the theorem in space, and the distance to a hemisphere. All are worked below, with the corrections the digest records.
MATH 375: Lagrange multipliers were not lectured. Lecture 24 handled a region by finding the interior critical points and then 'checking the boundary' edge by edge; the disc example below does the boundary both by substitution and by a multiplier, so the two methods can be compared.
MATH 340 / CS 532: Every constrained problem in optimisation (linear programming, quadratic programming, support vector machines) is solved through its Lagrangian. The multipliers become dual variables, and for inequality constraints the conditions of Karush, Kuhn and Tucker replace the equation of this chapter.
MATH 521: 521 proves the multiplier rule on a manifold: at a constrained extremum the derivative of f vanishes on the tangent space of the constraint set.
Economics, physics, statistics: Utility maximisation under a budget, the Boltzmann distribution (maximum entropy under an energy constraint), and the mean-variance portfolio of Markowitz are all Lagrange problems; the multiplier is a price, a temperature, and a risk premium respectively.