Mathematics 131, Section 1 -- Calculus for Physical and Life Sciences 1
Lab 1: Getting Started with Maple, Plotting Functions
September 5, 2007
Goals
Today, we will begin using a program called Maple to draw graphs
of functions of one variable (given by symbolic formulas). You will be
using the commands covered here for most of the other lab days this semester.
On the mathematical side, we will also explore some properties
of polynomial and exponential functions.
Lab Activity 1
Let's get right down to work and walk through a sample graphing session!
First, you will need to get into Windows and Maple as described in the
General Information on Maple handout. The basic Maple command for 2D plotting
graphs of the form y = f(x) is called plot. The basic format is
plot(function,range,options);
where
- function is the function to be plotted -- the simplest way to
specify one is via a formula (an expression in Maple)
- range is the range of x-values you want to see plotted, and
- options can be used to control the form of the plot if desired.
No options need be specified, however, so that part can
be absent. More on possible options later.
The above plot command is a template. To do an actual plot, you
will need to fill in the expression and range of x values
for the plot you want and add the appropriate options.
For example, suppose we wanted to plot y = x4 - x3
+ 2x - 5 sin(x2) for x between 1 and 3. We could use the Maple
plot command with no options:
plot(x^4-x^3+2*x-5*sin(x^2),x=1..3);
(Note: The close parenthesis comes directly after the range of x-values
if there are no options.) Type in this command line (exactly as here) and
press ENTER. If you make a typing mistake, Maple will let you know about
it(!) Fortunately, if this happens, the whole command does NOT need to
be re-entered. Just move the cursor arrow to the place on the input line
you want to change, press the left mouse button, and edit the input as
needed. Typing from the keyboard will insert new stuff at the cursor
location; the DELETE and BACKSPACE keys will remove stuff (DELETE removes
the character in front of the "insert point"; BACKSPACE removes
the character in back). You can also move around on the input line with
the arrow keys if more than one thing needs to be changed. When you think
it's OK, press ENTER again to have Maple execute the command again.
When all goes well you will see the graphics output displayed under
the input command in the worksheet.
From the formula, you might guess that there is at least one other
x-intercept
for this graph (why?). To see more of the graph
as well, edit your previous command line to change
the interval of x values (do not retype the whole command).
Press ENTER on that input line to have Maple execute the command again.
Experiment until you are sure that your plot shows all the x-intercepts of this graph. (You
can repeat this process of editing a command and re-running it as often
as you want; the previous output is replaced by the new output each time.)
You can also manipulate the graphics output in place within the
worksheet in several ways. For instance:
- If you click the left mouse button once over the graphics output, you
will see a black box with eight ``tabs'' displayed at the corners and the
midpoints of the edges of the box. If you place the cursor on one of the
tabs, hold down the left mouse button, drag the cursor and release, you
can resize the graphics. Try it! Note: This
feature is especially useful when you go to print your worksheet.
The "default" size for printed versions of plots is so large that
a single plot will take almost one whole sheet of paper(!)
Please save trees by resizing your plots to smaller sizes(!).
- Maple 2D graphics output regions have another nice feature: If you
place the cursor arrow at a point in a 2D graphics region and click the
LEFT mouse button once, approximate coordinates of the point at
the head of the arrow are printed out in a box at the upper left of the
window. How good approximations can you get that way to the x-intercepts
of this graph?
- Other features of the graph can be changed from the tool bar. Experiment
and see if you can figure out what the different tool bar icons do.
When you get a graphics window with all the intercepts shown,
let's add two more things.
- First, it's possible to show more than one graph on the
same set of axes. To do this, you place the formulas for
the functions you want in a set of square brackets ([ ]),
separated by commas. In the options section of the plot
command, you can then specify which colors you want to use
to make the graph more informative. For example, the option
color=[black,red]
will color the first function you listed black, and the
second one red. Most other common colors
are available too, by their usual names,
and you can ``mix and match'' at will.
(Unfortunately we don't have a color printer
in the lab, but at least you will see the colors on the
monitor :( ). In your plot, add a second graph,
y = sin(x) and color the two plots blue and green.
- Sometimes, an informative title makes a graph
much more understandable. To add a text title to a plot, you can insert
a comma after the range of x-values, and include an option in the plot
command of the form
title="whatever you want"
Add an appropriate
title to your plot.
Include the final graph you generate here in the worksheet you
submit for this assignment.
More Detailed Information on Maple Commands
Now that we have seen some first examples of Maple commands, here is
some more information about the syntax rules that Maple uses to
decide if what you have typed in is a well-formed command it can execute.
For a function described by a formula, the formula is entered in something
like usual mathematical notation:
- The symbols for addition, subtraction, multiplication, and division
are +, -, *, / respectively.
- The caret (^) is the Maple symbol for raising to a power.
- The asterisk symbol for multiplication MUST be included whenever you
are performing a product in a formula. Moreover, everything must be entered
in one string of characters, so you will need to use parentheses
to group terms to get the expressions you want. The rule to keep in mind
is: Maple always evaluates expressions by doing powers first, then products
and quotients, then sums and products, left to right, unless parentheses
are used to override these built-in rules. For example, the Maple expression
a + b^2/c + d is the same as the mathematical formula:
a + b2/c + d. If you really wanted
a + b2 in the numerator and c + d
in the denominator of a fraction, you will need to enter the expression
(a + b^2)/(c + d). What if you really wanted
(a+b)2 in the numerator?
- Maple ``knows'' all the usual functions from the ``catalog''
in Chapter 1 of our textbook. The
names of the most common ones are sin, cos, tan, exp, ln. To use
one of these functions in a Maple formula, you put the name, followed by
the ``argument'' (that is the expression you are applying the function
to) in parentheses.
- The range of x-values to plot for a graph y = f(x) MUST be
specified, in the format x = lowx..highx. A range of y-values to plot
can also be specified, in the format y = lowy..highy.
- Every Maple command must be terminated either with a semicolon or a
colon. This is the signal that the command is finished and that Maple should
try to execute what you asked it to do. The difference between a semicolon
and a colon is that for commands terminated with a semicolon, any output
produced will be displayed. If you terminate the command with a colon,
the calculation will be performed but not displayed (this is useful sometimes
for intermediate steps in a big computation where you don't need to see
the output). Until you enter either a semicolon or a colon and press ENTER,
Maple will not do anything with your command. Also, if a command you want
to enter doesn't all fit on one line, just keep typing, but don't press
ENTER until you are finished. Maple automatically wraps around to a new
line if you need it.
Lab Activity 2
Questions
A) Power functions f(x) = xn and
exponential functions g(x) = ax with a > 1
both increase as x increases. If we only plot a small range
of values, though, what we see might be misleading about which function
is growing faster as x -> +infinity.
- For example, plot f(x) = 2x (2^x in Maple)
and g(x) = x3 together on the same axes
for x = 0..3. Which one seems to be growing faster?
- What happens if you extend the range of plotting to x = 0..8?
- Your last plot should suggest that the exponential
might actually be ``catching up'' to the power and
getting ready to pass it. To see if that is true, we can use
a different feature of Maple to solve the equation
x3 = 2x. The command
fsolve(x^3 = 2^x, x=10);
will do this (approximately), looking for x
``near 10''. Take the number you get, add 3 and plot the two
functions again on the range from x = 0 to that number.
- Repeat the previous parts for f(x) = 2^x
and g(x) = x4, x5,
and x6. (Note: You will need to change the fsolve
command to include an appropriate place to look for
solutions of xn = 2x for the
different values of n.)
Do any of these functions
keep growing faster than f(x) = 2x indefinitely?
Where does each of them get overtaken by the exponential?
B) (Some polynomial graphs)
- Execute the plot command:
plot(2*x^4-20*x^3+70*x^2-100*x+48,x=0..5);
- By looking at the x-axis intercepts of the graph, what would be the
factored form of this fourth-degree polynomial? Check that this polynomial and
the factored form are the same. (There is a command called expand
in Maple that you can use for this!)
- This is one of the possible shapes for the graph of a fourth-degree
polynomial, but it is not the only one. In the this part, we will
see a Maple animated plot showing the family of graphs
y= 2x4-20x3+70x2- (100-a)x+48
for -8 <= a <= 8.
Execute the commands:
with(plots);
animate(plot,[2*x^4-20*x^3+70*x^2-(100-a)*x+48,x=0..5],a=-8..8,frames=60);
To ``play the animation'', use the mouse to
place the cursor over the graph and click the left mouse button.
If you look at the toolbar in the Maple window, you should now
see a new collection of buttons like the standard control buttons
on a cassette tape player (remember those?!) You might have
some fun experimenting to see what they do(!)
Each click of the button marked
(->|) advances you one frame in the animation. Since we plotted
a from -8 to 8 in 60 frames, each click increases
a by 16/60, which is about .27. Run through the whole range a few
times, then answer the following questions.
The a value corresponding to each frame is given as a title
to the graph while that frame is displayed.
- Give the approximate range(s) of a-values for
which the polynomial 2x4-20x3+70x2- (100-a)x+48
has three different turning points. (A turning point is a point where the
function ``turns'' from being increasing to being decreasing, or
vice versa.) Explain in your own words what
appears to happen when that number decreases. Do you ever get just
two turning points?
- A real number r is said to be a multiple root of
a polynomial f(x) if (x - r)m can be
factored out of f(x), leaving a polynomial, for some m > 1.
The largest such power m is called the multiplicity
of the root. For example, x = 1 is a multiple root of
f(x) = x3 - 2 x2 + x,
with multiplicity 2, since
f(x) = x(x - 1)2.
Multiple roots of a polynomial show up as points where the x-axis
is tangent to the graph at the corresponding intercept. (For instance think
of f(x) = x2, which has a root of multiplicity 2 at x = 0.
The x-axis is tangent to the parabola y = x2 at
(0,0).)
There are three different a-values where
the polynomial
2x4-20x3+70x2- (100-a)x+48
has a multiple root. What are they (approximately)?
Assignment
The lab write-up (a paper print-out of your worksheet, including all
graphs and answers/explanations in text regions) is due on Monday,
September 10. One write-up for each pair of lab partners.