Lagrange Multipliers
Optimising under a constraint: at the best point, the gradient of the function is a multiple of the constraint's gradient.
Needs a step first: 12
To maximise while staying on the curve , picture the contour lines of . At the best point a contour just touches the constraint curve, so the two gradients are parallel: . Solving this together with gives the candidates, and the multiplier has a meaning: it is how fast the best value changes if the constraint is loosened, a shadow price. The method finds maximum-entropy distributions, gives the Boltzmann distribution in statistical mechanics, and sets up support vector machines.
Where it shows up: Maximising entropy under an energy constraint gives the Boltzmann distribution, and the same idea underlies softmax.
How to hold it: In your head
Picture a contour of just touching the constraint curve, so the two gradients are parallel, and read as the price of loosening the constraint.
What knowing it looks like
- Solve a two-variable constrained problem with .
- Explain with a contour sketch why the gradients must be parallel at the optimum.
- Interpret as the rate of change of the optimum with the constraint level.
Test yourself
Maximise subject to using a Lagrange multiplier. Find the maximum, the value of , and check that predicts how the maximum changes if 8 becomes .
Show the worked answer
Needs a step first: 12
Learn it with an AI
Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.
Be my maths tutor. I'm learning "Lagrange Multipliers" (Undergraduate II tier): Optimising under a constraint: at the best point, the gradient of the function is a multiple $\lambda$ of the constraint's gradient. I already know: Optimisation in Many Variables. Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away. Finish by testing me with this: Maximise $f(x, y) = xy$ subject to $x + 2y = 8$ using a Lagrange multiplier. Find the maximum, the value of $\lambda$, and check that $\lambda$ predicts how the maximum changes if 8 becomes $8 + \delta$. Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.
Needs first
Leads to
This is the end of a path.
Recommended
- Mathematics for Machine LearningDeisenroth, Faisal and Ong (Cambridge University Press) · BookA free book that gathers exactly the linear algebra, vector calculus, probability and optimisation machine learning uses, then applies them to regression, PCA and classification.
- Convex OptimizationStephen Boyd and Lieven Vandenberghe · BookThe standard text on convex sets, duality and Lagrange multipliers, free as a PDF from Stanford along with lecture slides and exercises.
- Information Theory, Inference, and Learning AlgorithmsDavid MacKay · BookMacKay's book connecting entropy, coding, Bayesian inference and neural networks, free to read online and still the one recommended for information theory with intuition.