Method of Lagrange Multipliers:
The maximum and minimum values of $z = f(x, \,y)$ subject to the
constraint $g(x, \,y) = 0$ occur at a point $(a, \,b)$ for which
there exists $\lambda$ such that
$$ (\nabla f)(a, \,b) \ =\ \lambda (\nabla g)(a, \,b),
\qquad g(a,\, b) \ = \ 0\,,$$
and $(\nabla g)(a, \,b) \ne 0$.
It doesn't matter whether you think of them in terms of gradients or
contour lines, since the formulas, and the method, are the same.
Now let's use the method of Lagrange multipliers
to solve a couple of problems, starting with
a slightly more complicated version of our hiking problem:
Example 1: Use Lagrange multipliers to find the minimum value of
$$f(x,\, y) \ = \ 2x^2 + y^2 +3$$
subject to the constraint
$$g(x,\,y)\ = \ x^2 + 4y^2 - 4 \ = \ 0\,.$$
Solution: The minimum value of
$$f(x,\, y) \ = \ 2x^2 + y^2 +3$$
subject to the constraint
$$g(x,\,y)\ = \ x^2 + 4y^2 - 4 \ = \ 0$$
occurs at solutions of
$$\nabla f(x,\, y) \,=\, \lambda (\nabla g)(x,\,y), \ \ g(x,\, y)\,=\,0\,.$$
Now
$$\nabla f(x,\, y) \,=\, 4x\,{\bf i} + 2y\,{\bf j}\,,$$
$$\nabla g(x,\, y) \,=\, 2x\,{\bf i} + 8y\,{\bf j}\,.$$
thus the critical points occur at solutions of
$$4x\,=\, 2\lambda x\,, \ \ 2y \,=\, 8\lambda y\,, \ \ x^2 + 4y^2 - 4 \,=\,0\,,$$
i.e., $ x^2 + 4y^2 - 4 =0 $ and
$$2x(2 - \lambda)\,=\, 0\,, \quad 2y(1 - 4\lambda)\,=\, 0\,.$$
So $x = 0$ or $\lambda = 2$. Now
(i) if $x = 0$,
$$ x^2 + 4y^2 - 4 \,=\, 0 \quad \Longrightarrow\quad y\,=\, \pm 1\,;$$
while
(ii) if $\lambda = 2$,
$$2y(1 - 4\lambda)\,=\, 0\quad \Longrightarrow\quad y \, =\, 0\,,$$
and then
$$ x^2 + 4y^2 - 4 \,=\, 0 \quad \Longrightarrow\quad x\,=\, \pm 2\,.$$
So the critical points are
$$(0,\, -1),\quad (0,\, 1), \quad (-2,\, 0),\quad (2,\, 0)\,.$$
But
$$f(0,\, -1)\ = \ f(0,\, 1) = \ 4\,, $$
$$ f(-2,\, 0)\ = \ f(2,\, 0)\ = \ 11\,.$$
Consequently, on $g(x,\,y) = 0$ the minimum value of $f(x,\,y)$ is 4, and it occurs at $(0,\,\pm1)$.
A standard application of Lagrange Multipliers occurs in
maximizing production of 'widgets' by allocating a fixed amount of
capital between labor and manufacturing costs. It is based on
so-called Cobb-Douglas functions $z = Cx^ay^b$ relating labor, capital
and output in an industrial economy as first derived by economist Paul
Douglas and mathematician Charles Cobb long before financial
engineering became a 'hot topic'.
Example 2:By investing $x$ units of labor and $y$
units capital, Texas Tees can produce
$$P(x,\,y)\ = \ 40x^{3/5}y^{2/5}$$
T-shirts. Determine the maximum number of T-shirts that can be
produced on a budget of
$\$10,000$ if labor costs $\$100$ per unit and capital
costs $\$200$ per unit.
Solution: We have to maximize the function
$$P(x,\,y)\ = \ 40x^{3/5}y^{2/5}$$
subject to the budget constraint
$$g(x,\,y)\ = \ 100x + 200y - 10,000 \ = \ 0\,.$$
This maximum occurs at solutions of
$$\nabla P(x,\, y) \ = \ \lambda (\nabla g)(x,\,y), \quad g(x,\, y) \ = \ 0\,.$$
Now
$$\frac{\partial P}{\partial x}\ = \ 40\Bigl(\frac{3}{5}x^{-2/5}y^{2/5}\Bigl)\,,$$
$$\frac{\partial P}{\partial y}\ = \ 40\Bigl(\frac{2}{5}x^{3/5}y^{-3/5}\Bigl)\,.$$
Thus
$$\nabla P(x,\, y) \,=\, 8x^{-2/5}y^{-3/5}\bigl(3y\,{\bf i} + 2x\,{\bf j}\bigl)\,,$$
while
$$\nabla g(x,\, y) \,=\, 100\,{\bf i} + 200\,{\bf j}\,.$$
So the critical points occur at solutions of
$$ \bigl(8x^{-2/5}y^{-3/5}\bigl)3y \ = \ 100\lambda\,,$$
$$ \bigl(8x^{-2/5}y^{-3/5}\bigl)2x\ = \ 200\lambda\,,$$
which simplifies to
$$\frac{\lambda}{8x^{-2/5}y^{-3/5}} \ = \ \frac{3y}{100}\ = \ \frac{2x}{200}\,,$$
i.e., $y = \frac{1}{3}x$.
Substituting for $y = \frac{1}{3}x$ in the budget constraint condition, we find that
$$x \ = \ 60\,, \qquad y\ = \ 20\,.$$
Since
$$P(60,\,20)\ = \ 40(60)^{3/5}(20)^{2/5} \ \approx \ 1546.55\,, $$
the maximum number of T-shirts that can be produced is $1546$.
We work two additional problems in the following video:
Find the local maxima and minima of the function $f(x,y,z) =
x^2+2y^2-3z^2$ on the sphere $x^2+y^2+z^2=1$.
In the $xy$ plane, find the point(s) on the ellipse
$\frac{(x+1)^2}{9}+y^2=1$ that are closest to the origin.