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> is meant to give 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 will keep as much of your
t> system's memory free as possible.
b>
c1>
t> Two-Dimensional Plots
b>
t> Expressions in one unknown can be 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 allows you to specify that more sample points be
t> taken, which gives a smoother curve. (The default value is 49.) You can
t> specify what color the plot should be drawn in with the color option.
t> The axes option allows you to specify what type of axes(FRAME, BOXED,
t> NORMAL, or NONE) are used. With the xtickmarks and ytickmarks options,
t> you can control the number of marks that Maple uses along each axis.
t> The style option allows you to choose between different styles of
t> interpolation between sampled points (e.g., LINE, POINT). A title can
t> be added to the plot with the title option.
b>
t> The following are two plots that show 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);
c1>
t> Three-Dimensional Plots
b>
t> Expressions in two unknowns can be 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 allows you to specify the rectangular grid size for the
t> sample points. (The default value is 25 by 25.) You can specify the
t> style with which the surface will be rendered (e.g., PATCH, WIREFRAME,
t> POINT) with the style option. Different coloring schemes can be
t> specified with the color and shading options. Either ambient or
t> directional lights can be applied to the surface with the ambientlight
t> and light options, respectively. The orientation option lets you
t> specify from which point in space you are to view the surface.
t> Labelling of the plot can be handled with the title, labels, and
t> tickmarks options.
b>
t> The following are two plots that show 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, color=WHITE, style=PATCH, light=[45,45,0,1,0.4]);
c1>
t> Animation
b>
t> Maple can also perform basic animation. Two- and three-dimensional
t> animation can be performed 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. You give this variable a
t> range of its own (specified as the last range), and a number of frames
t> is also specified.  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 will appear in its own window, complete with motion
t> controls 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> will not work on such terminals and will cause 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>
x> animate3d((1.3)^x * sin(u*y), x=-1..2*Pi, y=0..Pi, u=1..8, coords=spherical);
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>
