Lagrange multipliers: optimize on a constraint

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 SeeChoose a point on a circle.
- 2 TryChange the constraint’s formula.
- 3 ProveExplain why the gradients line up.
- 4 ApplySolve five constrained problems.
Before you start · 3 quick checks on gradients, dot products, and stationary points
Two ideas before you start
2 ideasA 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.
Place your candidate on the circle
- Drag the round point, use its arrow keys, or set its angle counterclockwise from the positive x-axis.
- Make f(x, y) = 3x + 4y as large as you can on x² + y² = 4. Press Check my point.
- Inspect both gradients and a feasible improvement, then use Try again. Start over clears the calculation.
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.
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.
Use the condition to find both candidates
Use what you found above. Return to the circle activity and its objective. The multiplier equations are \(3=2\lambda x\), \(4=2\lambda y\), and \(x^2+y^2=4\). All three equations must hold together. Solving only the gradient equations can produce points off the curve.
The circle is closed and bounded, so the continuous objective attains both global extrema. Every point of this circle is regular. Comparing the complete candidate list therefore identifies the global maximum and minimum. For an unbounded feasible set, existence would require a separate argument.
Why a candidate still needs classification
The alignment condition is necessary at regular constrained extrema. It is not sufficient for a maximum. The minimum above satisfies it too. There can even be a stationary point that is neither. On the line y = 0, the objective \(f(x,y)=x^3\) has zero derivative along the line at the origin, but changes sign across it. Its constraint gradient is nonzero there.
For this lesson’s circle and linear objective, comparison of all candidates settles the question. In other problems, use a feasible parameterization, a direct inequality, or a constrained second-order test. The unconstrained Hessian test in critical points assumes all nearby directions are allowed; that assumption does not hold on a curve.
Why the gradients line up
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.
The dot product and projection lesson supplies a useful picture: remove the component of ∇f along n. The remainder lies in the tangent direction. At an extremum the tangent component vanishes, so the whole gradient lies along n. This picture also covers a zero objective gradient without dividing by its length.
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.
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.
Further reading
- J. Stewart, Calculus: Early Transcendentals, section 14.8, “Lagrange Multipliers.”
- J. E. Marsden and A. Tromba, Vector Calculus, chapter 3, “Higher-Order Derivatives; Maxima and Minima.”