Gradients

To plot the pattern that the gradient vectors of a function of two variables make on the coordinate plane we use the command  gradplot. Take for example the function  f(x,y) = 2x2-3y2.  Its gradient at a point  (x,y)  is the vector  (4x, -6y).  This vector depends on the point  (x,y).  Try the Maple command

> gradplot(2*x^2-3*y^2,x=-2..2,y=-3..3);

What you see is a picture of many arrows in the plane. Each of these arrows represents the gradient of  f(x,y)  in the following way: the base of the arrow is placed at the point  (x,y)  and the direction and length of the arrow is given by the gradient vector. This is done for many points  (x,y)  in the rectangle  [-2,2] x [-3,3]  but these arrows represent only some of the infinitely many values that the gradient takes in that region.

As usual, you may use various options in the gradient plot such as  scaling=constrained, thickness=2, color=red etc. The following sequence of commands displays both the contours and the gradient for a given function in the same plot.

> a:=contourplot(x^2+y^2,x=-2..2,y=-2..2,scaling=constrained):
> b:=gradplot(x^2+y^2,x=-2..2,y=-2..2,scaling=constrained):
> display(a,b);

To plot a 3-dimensional picture of the gradient of a function of three variables we use the Maple command  gradplot3d  with the same options as above.