Skip to main content

Section 10.5 Using Technology to Visualize the Gradient

The gradient of a function of three variables is a vector at each point in space. How can we graph such vector fields? How many different ways can you represent this information?

Activity 10.5.1. Using technology to visualize the gradient.

After you have thought about these questions yourself, you can use the Sage code below to explore several different mechanisms for visualizing the gradient in two and three dimensions. You can also use this Mathematica notebook 1  for the same purpose.

The code in the first box does some initialization, then defines and plots a function of two variables.

Now we can plot a contour diagram of the chosen function \(f\text{.}\)

Next we compute the gradient of \(f\text{...}\)

... and plot it.  2 

Finally, we display both plots together. What do you notice?

Now try other functions by plugging something else in for \(f(x,y)\) in the first box and then redoing the other steps. A particularly nice choice is \(f=e^{y^2-x^2}\text{.}\)

Hint.
Figure 10.5.1. The gradient in 2 dimensions.

In the activity in Section 10.5, you were asked to explore different ways of representing the gradient graphically. One combined representation is shown in Figure 10.5.1, showing both the gradient vector field and the level curves.

math.oregonstate.edu/bridge/paradigms/vfgradient.nb
You may need to adjust the value of the scale option in this plot, which controls the overall scale of the vectors drawn.