Let's try to visualize the height of the ball, for given values of V and
, as a function of time. The standard way to do this is to plot the
independent variable (time, in this case) on the horizontal axis vs. the
dependent variable (height, in this case) on the vertical axis.
Producing such a two-dimensional graph in Maple is quite easy. To do this, you
must give Maple, at a minimum,
- a symbolic expression containing the independent variable as the only
unbound variable and
- the range over which the independent variable will vary.
For example, the Maple command
 | plot(height(50, Pi/4, t), t=0..10); |
will plot the height of a ball thrown with initial velocity 50 meters/sec at an
angle of 45 degrees as a function of time, as time ranges from 0 to 10 seconds.
Maple will do this by bringing up a separate window. When you are done with
the window you can dispose of it by pulling down its File menu and
choosing Exit.
The plot command will accept a number of optional arguments. Often, you
will want to specify the range of the y-axis as well as of the x-axis. For
example, perhaps we'd like to fix our graph so that the ball doesn't continue
through the ground:
 | plot(height(50, Pi/4, t), t=0..10, 0..100); |
We might also want to label the axes and give the graph a title:
 | plot(height(50, Pi/4, `time (secs)`),
`time (secs)`=0..10,
`height (meters)`=0..100,
title=`Height attained in ballistic trajectory`); |
If we are going to produce a number of such plots, it is handy to have a
function that takes the initial velocity and initial angle and then produces
the plot for us:
 | plotHeight := (velocity, theta) ->
plot(height(velocity, theta, `time (secs)`),
`time (secs)`=0..10,
`height (meters)`=0..100,
title=`Height attained in ballistic trajectory`); |
Now we can produce our plot with the simple command:
 | plotHeight(50, Pi/4); |
This is a good illustration of the power of user-defined functions.
Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah