Lagrange multipliers: optimising under a constraint
Almost every real decision is a maximum or minimum problem with a constraint. A factory wants the greatest profit but has a limited amount of raw material. A can must hold 350 ml using as little aluminium as possible. A pendulum moves however it likes, as long as the bob stays attached to the string. Lagrange found a single method for all these problems. It appears in the Analytical Mechanics of 1788, to deal with the ties of mechanical systems, and in the Theory of Analytic Functions of 1797, as a general rule of calculation.
The pen
Let us start with a problem the Greeks already knew how to solve. With 20 metres of fencing, which rectangle has the largest area? If the sides are $x$ and $y$, we want the largest value of
$$f(x,y)=xy\qquad\text{with the constraint}\qquad g(x,y)=x+y=10.$$Here it would be easy to isolate $y=10-x$ and maximise $x(10-x)$. But in many problems the constraint is a complicated equation from which nothing can be isolated. Lagrange wanted a method that never needed that.
A new letter
Lagrange’s recipe is to add a new unknown, which today we call $\lambda$, the multiplier, and require the derivatives of $f$ to be proportional to those of $g$:
$$\begin{aligned}\frac{\partial f}{\partial x}&=\lambda\,\frac{\partial g}{\partial x},\\ \frac{\partial f}{\partial y}&=\lambda\,\frac{\partial g}{\partial y},\\ g(x,y)&=10.\end{aligned}$$For the pen, $\frac{\partial f}{\partial x}=y$, $\frac{\partial f}{\partial y}=x$ and the derivatives of $g$ are $1$. The equations become
$$y=\lambda,\qquad x=\lambda,\qquad x+y=10,$$and so $x=y=5$. The best rectangle is the square of 5 by 5, with an area of 25 m². There was no need to isolate anything: the constraint came in as one more equation, and $\lambda$ as one more unknown.
Why it works
The figure below shows the curves on which the area $xy$ has a fixed value, 9, 16, 25 and 36, and the constraint line $x+y=10$. Moving along the line, we pass through curves of larger and larger area, up to the curve of area 25. After that, the areas decrease again. The curve 36 does not even touch the line.
At the optimum, the line and the curve of maximum area are tangent. If they crossed, we could move a little further along the line and enter a curve of larger area. Tangent curves have the same direction, and that is why the derivatives of $f$ and $g$ are proportional there. The multiplier $\lambda$ is the factor of that proportion.
What λ says
Lagrange introduced $\lambda$ as a computational device, but it has a meaning. For the pen, $\lambda=5$. If the sum of the sides changes from $s=10$ to any value $s$, the best area will be that of the square of side $\frac s2$, that is, $\frac{s^2}{4}$. The rate of change of this area is
$$\frac{d}{ds}\left(\frac{s^2}{4}\right)=\frac s2=5=\lambda.$$The multiplier tells you how much you gain by loosening the constraint: each extra metre in the sum of the sides yields about 5 m² more area. Economists call $\lambda$ the shadow price: what one more unit of the scarce resource would be worth.
In mechanics, where Lagrange invented the method, the multiplier also has a physical meaning. It is the constraint force. In the pendulum, if instead of using the angle as a coordinate we use $x$ and $y$ with the constraint $x^2+y^2=\ell^2$, the multiplier that appears is proportional to the tension in the string. The force that Lagrange’s method had made disappear comes back, when wanted, as a letter $\lambda$.
Exercise: which point of the line x + 2y = 5 is closest to the origin?
We minimise the square of the distance, $f=x^2+y^2$, with $g=x+2y=5$. The equations are $2x=\lambda$, $2y=2\lambda$ and $x+2y=5$. From the first two, $y=2x$, and the constraint gives $5x=5$. The point is $(1,2)$, the distance is $\sqrt5\approx2.24$ and $\lambda=2$.
Exercise: what shape should a cylindrical can have to use the least material?
With radius $r$ and height $h$, the volume $V=\pi r^2h$ is fixed and we want to minimise the area $S=2\pi r^2+2\pi rh$. Lagrange’s equations are
$$\begin{aligned}4\pi r+2\pi h&=\lambda\cdot2\pi rh,\\ 2\pi r&=\lambda\cdot\pi r^2.\end{aligned}$$The second gives $\lambda=\frac2r$. Putting it into the first, $4\pi r+2\pi h=4\pi h$, and so $h=2r$: the height should equal the diameter. Food cans tend to be close to this. Drink cans are taller, because the lid is thicker and more expensive than the wall, and the calculation changes.
Sources: Joseph-Louis Lagrange, Méchanique analitique (1788) and Théorie des fonctions analytiques (1797) · biography of Lagrange, MacTutor · Harold W. Kuhn and Albert W. Tucker, “Nonlinear Programming” (1951).
All Lagrange topics · ← The derivative without infinitesimals and the mean value theorem · Lagrange’s legacy →