Computer Lab: Gradient Fields




Introduction

The aim of this lab is to visualize some of the properties of the gradient, and to use them to interpret the behavior of a function of two variables.

Review of the Gradient

  1. Suppose $f\,(x,y)$ is a scalar-valued function of two variables, so $f$ MATH. The gradient of f is the vector of functions: MATH.

  2. The gradient of $f$ at the point $P=(a,b)$ is the vector: MATH

  3. $\nabla f\,(a,b)$ points in the direction, from $(a,b)$, in which the function $f$ increases most rapidly.

  4. $\nabla f\,(a,b)$ is perpendicular to the contour or level curve for $f $ through $(a,b)$.




Vector Fields and Gradient Fields

  1. A vector field $\QTR{bf}{V}$ is simply a way of assigning, to points $(x,y)$ in the plane, vectors $\QTR{bf}{V}(x,y)$. For example, the vector field MATH assigns the vector MATH to the point $(2,3)$.

  2. Given a function $f(x,y)$, its gradient MATH is a vector field. For example, suppose MATH. Then MATH (see immediately above), so $\nabla f$ assigns the vector MATH to the point $(2,3).$

  3. We can picture vector fields by selecting a grid of points in the plane and drawing the vector $\QTR{bf}{V}(P)$ at the point $P$. Here is a Maple session which draws a combination of a gradient plot and contour plot for the function MATH.

    > with(plots):

    > F:= x^2-2*x*y+3*y^2;

    > P1:=contourplot(F,x=0..4,y=0..4,contours=20, grid=[30,30]):

    > P2:= gradplot(F,x=0..4,y=0..4,arrows=SLIM, grid=[30,30]):

    > display(P1,P2);


    gradcontour.eps

    Note that the parameter grid = [30,30], in the contour plot, determines how finely the contours are plotted (if they come out rough, increase the numbers, but don't make them much bigger than 50). In the gradient plot, the grid determines how many arrows are plotted. Both of the plot commands end in a colon (":") so they don't display anything, but save their data in variables P1 and P2, which are plotted simultaneously in the display command.

  4. Combined gradient and contour plots can be helpful in classifying critical points (places where the gradient is zero). These are of three types:




Exercises to Hand In




  1. Draw a gradient/contour plot for the function MATH in the rectangle $-2\leq x\leq 2,\,$ $-2\leq y\leq 2$ (usually written as simply $-2\leq x,\,y\leq 2$). Use this to locate, approximately, the critical points. Classify them: max, min or saddle; explain how you know.

  2. Do the same as exercise 1, except use the rectangle MATH and the function:

    MATH.

  3. Do the same as exercise 1, except use the rectangle $0\leq x,y\leq \pi $ and the function: MATH .

  4. Do the same as exercise 1, except use the rectangle MATH and the function:

    MATH