# 14.8: Lagrange Multipliers

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

Many applied max/min problems take the form of the last two examples: we want to find an extreme value of a function, like $$V=xyz$$, subject to a constraint, like $$1=\sqrt{x^2+y^2+z^2}$$. Often this can be done, as we have, by explicitly combining the equations and then finding critical points. There is another approach that is often convenient, the method of Lagrange multipliers.

It is somewhat easier to understand two variable problems, so we begin with one as an example. Suppose the perimeter of a rectangle is to be 100 units. Find the rectangle with largest area. This is a fairly straightforward problem from single variable calculus. We write down the two equations: $$A=xy$$, $$P=100=2x+2y$$, solve the second of these for $$y$$ (or $$x$$), substitute into the first, and end up with a one-variable maximization problem.

Let's now think of it differently: the equation $$A=xy$$ defines a surface, and the equation $$100=2x+2y$$ defines a curve (a line, in this case) in the $$x$$-$$y$$ plane. If we graph both of these in the three-dimensional coordinate system, we can phrase the problem like this: what is the highest point on the surface above the line? The solution we already understand effectively produces the equation of the cross-section of the surface above the line and then treats it as a single variable problem. Instead, imagine that we draw the level curves (the contour lines) for the surface in the $$x$$-$$y$$ plane, along with the line (Figure $$\PageIndex{1}$$).

Figure $$\PageIndex{1}$$: Constraint line with contour plot of the surface $$xy$$.

Another possibility is that we have a function of three variables, and we want to find a maximum or minimum value not on a surface but on a curve; often the curve is the intersection of two surfaces, so that we really have two constraint equations, say $$g(x,y,z)=c_1$$ and $$h(x,y,z)=c_2$$. It turns out that at points on the intersection of the surfaces where $$f$$ has a maximum or minimum value,

$\nabla f=\lambda\nabla g+\mu \nabla h.$

As before, this gives us three equations, one for each component of the vectors, but now in five unknowns, $$x$$, $$y$$, $$z$$, $$\lambda$$, and $$\mu$$. Since there are two constraint functions, we have a total of five equations in five unknowns, and so can usually find the solutions we need.

Example $$\PageIndex{2}$$

The plane $$x+y-z=1$$ intersects the cylinder $$x^2+y^2=1$$ in an ellipse. Find the points on the ellipse closest to and farthest from the origin.

Solution

We want the extreme values of $$f=\sqrt{x^2+y^2+z^2}$$ subject to the constraints $$g=x^2+y^2=1$$ and $$h=x+y-z=1$$. To simplify the algebra, we may use instead $$f=x^2+y^2+z^2$$, since this has a maximum or minimum value at exactly the points at which $$\sqrt{x^2+y^2+z^2}$$ does. The gradients are

$\nabla f =\langle 2x,2y,2z\rangle\qquad \nabla g = \langle 2x,2y,0\rangle\qquad \nabla h = \langle 1,1,-1\rangle,\nonumber$

so the equations we need to solve are

\eqalign{ 2x&=\lambda 2x+\mu\cr 2y&=\lambda 2y+\mu\cr 2z&=0-\mu\cr 1&=x^2+y^2\cr 1&=x+y-z.\cr }\nonumber

Subtracting the first two we get $$2y-2x=\lambda(2y-2x)$$, so either $$\lambda=1$$ or $$x=y$$. If $$\lambda=1$$ then $$\mu=0$$, so $$z=0$$ and the last two equations are

$1=x^2+y^2\qquad\hbox{and}\qquad 1=x+y.\nonumber$

Solving these gives $$x=1$$, $$y=0$$, or $$x=0$$, $$y=1$$, so the points of interest are $$(1,0,0)$$ and $$(0,1,0)$$, which are both distance 1 from the origin. If $$x=y$$, the fourth equation is $$2x^2=1$$, giving $$x=y=\pm1/\sqrt2$$, and from the fifth equation we get $$z=-1\pm\sqrt2$$. The distance from the origin to $$(1/\sqrt2,1/\sqrt2,-1+\sqrt2)$$ is $$\sqrt{4-2\sqrt2}\approx 1.08$$ and the distance from the origin to $$(-1/\sqrt2,-1/\sqrt2,-1-\sqrt2)$$ is $$\sqrt{4+2\sqrt2}\approx 2.6$$. Thus, the points $$(1,0,0)$$ and $$(0,1,0)$$ are closest to the origin and $$(-1/\sqrt2,-1/\sqrt2,-1-\sqrt2)$$ is farthest from the origin.

The Java applet shows the cylinder, the plane, the four points of interest, and the origin.

## Contributors

• Integrated by Justin Marshall.

This page titled 14.8: Lagrange Multipliers is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by David Guichard.