Hexa Scholar

Lagrange multipliers: optimize on a constraint

A cream bead is threaded onto a circular gold rail above a navy base.
A bead on a rail represents a point whose movement is restricted to a curve.

The question

Where on the circle x² + y² = 4 would you place a point to make 3x + 4y largest?

Commit to a point before opening its gradient calculation.

  1. 1 SeeChoose a point on a circle.
  2. 2 TryChange the constraint’s formula.
  3. 3 ProveExplain why the gradients line up.
  4. 4 ApplySolve five constrained problems.
Before you start · 3 quick checks on gradients, dot products, and stationary points

Two ideas before you start

2 ideas

A constraint selects the allowed points

A circle and a selected test point. The readout checks whether the point lies on the circle.

This card uses the unit circle. Change the test point and compare its squared distance with the required level.

Exact definition

An objective f assigns a value to a point. An equality constraint \(g(x,y)=c\) selects the feasible set: all points satisfying that equation. A constrained maximum compares f only at feasible points. Points with larger values elsewhere in the plane do not disprove it.

The unit circle here is \(g(x,y)=x^2+y^2=1\). Its interior is excluded: an equality constraint is different from a disk inequality. In the activity the required level changes, but the same definition applies.

A gradient belongs to a function

The slice x² + y at fixed y = 0 and a tangent at the chosen x-coordinate.

For q(x, y) = x² + y, the dashed tangent follows the selected point. The readout keeps both partial derivatives.

Exact definition

For a differentiable function q, \(\nabla q=(q_x,q_y)\). Along a differentiable path r(s), the rate is \((q\circ r)'(s)=\nabla q(r(s))\cdot r'(s)\). The vector r′ is the path’s velocity; it need not have unit length. The gradient lesson explains the rate per unit distance.

A constrained problem has an objective gradient and a constraint gradient. Keep their roles separate. One measures changes in the quantity being optimized; the other measures changes in the quantity being held fixed.

Refresher: paths, tangent vectors, and regular constraints

A path r(s) gives a point for each parameter s. Its derivative r′(s) is tangent to the path. The chain rule above follows by substituting the path’s small displacement into the linear approximation of q. If the path stays on \(g=c\), then g along the path is constant, so its derivative is zero.

A point is regular for the constraint when \(\nabla g\ne0\). For g with continuous first partial derivatives, a regular level set is a smooth curve locally. Here is the local graph fact used in the proof: if \(g_y\ne0\), nearby feasible points can be written \((x,\phi(x))\) with differentiable φ and \(\phi'=-g_x/g_y\). If instead \(g_x\ne0\), interchange the coordinates. This is the implicit function theorem in the form needed here. The argument concerns a neighborhood of the point; the whole curve need not be a single graph.

1 See

Place your candidate on the circle

Reading the map and the feedback

The thin parallel lines are objective contours. Each joins points with the same f-value; their labels let you compare locations. The thick circle is the feasible set. Only the round point can be dragged. Both axes use the same scale.

After checking, solid and dashed arrows show the objective and constraint gradients at your point, using the same length scale. An open square marks a nearby feasible point with a higher value when one is available. The short arc shows the move along the circle. The move is computed on the circle, not along its tangent line. The coordinate and value readouts are rounded when marked ≈.

The angle control uses whole degrees. A point within one hundredth of the largest objective value counts as an approximate success. Even a successful approximate point can have a small feasible improvement. The result distinguishes these two statements.

2 Try

Change the formula, keep the curve

When the gradients line up, write \(\nabla f=\lambda\nabla g\). The real number λ is a Lagrange multiplier. It may be positive, negative, or zero. The next question tests what that number depends on.

3 Prove

Why the gradients line up

Lagrange multiplier theorem, one equality in the plane

Let f and g have continuous first partial derivatives on an open neighborhood of p. Suppose p is a local maximum or minimum of f among points satisfying \(g=c\), and \(n=\nabla g(p)\ne0\). There is a real λ such that

\[\nabla f(p)=\lambda\nabla g(p).\]

Under these hypotheses the feasible set near p is a curve through p, so feasible motion is possible in both tangent directions. If an extra endpoint or inequality restriction removes one of those directions, the theorem does not apply there; such points need separate treatment. The theorem allows \(\nabla f(p)=0\); then λ is zero. When both gradients are nonzero, “line up” includes opposite directions.

Set \(t=(-n_y,n_x)\), a nonzero tangent vector. By the regular level-set fact in the refresher, choose a local feasible path r(s) with \(r(0)=p\) and \(r'(0)=t\). Such a path comes from a local graph after rescaling its parameter. Write \(q(s)=f(r(s))\). For the final line, define \(\lambda=(\nabla f(p)\cdot n)/(n\cdot n)\) and \(z=\nabla f(p)-\lambda n\). Choose the justified step on each line.

When the regularity hypothesis fails

Take \(g(x,y)=x^2+y^2\) with required level zero. The only feasible point is the origin. It is a constrained maximum and minimum of \(f(x,y)=x\), yet its constraint gradient vanishes and its objective gradient does not. No multiplier can equate those vectors. There is no nonzero tangent direction to the singleton feasible set.

Before solving, check where the constraint gradient vanishes. Investigate such feasible points directly. Also check any endpoints introduced by a separate domain restriction. Multipliers do not remove these cases from the original optimization problem; they describe the regular interior part of it.

Writing the same equations as a Lagrangian

With the sign convention used here, define \(L(x,y,\lambda)=f(x,y)-\lambda(g(x,y)-c)\). Setting its partial derivatives to zero gives \(f_x-\lambda g_x=0\), \(f_y-\lambda g_y=0\), and \(g=c\). This packages the same equations. It does not say that L has a minimum in all its variables. Using a plus sign instead changes the multiplier’s sign, so state your convention.

4 Apply

Find candidates and justify the answer

Enter one number in each box. Each problem has hints and a worked solution. The stated absolute tolerance checks your arithmetic; it does not replace feasibility or the argument that the value is optimal.

Key point Name the objective and constraint, check regularity, solve the gradient equations with the constraint, and justify the final comparison. Use the original feasible set to handle singular points and endpoints.
Level Intro (multivariable calculus)Prerequisites Gradients, critical points, and dot products; the local level-set fact is refreshed aboveTime About half an hour

Further reading