The set of points satisfying the constraint
\(g(x,y) = 0\) is a curve
\(C\) in the plane: it is precisely the level curve of
\(g\) of value
\(0\text{.}\) We showed in
Theoremย 7.10 that the gradient of a function is perpendicular to its level curves, so at every point of
\(C\) where
\(\nabla g \neq \mathbf 0\text{,}\)
\begin{equation}
\nabla g \cdot \mathbf T = 0,\tag{10.2}
\end{equation}
where \(\mathbf T\) is a vector tangent to \(C\) at that point. To stay on the curve, any small motion away from the point must be along the tangent direction \(\mathbf T\text{.}\)
How does
\(f\) change as we move along
\(C\text{?}\) By
(7.5), the rate of change of
\(f\) in the direction of the unit tangent vector
\(\mathbf T\) is the directional derivative
\begin{equation}
D_{\mathbf T} f = \nabla f \cdot \mathbf T.\tag{10.3}
\end{equation}
If
\(\nabla f \cdot \mathbf T \neq 0\) at a point of
\(C\text{,}\) as in
Figureย 10.1, then the motion along the curve has a component along
\(\nabla f\text{:}\) the value of
\(f\) increases as we move along
\(C\) in the direction of
\(\mathbf T\) and decreases as we move in the direction of
\(-\mathbf T\text{.}\) Such a point cannot be a constrained maximum or minimum.
At a constrained local maximum or minimum, then, a small motion along the curve must not produce any change in
\(f\text{:}\) the rate of change
(10.3) must vanish, so
\begin{equation}
\nabla f \cdot \mathbf T = 0.\tag{10.4}
\end{equation}
Now compare
(10.2) and
(10.4): at a constrained extremum, the tangent vector
\(\mathbf T\) is perpendicular to both gradients
\(\nabla f\) and
\(\nabla g\text{.}\) In the plane, all vectors perpendicular to the nonzero vector
\(\mathbf T\) lie on a single line, so
\(\nabla f\) and
\(\nabla g\) must be collinear (parallel). Phrased differently, there exists some number
\(\lambda \in \R\) such that
\begin{equation}
\nabla f = \lambda\, \nabla g.\tag{10.5}
\end{equation}
Figureย 10.2 explains the condition
(10.5) by superposing the constraint curve
\(g(x,y) = 0\) onto the family of level curves of
\(f(x,y)\text{,}\) that is, the collection of curves
\(f(x,y) = c\text{,}\) where
\(c\) is a real number in the range of
\(f\text{.}\) In the figure,
\(c_1 \lt c^* \lt c_3 \lt c_4 \lt c_5\text{.}\) Imagine a point moving along the constraint curve from
\((x_1,y_1)\) to
\((x_2,y_2)\text{.}\) Initially, the motion has a component along the negative gradient direction
\(-\nabla f\text{,}\) so the value of
\(f\) decreases. This component becomes smaller and smaller. When the moving point reaches
\((x^*,y^*)\text{,}\) the motion is perpendicular to
\(\nabla f\text{.}\) From that point on, the motion has a component along the gradient direction
\(\nabla f\text{,}\) so the value of
\(f\) increases. Thus at
\((x^*,y^*)\) the function
\(f\) achieves a local minimum on the constraint curve, namely the value
\(c^*\text{.}\) The motion is in the tangential direction of the constraint curve, which is perpendicular to
\(\nabla g\text{;}\) therefore at
\((x^*,y^*)\) the two gradients
\(\nabla f\) and
\(\nabla g\) are collinear, which is what
(10.5) says. Since both curves are perpendicular to the same line at
\((x^*,y^*)\text{,}\) the level curve
\(f(x,y) = c^*\) and the constraint curve
\(g(x,y) = 0\) are tangent at
\((x^*,y^*)\text{.}\)
Suppose we find the set \(S\) of points \((x,y)\) satisfying the two equations
\begin{align*}
g(x,y) \amp= 0,\\
\nabla f \amp= \lambda\, \nabla g \quad \text{for some } \lambda.
\end{align*}
Then \(S\) contains the local extrema of \(f\) subject to the constraint \(g(x,y) = 0\text{.}\) The same reasoning applies to functions of three variables: there the constraint \(g(x,y,z) = 0\) defines a level surface of \(g\text{,}\) the gradient \(\nabla g\) is perpendicular to that surface, and at a constrained extremum \(\nabla f\) can have no component tangent to the surface, so once again \(\nabla f\) and \(\nabla g\) must be collinear.