Application Center - Maplesoft

App Preview:

Calculus III: Complete Set of Lessons

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

An introduction to plotting with Maple 

Worksheet by Mike May, S.J.- maymk@slu.edu 

Introduction 

> restart;
 

In previous courses you have been using a graphing calculator to graph functions of one variable.  Having a convenient grapher makes the concepts of calculus easier to understand.   

 

However, most of Calculus III deals with functions of several variables and our calculators are not very good at graphing surfaces.  The point of this worksheet is to give  an introduction to graphing with Maple.  This should make it easy for you to produce the relevant pictures for this course. 

 

An introduction with functions of one variable: 

A Simple Plot 

Since functions of one variable are more familiar, we start with them.   

The syntax for plotting a function of one variable is 

    plot("function of x", x="low value of x".."high value of x"); 

where the expressions in quotation marks are to be replaced by appropriate values.   

Hit enter to execute the command below. 

> plot(sin(x), x=-Pi..Pi);
 

Plot
 

Things to notice: 

  • The "function of x" is not an equation.  It is what we would set y equal to if we were writing an equation.
 

  • We specified the x-range we wanted, and Maple decided on an appropriate y-range.  We will learn how to specify the y-range a little later.
 

  • Click once on the graph.  The graph should now be enclosed in a box.  Dragging the corners of the box will let you resize the graph.  The second row of icons above has also been replaced be a new row.  The new row has buttons that control the style of the graph.  From left to right you should see a box with the coordinates of the point you clicked on, a drop down menu of icons concerned with the style of the graph, a drop down menu of icons  concerned with the style of the coordinate axes, a "1:1" button that looks at whether the x and y axes need to have the same scale, a drop down menu of icons  concerned with the action for clicking and dragging, and a button for whether or not to show the grid for the graph.
 

 

Exercises 

1)  Plot the graph of  y = cos(2*x) with Typesetting:-mrow(Typesetting:-mo(.  

Stretch the graph to cover the screen. 

>
 

2)  Replot the graph above, but modify the style so that it is done with dots rather than with connected lines, and so the axes are on the sides of the graph rather than in the middle of them. 

>
 

3)  Replot the graph above, but modify the style so that it is a connected curve, with no axes, and the same scale for the x and y axes. 

>
 

Specifying the y-range 

We would like to be able to specify the y-range of a plot. 

If a plot has a vertical asymptote, Maple will give such a large y-range that we miss details we are interested in.  The solution is to specify the y-range.  Specifying the y-range is done using the same conventions used to specify the x-range. The command 

    plot("function of x", x="low value of x".."high value of x"); 

becomes 

    plot("function of x", x="low value of x".."high value of x", y="low value of y".."high value of y"); 

For an example, execute the plotting commands given below. 

> plot(cos(x)/x, x = -10 .. 12); 1
 

Plot
 

> plot(cos(x)/x, x = -10 .. 12, y = -2 .. 2); 1
 

Plot
 

The second graph is much more informative than the first about the behavior of this function. 

 

It is worthwhile at this point to note where we have been using imprecise language.  By "x-range" we mean "the range of the independent variable", while "y-range" is "the range of the dependent variable".  Equivalently, x-range and y-range respectively stand for the ranges of the input and output variables.  The examples below show what happens when we change the names of the variables. 

 

> plot(cos(x)/x, x = -10 .. 12, z = -2 .. 2); 1
 

Plot
 

> plot(cos(y)/y, y = -10 .. 12, x = -2 .. 2); 1
 

Plot
 

> plot(cos(x)/x, y = -10 .. 12, x = -2 .. 2); 1
 

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct 

Plot
 

 

Notice that we can use any letter for input and output, but the input range is specified before the output range or we get an error.  With the error it is worth pointing out where maple hides some stuff.  Put the cursor in the line containing the last plot command and select "Expand Document Block" from the View menu. 

Plotting several functions on the same graph 

It is also useful to be able to see the graphs of several functions on the same graph.  In Calculus I and II we were interested in seeing the graph of a function and its derivative at the same time.  We also wanted to compare a function with the polynomial approximations we obtained for it. 

 

To plot several functions at the same time, the command 

    plot("function of x", x="low value of x".."high value of x"); 

becomes 

    plot({"function1 of x", "function2 of x", "etc."}, x="low value of x".."high value of x"); 

Note that the set of functions is enclosed in braces. 

For an example, consider the following commands which plot cos(x) along with some of the Taylor polynomial approximations of cos(x). 

 

> plot({1, 1-1/2*x^2+1/24*x^4, cos(x), 1-1/2*x^2}, x = -3 .. 5); 1
 

Plot
 

> plot({1, 1-1/2*x^2+1/24*x^4, cos(x), 1-1/2*x^2}, x = -3 .. 5, y = -1.5 .. 1.5); 1
 

Plot
 

 

Plot
 

 

Plot
 

 

More Exercises 

4)  Produce a nice plot of the graph of y = tan(x) with x between 0 and 10.  You will need to specify the y-range. 

>
 

 

5) Plot Typesetting:-mrow(Typesetting:-mi( with Typesetting:-mrow(Typesetting:-mo(,  along with the lines tangent to that graph when x = -1.5,  -.5,  .5, and 1.5.  Crop the graph to show the region where y is between -2 and 4. 

>
 

 

As was noted earlier, you can graph a function of one variable on a graphing calculator.  Often, a calculator will be the easier way to deal with such graphs.  There are two reasons to look at them with Maple when your calculator is already at hand: 

  • It gives an introduction to graphing with Maple using familiar material.  (This is the reason we include it here.)
 

  • Maple graphs can easily be printed out if you want to write on them or turn them in.
 

Plotting with functions of two variables: 

Basic Plotting 

The syntax for plotting the graph of a function in 2 variables is similar to the one variable case.  We use the command: 

    plot3d("function of x and y", x="low x".."high x", y="lowy".."high y"); 

as we see with the following command. 

 

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

Once again, if you click once on the graph, it will be enclosed in a box, and a set of buttons will appear up on the menu bar.  There are 2 boxes labeled theta and phi with scroll arrows for specifying the viewing angle, a drop down list of 7 buttons for style used on the graph itself, a drop down list of 4 buttons for style used on the axes, a "1:1" button to use the same scale on all 3 axes, and a drop down list of 3 possible actions of dragging on the graph. 

 

The default has a wire frame model, that is opaque (the front bump hides the back bump), the axes are not printed, from a viewing angle of 45 degrees on both angles. 

 

Exercise 

6)  Redraw the graph given above.  Then use the buttons to produce an image that: 

    A) Shades the image, draws a grid of lines on the image, and boxes the axes around the image; 

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

B) Shades the image and draws contour lines on it, while putting the axes in standard position through the origin;  

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

C) Uses a wire frame model with contour lines, and suppresses the axes. 

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

 

Viewing angles and contour plots 

The list of controls for changing the appearance of a graph includes controls for theta and phi, the coordinates of the position in spherical coordinates that the graph is viewed from.  The angle phi is the angle to the positive z-axes.  Thus an angle of  Typesetting:-mrow(Typesetting:-mi(   

looks down on the x-y plane from above, Typesetting:-mrow(Typesetting:-mi( 

gives a viewpoint looking down the x-y plane, while Typesetting:-mrow(Typesetting:-mi( looks up from below.  The angle theta measures the rotation of the x-y plane.  If  Typesetting:-mrow(Typesetting:-mi( so we are looking down the z-axis, then θ=0 has the y- axis horizontal increasing from left to right and the x-axis vertical decreasing as you go up.  The default setting has theta and phi both set to 45. 

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

Exercises: 

7)  Redraw the graph above.  Adjust the viewing angle so that theta = 60 and phi = 30.  Use a wireframe model that is opaque, and have the axes on the outside of the graph. 

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

8)  Find the angle settings that look down the z axis and put the x-y plane in standard position for the plane.  (Standard position has the x-axis horizontal and increasing to the right.  The y- axis is vertical and increasing as you rise.) 

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

The correct settings are..... 

9)  View the graph above as a contour map with the x-y plane in standard position. 

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

This contour map view can be obtained more directly with the plots[contourmap] command, using 

  plots[contourplot]("func(x,y)", x="low x".."hi x", y="low y".."hi y");
The plots[contourplot] command has the option of letting you specify which contours will be drawn with a
 

contours=["list of values" option.  Thus to get the map above with contours corresponding to the values of -2/3, 0, 1/4, and 5/4 we use the command: 

  plots[contourplot](sin(x) + sin(y), x=-3..5, y= -Pi..2*Pi, contours= [-2/3, 0, 1/4, 5/4]); 

 

10)  Redraw the contour plot you found in the last exercise, using the plot options rather than adjusting the controls and redrawing. 

> plot3d(sin(x)+sin(y), x = -3 .. 5, y = -Pi .. 2*Pi); 1
 

Plot
 

Multiple graphs and controlling the z-range 

The syntax for doing more than one graph on the same plot is similar to the one variable case.  We simply replace the function with a set of functions. 

> plot3d({x^2+y^2-5, sin(x)+sin(y)}, x = -3 .. 5, y = -Pi .. Pi); 1
 

Plot
 

The control of the z-range is done with a  

      view = "low value of z".."high value of z" 

clause inserted into the plot3d command. 

> plot3d({x^2+y^2-5, sin(x)+sin(y)}, x = -3 .. 5, y = -Pi .. Pi, view = -3 .. 3); 1
 

Plot
 

Exercises: 

11)  Plot the functions  

z = x^2+2*y^2 

z = x^2+2*y^2 (3.6.1)
 

and  z = 2*(x-1)+4*(y-1)+3  on the same axes.  Plot over the rectangle with x and y between -1 and 3. 

>
 

12)  Regraph the same pair of functions, this time constraining the z-range between -1 and 7. 

>
 

These 2 surfaces have a simple relationship.  Describe the relationship and replot the graph viewed at an angle to make the relationship clear visually. 

>
 

The relationship is....... 

The viewing angle that makes this obvious is ...... 

 


Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.
 

Image