> restart;
More On Graphing In Maple
Introduction
In the preceding worksheets, we have introduced the basics of Maple in particular and given some commentary about computer algebra systems in general. We have already seen that such systems are a tremendous resource when it comes to symbolic manipulation, calculations, and graphing, among other uses. The purpose of this worksheet is to supply more information and practice about the specific use of Maple in producing graphs. Naturally, it is impossible to cover every possible capability and detail in a single worksheet, and so the reader is strongly encouraged to explore more on his or her own. As noted previously, the "Help" menu in Maple is remarkably useful, and it should be consulted frequently as questions arise and as more examples are needed.
In the preceding worksheet, we introduced the creation of graphs from functions or expressions. To recap briefly, we can define a function in Maple and then obtain its graph over any desired interval. For example, to study the function
h
defined by the formula
h
(
x
) =
on the interval from 0.1 to 0.9, we can proceed as follows.
> h:=x->(1/x)+(2/(1-x));
> plot(h,0.1..0.9);
>
Recall also that you can choose the vertical range of the graph in your command if you so desire. We will return to this interesting function in a moment to discuss what may happen as we vary the domain of its graph.
Similarly, expressions in Maple can be used, as can explicit formulas, with slight variations in the plotting command due to the syntax involved. Please refer to the preceding worksheets for more on the distinction between functions and expressions. We illustrate this here with a quadratic expression we call j , and we also remind the reader that two or more graphs can be displayed simultaneously, with a variety of options available, by graphing j along with a certain straight line.
> j:=1+t+t^2;
> plot(j,t=-3..2);
> plot([j,0.345*t+3.782],t=-3..2,color=[green,orange]);
While commands such as the preceding one can be daunting at first look, remember that the "Help" menu is full of examples and that incorrect commands will prompt informative error messages which will help you in adjusting your commands.
Rational Functions and Related Topics
The function we denoted above by h is a so-called rational function, a function which can be written as a quotient of polynomials. As you know, such a formula will be undefined at any point where its denominator takes the value zero. When the variable is very near such a value, the function may take a value which is very large in size. (Why?) We should take a look at how Maple reacts to a command to graph such a function over an interval which includes one or more such numbers outside of its implied domain. For instance, let's look at our function from above on an interval which includes both zero and one. We'll do it once with Maple choosing the displayed range and once with us specifying it.
> plot(h,-1..1.5);
> plot(h,-1..1.5,-20..20);
>
Some strange things seem to be happening. When the input variable is near zero or near one, the values of the function become very large in size indeed. In the first graph, Maple has chosen such a large range that the picture of the graph anywhere away from those special points is essentially invisible to us. In the second graph, that problem has been suppressed somewhat by our choice of a more reasonable range. But in both graphs, a crucial and potentially misleading occurrence has arisen. Both graphs appear to have a vertical line at the value one "in" the domain. (Another would appear at the value zero, but the vertical axis is hiding it.) We know, though, that one and zero are not in the domain, and we also know that no function can have a vertical segment in its graph.
So what do we do? The short answer is to use a combination of the graphing utility of Maple and some common sense. The graph of this function should be undefined at zero and at one, and in fact should have vertical asymptotes at those values. So when you read this graph, or when you print it for presentation, you should simply interpret these special values correctly and alter the picture to indicate the presence of asymptotes. In Maple and in all computer algebra systems, graphing software is never completely "perfect", and we need to use them in conjunction with our usual mathematical reasoning.
The slightly longer answer to what is happening here involves how the program produces a graph, and we'll barely outline it here. Maple creates a graph by listing for itself many points within the interval we specify, evaluating the function at those points and plotting the corresponding ordered pairs, and then "connecting the dots". If, say, it plots the pairs (0.99, h (0.99)), (1.01, h (1.01)) and connects them, it is drawing a nearly vertical line segment from one very high point to one very low point. This appears on the graph as a line segment which we cannot reconcile with what we know, and which passes right across the forbidden domain value of one. Maple does have options within plotting commands for dealing with discontinuous functions and other awkward situations; we choose not to go into extreme detail here. For more details on this and related topics, see both your instructors and the "Help" menu.
More On Different Types Of Graphs
Inequalities, implicitly defined plots, parametric plots, polar coordinates
For more complicated graphing work, it is usually appropriate to begin with the next command we show. We choose to execute it with a semicolon here; recall that if you want the command executed but no display presented, use a colon instead.
> with(plots);
>
Once this command is executed, Maple accesses its extensive library of plotting routines. The ones we have used previously are available whenever Maple is opened. To plot inequalities, use polar coordinates, explore parametrically-defined curves, and look at three-dimensional plots, the
"
with(plots)
" command is needed in advance.
Maple will graph linear inequalities or systems thereof. Extensive details, including coloring options, are found in the "Help" menu. Two examples will suffice here, both involving the system of two inequalities {
}. In the first, we allow the software to use its default plotting options, which include appropriate solid or dotted lines as you are accustomed to, but do not show which inequality gives rise to which portion of the graph.. In the second, we choose some colors and show more detail. "Feasible" refers to the
solution set
, "open" refers to the borders of
strict
inequalities, "closed" refers to the borders of
non-strict
inequalities, and "excluded" refers to the area
not
in the solution set.
> inequal( { x+y>0, x-y<=1 }, x=-3..4, y=-2..3);
>
inequal( { x+y>0, x-y<=1 }, x=-3..4, y=-2..3,
optionsfeasible=(color=red),
optionsopen=(color=blue,thickness=2),
optionsclosed=(color=green, thickness=5),
optionsexcluded=(color=yellow) );
>
We often wish to view graphs which are not necessarily produced by functions. Circles and ellipses, inverse relations, and other relations arise from equations which are most easily handled in what is called
implicit
form: that is, of the form
for some function F of two variables. For example, if we wish to view the curve defined by the equation
(which can be rewritten as
), we use an appropriate command for implicit plotting.
> implicitplot(x^2+2.5*y^2=14,x=-6..6,y=-6..6);
>
Notice that since the graph has no points near the edges of the specified x and y intervals, the software has defaulted to give us as large a picture as possible by deleting some"empty" space in the plot.
As usual, we can view a small portion of the graph, adjust preferences for color, and so forth.
> implicitplot(x^2+2.5*y^2=14,x=2.5..3.5,y=-6..6,color=orange,thickness=5);
>
You may have encountered situations in applied problems in which a coordinate point ( x , y )
moves as time
t
(or some other variable) changes. In this case, we may be interested in the set of points in the plane traced out by the pair (
x
(
t
),
y
(
t
)) as
t
varies over some interval of interest. For instance, if an object is following the path
as
t
varies from 0 to 4, it traces the path shown below.
> plot([1/(t+1),t^2-t,t=0..2],color=blue,thickness=4);
>
As usual, a variety of options are available with parametric plots. The "Help" menu will illustrate most. One particular option has the software interpret the input expressions as
r
and
of polar coordinates (in that order!) rather than rectangular coordinates. For instance, an example of the remarkable Sprial of Archimedes, of the form
for some constant
k
, can be drawn as simply as follows. We plot (
) for some parameter
s
, and it is simplest to let
s
and
simply have the same meaning. That is, we can call our expressions "
" and "
" rather than introducing yet another named variable. Many users routinely call their parameter "theta" in polar plots, and if the relation to be graphed has the simple form
r
= function of
, this will cause no problems. (The constant
k
is taken to equal 0.1 in this example.)
> plot([0.1*theta,theta,theta=0..6*Pi],coords=polar,color=gold,thickness=3);
>
For other ways to approach problems involving graphs in polar coordinates, consult your instructor and the "Help" menu regarding the "polarplot" commands.
Other Notes On Graphing
We have barely scratched the surface of the topic of graphing using Maple. You can find many, many more ways to use the system. For example, Maple will plot points, connect them if you wish, find the straight line or specified type of curve which best fits a collection of plotted points, and so on. As higher-level topics in mathematics are addressed, graphical interpretations exist for a wide variety of concepts, and computer algebra systems will handle them as you encounter them. We leave you here with one more example, one which is designed to whet your appetite for more.
Just as two coodinates can be related in some way, so can three (or more). A relationship among variables x , y , and z can be interpreted as a surface or region in three-dimensional space. This has long been a difficult topic, often left to a third or fourth semester of calculus, primarily because it is so extraordinarily difficult for a person to visualize and draw three-dimensional objects on a two-dimensional paper, blackboard, or screen. With a system like Maple, we can let the software do the onerous task of creating a realistic three-dimensional "object"; we can then tinker with it almost as though it were a solid object in our hands.
For example, the set of all points in three-space at an equal distance from a given central point would be a sphere, and as a consequence of the distance formula, its equation is
if we take the central point to be (0, 0, 0) and call the radius
r
. If we let the radius be 3 units and wish to view only the "northern" hemisphere, where
z
is nonnegative, we have the following.
> implicitplot3d(x^2+y^2+z^2=9,x=-4..4,y=-4..4,z=0..4,axes=boxed);
>
Here's the stunner: click on the plot and then slowly move the cursor. The plot will rotate in three dimensions, so you can see it from any angle you wish. At the top of the screen are the measurements of two angles which describe your viewing location, and you may use them directly to rotate the graph as well. As you might expect, there are also many options available regarding the colors and shading of the graph, the resolution of the plot, whether to have axes present, and so forth.
You'll see much more on three-dimensional graphs in your future mathematics courses. Consult your instructor for more information if you want to start in on them now.
Homework Problems
Complete these problems in the form of a Maple worksheet with thorough explanatory text.
1. (The purpose of this problem is to emphasize the fact that a computer algebra system can be used in many different ways in problem-solving.) For a certain product, selling at a price of
x
dollars per item, the following information is discovered. Consumer demand, in thousands of items demanded by the public, is given by
for
x
between 0 and 20, and manufacturer supply, in thousands of items supplied, is given by
for
x
between 5 and 30.
(a) Graph D and S on the same set of axes. By choosing your viewing area, find an approximation to a value of x where S = D (accurate to one decimal place). Then give an interpretation of the real-world meaning of both coordinates of the corresponding point on the graphs.
(b) Instead of using graphical means, use the algebraic capabilities of Maple to find a value of x which makes S and D equal. (You may wish to refer to a previous worksheet.) How does this value compare with your approximation in part (a)?
(c) The excess of demand over supply is given by E = D - S. Graph E for x between 5 and 20, and explain what it means for the value of E to be positive, negative, or zero. Use Maple to solve E = 0 and comment on whether your answer is related to parts (a) and (b) above.
2. Let a function h be defined by the following formula:
.
(a) Use Maple to factor the numerator and denominator, and comment on vertical asymptotes and x -intercepts which you expect to find on the graph of h.
(b) Plot the graph of h, choosing domain and range so that the behavior of the function can be seen clearly.
(c) Correct the plot as necessary to reconcile it with the information you learned in part (a).
3a. Plot the set of points (
x
,
y
) for which
. Try to get some views which suggest the shape of both the overall large plot and some interesting smaller portions of it.
3b. The graph of the cube root function can be described in more than one way. We could view it as the set of points for which
, or we could say that it is the set of points for which
. Use each of these approaches to construct graphs in which you specify that x is in the interval from -5 to 5. Are the graphs identical? If they are not, discuss and/or investigate what has transpired. What important points about the use of mathematical software are illustrated here?
4. If the units on the coordinate axes represent meters, tell approximately how many square meters are contained in the solution set of this system of inequalities:
,
,
.
5. A point moves in the plane as follows. It starts on the
x
-axis and moves counterclockwise with constant angular velocity of one radian per second, so that its angular coodinate is simply
, where
t
is time, in seconds, since it began to move. Its distance from the origin at time
t
is
centimeters.
(a) Plot its motion for its first 20 seconds of travel.
(b) Describe its motion as a much longer time interval passes. What is the point eventually doing?