GRADIENTS, DIRECTIONAL DERIVATIVES

         
        


   So you are back in Yosemite and feel like doing a bit of serious hiking. You've pulled up the contour map to the right on your iPhone and located yourself at the black dot on the 9200' contour. One natural question to ask is for the slope of the terrain from where you in the particular direction you set off to walk.

    If you are feeling particularly energetic, you might even try to take the steepest path to the top of the mountain - we might call that the Path of Steepest Ascent'. This will mean that at each point on your path you always take the direction of greatest slope. But if you are on the 9200' contour, that direction of greatest slope must be perpendicular to the contour, because if you walk uphill in a direction that is not perpendicular, then you are 'cutting across' the mountain and not climbing uphill as fast as you can.




        Now, mathematically, the terrain is the graph of  $z = f(x, y)$ and if $(x(t), y(t))$ is a curve in the $xy$-plane, then the graph of 

r$(t) = \langle x(t), y(t), f(x(t), y(t)) \rangle$

is a space curve lying on the graph of $f$.
It's the mathematical way of describing a path in Yosemite, say. Different curves provide different information. But first we make a crucial


Definition:

For a function $f(x, y)$ the GRADIENT of $f$ is the vector function 

$\nabla f(x, y)   =   f_x(x, y)\,$i$ \, +\, f_y(x, y)\,$j  

whose respective components are $f_x$ and $f_y$.  
     


For example, when $f(x, y) = x^2 - y^2$, then $(\nabla f)(x, y)  =  2x\,$i$ - 2y\,$j.

     C
omposition suggests the Chain Rule:

$ \displaystyle{\frac{d }{d t} f(x(t), y(t)) }  =   \displaystyle{\frac{\partial f}{\partial x} \frac{d x}{d t}\, +\, \frac{\partial f}{\partial y}\frac{d y}{d t}}  =   x'(t) f_x + y'(t) f_y $,

which in turn suggests the dot product. For if we set c$(t) = \langle x(t), y(t) \rangle,$ then c$'(t) =\langle x'(t), y'(t) \rangle$ and

$\displaystyle{\frac{d }{d t}f(}$c$(t))  = \displaystyle{ \frac{d }{d t} f(x(t), y(t))   =  x'(t)f_x + y'(t) f_y  =  (\nabla f)(}$c$(t)) \cdot $c$'(t)$.

An example from a familiar setting will help.

CURVE 1: set

$f(x, y)  = 2+ x^2 - y^2$,    c$(t)  =  \langle \cos t, \, \sin t\rangle$.

 The graph of c is a circle in the $xy$-plane, while the graph of

$f($c$(t))  =   f(\cos t, \sin t)  =  2 + \cos 2t$

is the intersection of a hyperbolic paraboloid and a circular cylinder as shown to the right. Now

$\displaystyle{\frac{d }{dt} f(}$c$(t))  =   -2\sin 2t,}$

while

c$'(t)   =   \langle -\sin t, \cos t\rangle$,      $\nabla f($c$(t))  =  2\cos t$ i $ -2 \sin t$ j.

 But then

$(\nabla f )($c$(t)) \cdot $c$'(t)  =   -4 \cos t \sin t  =  -2 \sin 2t$,

confirming that

$\displaystyle{\frac{d }{d t} f(}$c$(t))  =  (\nabla f )($c$(t)) \cdot $c$'(t)$.

 Now the tangent vector to the space curve can be calculated:

r$'(t)  =  \langle x'(t), y'(t),  \displaystyle{\frac{d }{d t} f(x(t), y(t)) \rangle } =  \langle x'(t), y'(t), (\nabla f)(}$c$(t)) \cdot $c$'(t)) \rangle$.

It is shown in orange in the previous graphic.     


Second Definition:
For a UNIT vector v$= h\,$i $+k\,$j the DIRECTIONAL DERIVATIVE  of $z = f(x, y)$ at $(a, b)$ in the direction v is
$Df$v$(a, b) = \displaystyle{\lim_{t \to 0} \frac{f(a+th, b+tk) - f(a, b)}{t}.}$         

Of course, $Df$i$(a, b) = f_x(a, b)$ and $Df$j$(a, b) = f_y(a, b)$.




Since

$Df$v$(a, b)  =  \displaystyle{\lim_{t \to 0}\frac{f(a+th, b+tk) - f(a, b)}{t}  =  \frac{d }{d t} f(a+th, b+tk) \Big|_{t = 0}},$

this suggests what the next choice of curve should be.



CURVE 2.  Let
  
c$(t) = (a+th)$i + $(b+tk)$j

be the line through $(a, b)$ in the direction of a vector v$ = h\,$i +$k\,$j. When the surface to the right is the graph of $f$,
the graph of

$f($c$(t))  =   f(a+th, b+tk)$

is the curve 
shown in orange on the surface. On the other hand,
   
 c$(0) = (a, b)$,          c$'(0) = h$ i $+ k$j$ = $v,

so

$Df$v$(a, b)  =  \nabla f(a, b)\cdot $v

This tells us how to compute all directional derivatives $Df$v$(a, b)$.


      Finally, we can see what the gradient vector has to do with contours. What's a contour? Well, its a curve c$(t) = \langle x(t), y(t) \rangle$ in the $xy$-plane such that $f($c$(t)) = k$ where $k$ is some constant. The graph to the left below shows one contour, while the one to the right shows two contours realized as curves in the $xy$-plane.



CURVE 3:


    But if we differentiate the equation  $f($c$(t)) = k$, then

$\displaystyle\frac{d }{d t} f(}$c$(t))  =  (\nabla f)($c$(t))\cdot $c$'(t)  =  0.$

Now c$'(t)$ is the tangent vector to the contour, so the fact that $(\nabla f)($c$(t)\cdot $c$'(t) = 0$ means that the $\nabla f$ is perpendicular at c$(t)$ to the contour. That's what the right hand graph shows. But why are some vectors longer than others? Look on the graph where those short vectors occur, it's close to the $y$-axis where the surface isn't very steep, whereas the vectors get longer and longer the more we move along the contour away from the $y$-axis. But the surface gets steeper and steeper as one moves away from the $y$-axis. In other words the slope increases!