linguistic:paraphrasing, structural:expansion, linguistic:voice_change
Example 1

Suppose we wish to maximize f (x, y) = x + y {\displaystyle \ f(x,y)=x+y\ } subject to the constraint x 2 + y 2 = 1. {\displaystyle \ x^{2}+y^{2}=1~.} The feasible set is the unit circle, and the level sets of f are diagonal lines (with slope −1), so we can see graphically that the maximum occurs at (1 2, 1 2) , {\displaystyle \ \left({\tfrac {1}{\sqrt {2}}},{\tfrac {1}{\sqrt {2}}}\right)\,} and that the minimum occurs at (− 1 2, − 1 2). {\displaystyle \ \left(-{\tfrac {1}{\sqrt {2}}},-{\tfrac {1}{\sqrt {2}}}\right)~.}

For the method of Lagrange multipliers, the constraint is g (x, y) = x 2 + y 2 − 1 = 0 , {\displaystyle g(x,y)=x^{2}+y^{2}-1=0\,} hence the Lagrangian function, L (x, y, λ) = f (x, y) + λ ⋅ g (x, y) = x + y + λ (x 2 + y 2 − 1) , {\displaystyle {\begin{aligned}{\mathcal {L}}(x,y,\lambda)&=f(x,y)+\lambda \cdot g(x,y)\\&=x+y+\lambda (x^{2}+y^{2}-1)\,\end{aligned}}} is a function that is equivalent to f (x, y) {\displaystyle \ f(x,y)\ } when g (x, y) {\displaystyle \ g(x,y)\ } is set to 0.

Now we can calculate the gradient: ∇ x, y, λ L (x, y, λ) = (∂ L ∂ x, ∂ L ∂ y, ∂ L ∂ λ) = (1 + 2 λ x, 1 + 2 λ y, x 2 + y 2 − 1) , {\displaystyle {\begin{aligned}\nabla _{x,y,\lambda }{\mathcal {L}}(x,y,\lambda)&=\left({\frac {\partial {\mathcal {L}}}{\partial x}},{\frac {\partial {\mathcal {L}}}{\partial y}},{\frac {\partial {\mathcal {L}}}{\partial \lambda }}\right)\\&=\left(1+2\lambda x,1+2\lambda y,x^{2}+y^{2}-1\right)\ \color {gray}{,}\end{aligned}}} and therefore: ∇ x, y, λ L (x, y, λ) = 0 ⇔ { 1 + 2 λ x = 0 1 + 2 λ y = 0 x 2 + y 2 − 1 = 0 {\displaystyle \nabla _{x,y,\lambda }{\mathcal {L}}(x,y,\lambda)=0\quad \Leftrightarrow \quad {\begin{cases}1+2\lambda x=0\\1+2\lambda y=0\\x^{2}+y^{2}-1=0\end{cases}}}

Notice that the last equation is the original constraint.

The first two equations yield x = y = − 1 2 λ, λ ≠ 0. {\displaystyle x=y=-{\frac {1}{2\lambda }},\qquad \lambda \neq 0~.} By substituting into the last equation we have: 1 4 λ 2 + 1 4 λ 2 − 1 = 0 , {\displaystyle {\frac {1}{4\lambda ^{2}}}+{\frac {1}{4\lambda ^{2}}}-1=0\,} so λ = ± 1 2 , {\displaystyle \lambda =\pm {\frac {1}{\sqrt {2\ }}}\,} which implies that the stationary points of L {\displaystyle {\mathcal {L}}} are (2 2, 2 2, − 1 2), (− 2 2, − 2 2, 1 2). {\displaystyle \left({\tfrac {\sqrt {2\ }}{2}},{\tfrac {\sqrt {2\ }}{2}},-{\tfrac {1}{\sqrt {2\ }}}\right),\qquad \left(-{\tfrac {\sqrt {2\ }}{2}},-{\tfrac {\sqrt {2\ }}{2}},{\tfrac {1}{\sqrt {2\ }}}\right)~.}

Evaluating the objective function f at these points yields f (2 2, 2 2) = 2 , f (− 2 2, − 2 2) = − 2. {\displaystyle f\left({\tfrac {\sqrt {2\ }}{2}},{\tfrac {\sqrt {2\ }}{2}}\right)={\sqrt {2\ }}\,\qquad f\left(-{\tfrac {\sqrt {2\ }}{2}},-{\tfrac {\sqrt {2\ }}{2}}\right)=-{\sqrt {2\ }}~.}

Thus the constrained maximum is 2 {\displaystyle \ {\sqrt {2\ }}\ } and the constrained minimum is − 2 {\displaystyle -{\sqrt {2}}}.