
92 CHAPTER 3. VECTORS AND MATRICES
At the top of the hill, the gradient is zero. The Gradient command is used to
calculate grad h at an arbitrary point (x, y). Alternately, one can obtain the
same result by using Del to calculate ∇h.
>
G:=Gradient(h,[x,y]); #alternately, G:=Del(h,[x,y]);
G := (2 xe
(−0.5 x
2
−0.5 y
2
)
− 1.0(x
2
+ y
2
) xe
(−0.5 x
2
−0.5 y
2
)
+1.2(−2 x +5.8) e
(−(x−2.9)
2
−(y−2)
2
)
) e
x
+(2ye
(−0.5 x
2
−0.5 y
2
)
− 1.0(x
2
+ y
2
) ye
(−0.5 x
2
−0.5 y
2
)
+1.2(−2 y +4)e
(−(x−2.9)
2
−(y−2)
2
)
) e
y
Notice that overbars appear above the unit (basis) vectors in the output of
the gradient operation. This indicates that G is a vector field defined at all
points (x, y). It is Maple’s way of reminding you that for general curvilinear
coordinate systems, such as the spherical polar system, the directions of the
unit vectors will vary from point to point in space. Only Cartesian unit vectors
are independent of position.
Guided by the figure, a numerical search is made over the range x = 2 to 4
and y = 1 to 4, using the floating point solve command, to find the zeros of the
x and y components (G[1] and G[2])ofG. The solution sol is assigned,
>
sol:=fsolve({G[1],G[2]},{x,y},{x=2..4,y=1..4}); assign(sol):
sol := {y =1.980898405,x=2.872302687}
and the x and y coordinates of the peak of the hill are given by xmax and ymax.
The height of the hill, hmax, is obtained by evaluating h at xmax, ymax .
>
xmax:=x; ymax:=y; hmax:=eval(h,{x=xmax,y=ymax});
xmax := 2.872302687 ymax := 1.980898405 hmax := 1.226303365
The elevation of the hill’s peak is about 1226 m. x and y are now unassigned.
>
unassign(’x’,’y’):
Topographical maps used in hiking are 2-dimensional in nature. A 2-d contour
map with 25 contours is now made in cp with contourplot.Thegrid option is
set to 50 × 50, which generates 2500 equally spaced grid points for the contour
plot. The default is 25 × 25, which produces 625 grid points.
>
cp:=contourplot(h,x=-4..5,y=-4..5,contours=25,grid=[50,50],
filled=true):
The fieldplot command is used in fp to plot the gradient G, placing thick
magenta colored arrows at equally spaced grid points (here 15 × 15), each arrow
pointing in the direction of increasing gradient at the grid point. The size of the
arrow is a measure of the strength of the gradient, larger arrows corresponding
to steeper gradients.
>
fp:=fieldplot(G,x=-4..5,y=-4..5,arrows=THICK,grid=[15,15],
color=magenta):
The textplot command is used in tp to place the word “Top”, colored blue,
at the location xmax −0.3, ymax +0.1, adjacent to the top of the hill.
>
tp:=textplot([[xmax-0.3,ymax+0.1,"Top"]],color=blue):