t> PLOTTING WITH MAPLE
b>
t> One of the most interesting and useful features of computer algebra is
t> scientific visualization. Displaying expressions of one or two unknowns
t> pictorially extends our understanding of their nature and
t> significance.  Maple provides a large range of plotting commands that
t> accommodate most of your scientific visualization needs. This chapter
t> gives you a solid background in how to use these commands.
b>
t> The basic concept to plotting is to provide an expression in one or two
t> unknowns, and also provide desired ranges for *each* unknown to be
t> evaluated over. Maple then samples a meaningful set (or grid) of points
t> and displays the results for you.
b> 
c1>
t> Of course, the quality with which these images appear on your screen
t> are directly proportionate to the graphics capabilities of your
t> monitor. When Maple is installed, the device type for your monitor
t> should be set for you, making the transition to plotting as seamless as
t> possible. If you have any problems viewing the plots in this chapter,
t> please make sure that your terminal is properly configured in your
t> Maple session.
b>
t> If you are working with a terminal that brings up a separate window for
t> each Maple plot, please make sure that you close these plots windows as
t> soon as you are finished viewing them. This keeps as much of your
t> system's memory free as possible.
b>
c1>
t> Two-Dimensional Plots
b>
t> Expressions in one unknown are plotted using the plot command. There
t> are several types of two-dimensional plots available. Here are a few of
t> the more popular ones.
b>
c1>
t> Expressions can be plotted:
b>
h> with(plots):
x> plot(x^2-3, x=-4..4);
c1>
x> plot(x*sin(x), x=-3*Pi..3*Pi);
c1>
t> Parametric expressions can be plotted as well:
b>
x> plot([sin(t),cos(t),t=0..2*Pi]);
c1>
t> Lists of x and y values can be joined by lines:
b>
x> plot([3,3,6,0,3,-3,0,0,3,3], x=-2..10);
c1>
t> Multiple plots can be specified for one set of axes:
b>
x> plot({x^2, exp(x), x}, x=0..3);
c1>
x> plot({seq(cos(x*i),i=1..4)}, x=-Pi..Pi);
c1>
t> Besides these standard plots, there are several other types of
t> two-dimensional plots available in the plots package. Let's try out a
t> few of these commands.
b>
c1>
t> Polar plots can be specified:
b>
x> plots[polarplot](2*t);
c1>
t> Two-dimensional vector fields can be plotted:
b>
x> plots[fieldplot]([sin(y),cos(x)], x=-10..10, y=-10..10, arrows=SLIM);
c1>
t> And implicit functions can be plotted in two dimensions:
b>
x> plots[implicitplot](x^2/25+y^2/9=1, x=-6..6, y=-6..6, scaling=CONSTRAINED);
c1>
t> There are several additional options available for two-dimensional
t> plots.
b>
t> The numpoints option specifies that more sample points be taken, 
t> which gives a smoother curve. (The default value is 49.) Specify
t> what color the plot is drawn in with the color option. The thickness 
t> option specifies the thickness of the curves drawn. The symbols 
t> option specifies how a point is drawn (one of BOX, CROSS, CIRCLE, 
t> POINT, or DIAMOND). The axes option specifies what type of axes
t> (FRAME, BOXED, NORMAL, or NONE) are used. With the xtickmarks and
t> ytickmarks options, you control the number of marks that Maple uses along
t> each axis. The style option chooses between different styles of
t> interpolation between sampled points (e.g., LINE, POINT). A title
t> is added to the plot with the title option.
b>
t> The following are two plots showing some of these options in use:
b>
c1> 
x> plot([sin(2*x),cos(x),x=0..2*Pi], color=BLUE, title=`my blue plot`);
c1>
x> plot(x^3+2*x^2-3*x-1, x=-3..3, axes=FRAME, style=POINT, symbol=CROSS);
c1>
t> Three-Dimensional Plots
b>
t> Expressions in two unknowns are plotted using the plot3d command.
t> There are several types of three-dimensional plots available. Here are
t> a few of the more popular ones.
b>
c1>
t> Expressions can be plotted:
b>
x> plot3d((x^2-y^2)/(x^2+y^2), x=-2..2, y=-2..2);
c1>
x> plot3d(exp(x+y), x=-0..2, y=0..2);
c1>
t> Parametric expressions can be plotted as well:
b>
x> plot3d([x*sin(x),x*cos(y),x*sin(y)], x=0..2*Pi, y=0..Pi);
c1>
t> Multiple plots can be specified for one set of axes:
b>
x> plot3d({x+y^2, -x-y^2}, x=0..3, y=0..3);
c1>
t> Besides these standard plots, there are several other types of
t> three-dimensional plots available in the plots package. Let's try out a
t> few of these commands.
b>
c1>
t> Plots can be specified in spherical coordinates:
b>
x> plots[sphereplot]((1.3)^z * sin(theta), z=-1..2*Pi, theta=0..Pi);
c1> 
t> Curves can be drawn in three-dimensional space:
b>
x> plots[spacecurve]([t*cos(t),t*sin(t),t], t=0..7*Pi);
c1>
t> And implicit functions can be plotted in three dimensions:
b>
x> implicitplot3d(z^2=x*exp(-x^2-y^2), x=-2..2, y=-2..2, z=0..40);
c1>
t> There are several additional options available for three-dimensional
t> plots.
b>
t> The grid option specifies the rectangular grid size for the sample points. 
t> (The default value is 25 by 25.) Specify the style with which the
t> surface is rendered (e.g., PATCH, WIREFRAME, POINT, CONTOUR) with the style 
t> option. The number of contours used in a contour plot is specified with 
t> the contours option. The thickness option specifies the thickness of the 
t> curves drawn. The symbols option specifies how a point is drawn (one of BOX, 
t> CROSS, CIRCLE, POINT, or DIAMOND). Different coloring schemes are specified 
t> with the color and shading options. Either ambient or directional lights are
t> applied to a surface with the ambientlight and light options, respectively. 
t> The orientation option specifies from which point in space you view 
t> the surface. Labelling of the plot are handled with the title, labels, 
t> and tickmarks options.
b>
t> The following are two plots showing some of these options in use:
b>
c1> 
x> plot3d((x^2-y^2)/(x^2+y^2), x=-2..2, y=-2..2, shading=XYZ, title=`saddle`);
c1>
x> plot3d(sin(x*y), x=-2..2, y=-2..2, shading=NONE, style=PATCH, light=[45,45,0,1,0.4]);
c1>
t> Animation
b>
t> Maple also performs basic animation. Two- and three-dimensional
t> animations are created with the commands animate and animate3d from
t> the plots package.
b>
t> To have animation, there must be an extra unknown in the expression
t> being animated - the variable of animation. Give this variable a
t> range of its own (specified as the last range), and also specify a 
t> number of frames. Other than these two things, the calls to animate
t> and animate3d are very similar to the ones for plot and plot3d,
t> respectively.
b>
t> Each animation appears in its own window, complete with motion controls
t> much like those found on a VCR.
b>
c1>
t> If you are running this tutorial on a text terminal (i.e., one that
t> cannot display graphics), then please do not continue further in this
t> chapter - just enter x for exit at the next available prompt. Animation
t> does not work on such terminals and causes the tutorial program to
t> terminate abruptly.
b>
t> If you do have the proper graphics terminal, please try the following
t> four animation examples.
b>
c1>
t> Two-Dimensional Animation
b>
x> animate(sin(x*t),x=-10..10, t=1..2, frames=25);
c1>
x> animate([u*sin(t),u*cos(t),t=-Pi..Pi], u=1..8);
c1>
t> Three-Dimensional Animation
b>
x> animate3d(cos(t*x)*sin(t*y), x=-Pi..Pi, y=-Pi..Pi, t=1..2);
c1>
t> Questions
b>
c2>
q> Using the $ operator, plot the planes x+y-1=0, x+y-2=0, x+y-3=0, and x+y-4=0
q> on the same set of three-dimensional axes (where x=-2..2, y=-2..2).
h> i := 'i';
a> plot3d({x+y-i$i=1..4}, x=-2..2, y=-2..2);
c2>
q> Animate, in two-dimensions, the behavior of the expression t^2*sin(s*t),
q> where t ranges from 0 to 2*Pi, as s (the variable of animation) varies 
q> from 1 to 10. (Use 10 frames.)
a> plots[animate](t^2*sin(s*t), t=0..2*Pi, s=0..10, frames=10);
eoq>
eof>
