Plotting with Maple V

Some basics

Here are a few things that may be helpful when plotting using Maple. The first is that constants and equations can be assigned to variables.

Example

a:=1997;

b:=cos(x);

The first line assigns the value 1997 to a. The second line assigns the function cos(x) to b. Knowing this will help a great deal when plotting with Maple. This will allow you to define a function once and then easily try different ways to plot it. If this was not available you would have to reenter the function every time you wanted to plot it. For long and complicated functions this could become annoying very quickly.

An important point to notice is that commands in Maple end with a semicolon. This tells Maple that the command has ended and to perform the processes that were called upon. If you do not end a command with a semicolon and push enter you will see this:

>
>
>

This does not mean you have to reenter the command. Simply type a single semicolon and push enter. Maple will complete the command that you had intended to run.

plot

Plotting in Maple is similar to plotting in Mathematica. In Maple the function used for two dimensional plotting is called plot and receives a minimum of two arguments, similar to Plot in Mathematica.

The first argument is a description of the function to be plotted. The second argument defines the range of the variable in the function. Below is an example that was used with Mathematica. It plots the cosine function from -2Pi to 2Pi.Pi is a constant that is built into Maple, it does not have to be define by you.

Example:

>plot(cos(x), x=-2*Pi..2*Pi);

If we use the definition of b from the top of the page, b:=cos(x);, this line could be rewritten and enter as it is shown below.

>plot(b, x=-2*Pi..2*Pi);

Maple can also plot multiple functions at the same time. This is done by enclosing the functions to be plotted within brackets. In the example below, the cosine and sine curves are plotted within the range -2pi to 2pi.

Example:

>plot({cos(x), sin(x)}, x=-2*Pi..2*Pi);

Just as multiple functions can be plotted, multiple attributes can be given to the range argument. A range can be applied to the dependent variable as well as the independent variable. Below is an example that uses this technique.

Example:

>plot(sin(x)/x^2, x=-1..1,-5..5);

This particular function has an asymptote at x=0. The second part of the range though scales the y-axis from -5 to 5. This allows the function to be plotted without being scaled pout of existence.

plot3d

The principal method for three dimensional plotting in Maple is plot3d. There are other types of methods but they will not be explained here. For those that are interested though, at the bottom of this page are references to some good books concerning Maple.

plot3d is called in a simialr way as plot except that one more argument is added to define the range of the second variable.

Example:

>plot3d(sin(x)+cos(y), x=0..4*Pi, y=0..4*Pi);

The above example describes a surface using the equation sin(x)+cos(y) with the x-axis and y-axis having a range of 0 to 4pi. This example could also have been entered as shown below with the equation saved in a variable.

Example:


> b:=sin(x)+cos(y);       

                              b := sin(x) + cos(y)

> plot3d(b, x=0..4*Pi, y=0..4*Pi);

References

[Rob96] Engineering Mathematics with Maple
John S. Robertson
McGraw-Hill, New York NY (1996).

[NW96] Maple: A Comprehensive Introduction
Roy Nicolaides and Noel Walkington
Cambridge University Press, New York NY (1996).

Week 1 Precept

Assignments

Last Modified: 97.08.13 Michael Carreno <mcarreno@cs.princeton.edu>