This Optimization concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Optimization
Lagrange Multipliers and Constrained Optimization
Lagrange multipliers turn a constrained optimum into a normal-vector alignment condition and interpret the multiplier as local constraint sensitivity.
Concept Structure
Lagrange Multipliers and Constrained Optimization
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
2 prerequisites listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Substantive review recorded
1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
A constraint changes what "downhill" means.
If you can move anywhere, minimizing a smooth function means looking for a point where the gradient is zero. But on a constraint, most directions are illegal. A point can still have a nonzero objective gradient and be optimal, because the gradient may point straight out of the feasible surface instead of along it.
Think about minimizing distance to a target while staying on a circle. The unconstrained best point is the target itself. If the target is outside the circle, you cannot go there. The constrained best point is where the circle gets closest to the target.
At that point, the objective gradient does not run along the circle. It points normal to the circle. Every legal first-order move is tangent, and tangent motion no longer improves the objective. That is the core Lagrange multiplier picture:
- the constraint gradient points normal to the feasible surface ;
- the objective gradient must have no tangent component at a constrained optimum;
- therefore is a scalar multiple of .
The multiplier is not just algebraic decoration. In a well-behaved problem it also tells you sensitivity: if you loosen or tighten the constraint a little, the optimal value changes at a rate controlled by the multiplier.
This page deliberately stops before full inequality KKT theory. The next page can introduce active constraints, complementary slackness, and dual certificates. First we need the simpler skill: see the normal-vector alignment and read the multiplier as "how much the constraint is biting."
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Start with a smooth equality-constrained minimization problem:
The feasible directions at a smooth point satisfy the first-order constraint condition
So feasible directions are tangent to the level set of . If is a constrained local minimizer, then no feasible first-order direction should reduce the objective:
That means is orthogonal to the tangent space. For one equality constraint, the normal space is spanned by , so there is a scalar such that
Equivalently, define the Lagrangian
The first-order equations are
Now use the toy problem from the demo. Let be a target point outside the unit circle and solve
Here
The Lagrange condition is
Because lies on the unit circle, the closest feasible point is the normalized target direction:
Substitute this into the stationarity equation:
For the perturbed constraint , the optimal value is
At ,
So if is large and positive, loosening the squared-radius constraint decreases the best achievable objective value quickly. That is the sensitivity interpretation the demo asks you to inspect.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
c = np.array([1.8, 1.1]) # unconstrained target
rho = 1.0 # circle: x^T x = rho
r = np.sqrt(rho)
x_star = r * c / np.linalg.norm(c)
grad_f = x_star - c
grad_h = 2.0 * x_star
lambda_star = -grad_f @ grad_h / (grad_h @ grad_h)
p_star = 0.5 * np.linalg.norm(x_star - c) ** 2
rho_step = 1e-4
r2 = np.sqrt(rho + rho_step)
x2 = r2 * c / np.linalg.norm(c)
p2 = 0.5 * np.linalg.norm(x2 - c) ** 2
finite_diff = (p2 - p_star) / rho_step
print("x_star:", np.round(x_star, 3))
print("grad_f:", np.round(grad_f, 3))
print("grad_h:", np.round(grad_h, 3))
print("lambda:", round(lambda_star, 3))
print("sensitivity dp*/d rho:", round(finite_diff, 3))
print("-lambda:", round(-lambda_star, 3))
The witness computes the same object as the live lab. The multiplier comes from projecting onto the constraint normal. The finite difference checks the sensitivity claim by slightly loosening the squared-radius constraint.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
The lab asks for the vector relation before revealing the arrows and ledger. Predict first: at the constrained minimizer, should the objective gradient be tangent to the circle, normal to the circle, or should the point simply equal the unconstrained target?
Live Concept Demo
Explore Lagrange Multipliers and Constrained Optimization
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Lagrange Multipliers and Constrained Optimization should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Lagrange multipliers turn a constrained optimum into a normal-vector alignment condition and interpret the multiplier as local constraint sensitivity.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Lagrange Multipliers and Constrained Optimization should make visible.
Visual Inquiry
Make the image answer a mathematical question
Lagrange multipliers turn a constrained optimum into a normal-vector alignment condition and interpret the multiplier as local constraint sensitivity.
Which visible object should carry the first intuition?
Pick the cue that should make Lagrange Multipliers and Constrained Optimization easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Supports constrained optimization, Lagrange multipliers, equality-constraint multiplier freedom, duality setup, and the PCA eigenvector example.
Open sourceSupports the Lagrangian, Lagrange multiplier optimality conditions, KKT stationarity, and multiplier sensitivity interpretation.
Open sourceSupports Lagrangian dual variables as constraint costs, weak/strong duality intuition, KKT conditions, and the SVM support-vector connection.
Open sourceClaim Review
Lagrange multipliers turn a constrained optimum into a normal-vector alignment condition and interpret the multiplier as local constraint sensitivity.
Claims without a substantive review badge still need exact source-support review.
deisenroth-2020-mml-lagrange, boyd-2004-convex-optimization-lagrange, cs229-cvxopt2-lagrange-duality
Use equations, runnable code, and demos to check whether the source support is operational.
The sources support constrained optimization as the right setting, the construction of a Lagrangian with multiplier variables, the stationarity equation, the equality multiplier being unconstrained, and the sensitivity reading of optimal multipliers.
Sources: Mathematics for Machine Learning, Convex Optimization, CS229 Section Notes: Convex Optimization OverviewThis page teaches a smooth equality-constrained toy and only previews inequality constraints, duality, and KKT. It does not certify second-order sufficiency, constraint qualification edge cases, nonsmooth constraints, numerical solver behavior, or SVM dual derivations.A bounded review summary is present; still check caveats and exact reference scope.Checked MML chapter 7 for constrained optimization, Lagrange multipliers, equality-constraint multiplier treatment, and PCA as constrained optimization; Boyd/Vandenberghe chapters 4-5 for equality-constrained optimality, Lagrangian multiplier vectors, KKT stationarity, and sensitivity; and Stanford CS229 convex optimization notes for Lagrangian dual variables, KKT stationarity, active constraints, and SVM motivation. GPT Pro publication critique remains pending because 127.0.0.1:51672 refused connection.
Reviewer: codex-local-source-review; reviewed 2026-07-02Source support candidates
book 2020Mathematics for Machine LearningSupports constrained optimization, Lagrange multipliers, equality-constraint multiplier freedom, duality setup, and the PCA eigenvector example.
book 2004Convex OptimizationSupports the Lagrangian, Lagrange multiplier optimality conditions, KKT stationarity, and multiplier sensitivity interpretation.
course-notes 2009CS229 Section Notes: Convex Optimization OverviewSupports Lagrangian dual variables as constraint costs, weak/strong duality intuition, KKT conditions, and the SVM support-vector connection.
Practice Loop
Try the idea before it explains itself
Lagrange multipliers turn a constrained optimum into a normal-vector alignment condition and interpret the multiplier as local constraint sensitivity.
Before touching the demo, predict one visible change that should happen in Lagrange Multipliers and Constrained Optimization.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to a claim, equation, code, or demo
Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.Open the draft below to save one note and next action in this browser.
Lagrange Multipliers and Constrained Optimization
What is the smallest example that makes Lagrange Multipliers and Constrained Optimization click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- References to inspect: attached references on this page.
- Definition, prerequisite, and contrast concept links
- The equation or runnable code that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Lagrange Multipliers and Constrained Optimization Selected item key: recorded for copy. Context: Optimization Page anchor: recorded for copy. Open question: What is the smallest example that makes Lagrange Multipliers and Constrained Optimization click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/optimization/lagrange-multipliers-constrained-optimization
concept:optimization/lagrange-multipliers-constrained-optimization