Advanced Mathematics

Lagrange Multipliers

Optimising under a constraint: at the best point, the gradient of the function is a multiple λ\lambda of the constraint's gradient.

Needs a step first: 12

To maximise ff while staying on the curve g=cg = c, picture the contour lines of ff. At the best point a contour just touches the constraint curve, so the two gradients are parallel: ∇f=λ∇g\nabla f = \lambda\nabla g. Solving this together with g=cg = c gives the candidates, and the multiplier λ\lambda 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 ff just touching the constraint curve, so the two gradients are parallel, and read λ\lambda as the price of loosening the constraint.

What knowing it looks like

  • Solve a two-variable constrained problem with ∇f=λ∇g\nabla f = \lambda\nabla g.
  • Explain with a contour sketch why the gradients must be parallel at the optimum.
  • Interpret λ\lambda as the rate of change of the optimum with the constraint level.

Test yourself

Maximise f(x,y)=xyf(x, y) = xy subject to x+2y=8x + 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+δ8 + \delta.
Show the worked answer
∇f=(y,x)=λ(1,2)\nabla f = (y, x) = \lambda(1, 2), so y=λy = \lambda and x=2λx = 2\lambda. The constraint gives 2λ+2λ=82\lambda + 2\lambda = 8, so λ=2\lambda = 2, x=4x = 4, y=2y = 2, and the maximum is f=8f = 8. For general cc in place of 8: x=c/2x = c/2, y=c/4y = c/4, maximum c2/8c^2/8, whose derivative at c=8c = 8 is c/4=2=λc/4 = 2 = \lambda. So the maximum rises by about 2δ2\delta.

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.

Recommended