Constrained optimization
Find extrema along feasible directions and use Lagrange multipliers without confusing candidates with guarantees.
On this page
The question for today
What you’ll understand
- Distinguish feasible motion from arbitrary motion.
- Derive multiplier equations at a regular equality constraint.
- Verify candidate optima using geometry, boundaries, or convexity.
An optimizer rarely gets to choose every variable independently. A design may have a fixed material budget, a probability vector must sum to one, and a normalized quantum state has a fixed norm. The right question is therefore whether the objective can improve along an allowed direction. Lagrange multipliers express this geometry compactly. They produce candidate solutions under stated regularity conditions; a separate argument must establish which candidate is best and whether the optimum exists.
Feasible directions change the stationarity condition
For an unconstrained smooth minimum inside an open region, the gradient must vanish because every sufficiently small direction is allowed. Under an equality constraint , a feasible tangent direction instead satisfies . At a constrained stationary point, the objective has no first-order change in any such tangent direction. Its gradient can be nonzero while pointing entirely across the constraint surface.
With one smooth constraint and , a vector perpendicular to all feasible tangent directions must be parallel to the constraint gradient. This gives the multiplier equation. If the constraint gradient vanishes, that reasoning breaks down, and singular points need direct examination. For multiple equalities, the corresponding gradients must be independent to use the same regularity argument cleanly.
The Lagrangian organizes the equations
Define a Lagrangian by subtracting a multiplier times the constraint residual. Stationarity with respect to the original variables gives the parallel-gradient equation, while stationarity with respect to the multiplier restores feasibility. The sign convention is arbitrary if used consistently. The multiplier is an auxiliary unknown, not an extra design freedom that permits violating the constraint. Solve the objective and feasibility equations together.
A multiplier can also measure sensitivity. Under suitable smoothness and an isolated smoothly varying optimum, the derivative of the optimal objective with respect to the constraint level equals the multiplier for this sign convention. This shadow-price interpretation is local and depends on the parameterization of the constraint. Multiplying the constraint equation by a constant rescales the multiplier even though it leaves the feasible set unchanged.
Verification belongs to the solution
After solving the multiplier equations, compare candidates and inspect relevant boundaries or singular points. On a compact feasible set, a continuous objective attains a maximum and minimum, but those extrema can have different values. On an unbounded set, a stationary point need not be globally best and an optimum might not exist. Substituting the constraint into the objective is often the simplest independent check in a two-variable example.
Convexity can provide a stronger guarantee. A convex objective minimized over an affine set has no worse local minima hidden elsewhere; strict convexity gives uniqueness when a minimizer exists. Inequality constraints require additional logic, including active constraints and complementary slackness in the KKT framework. We have not derived that framework here. In machine learning, a nonconvex loss or a normalization constraint must be analyzed on its own terms rather than declared solved by writing a Lagrangian.
Work it through
Split a fixed total at minimum squared cost
Minimize subject to , allowing real x and y.
Let . Its gradient never vanishes, so the regular multiplier equations apply: with .
The two gradient components give . Feasibility then gives , with and objective value .
Verify globally by writing . The square is nonnegative for every feasible real x, so no other point has smaller cost.
The unique minimum is (3,3) with cost 18. More generally the minimum at total c is c²/2, whose derivative at c=6 equals the multiplier 6.
The living notebook
Explore the model
Interactive lab · optimization
Inspect steps before trusting an optimizer
Vary step size and initial coordinate in gradient descent on , then pause and step through the exact updates. Compare small steps with unstable . This unconstrained one-dimensional model does not enforce x+y=6 or solve multiplier equations; feasibility in this lesson is checked algebraically.
- Position x0
- 2
- Objective x²/2
- 2
- Iteration behavior
- Stable step
Gradient descent on f(x) = x²/2: xₙ = (1 − η)ⁿx₀. Playback advances two discrete iterations per second. Values outside |x| ≤ 4 are explicitly reported. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forAn attractive descent animation is not evidence that constraints or global optimality have been satisfied.
Pause & reason
Check your understanding
Your turn
Try it yourself
Maximize the area subject to and . Check both the interior and boundary.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Substitute y=10−x and complete the square on the interval from 0 to 10.
Compare with the solution
The area is . Its largest value is 25 at . The endpoints and both give zero, so checking them confirms that the interior candidate is the global maximum on the closed feasible interval.
Keep the idea
Take it with you
- Constrained stationarity concerns feasible tangent directions.
- Multiplier equations require regularity and produce candidates.
- A complete answer verifies feasibility, boundaries, and the claimed local or global guarantee.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.