Mathematics 133 -- Intensive Calculus for Science 1
Lab 1: Getting Started with Maple, Plotting Functions and Derivatives
October 12, 2001
Goals
Today, we will begin using a program called Maple to draw graphs
of functions of one variable (given by symbolic formulas) and their derivatives.
You will be
using the commands covered here for most of the other lab days this semester.
On the mathematical side, we will study the relation between functions
and their derivative functions.
Maple Background and A First Example
Examples of all of the commands described here may be found
in the handouts from yesterday's class. You will probably want
to consult them for additional information.
First, you will need to get into Windows and Maple as described in the
General Information 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. You will always
want to define this first using the function definition format
given in the handout of Maple examples.
- 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 if you don't want to. More on this
later.
The above plot command is a template. To do an actual plot, you
will need to fill in the function and range of x values
for the plot you want and add the appropriate options.
For example, suppose we wanted to plot y = x4 - 2x3
+ x - 5 for x between -2 and 1. We could use the Maple
plot command with no options:
f:=x->x^4-2*x^3+x-5;
plot(f(x),x=-2..1);
(Note: The close parenthesis comes directly after the range of x-values
if there are no options.) Type in these command lines (exactly as here) and
press ENTER (RETURN) after each one. 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, then press RETURN again
When all goes well you will see the graphics output displayed under
the input command in the worksheet.
You can display several plots together by putting the formulas
for the functions together inside the plot command, in a set of
curly brackets ( { } ), separated by commas. For example, try entering
the command
plot({f(x),cos(x)},x=-2..1);
to plot our polynomial function from before together with y = cos(x).
The cosine function is built-in in Maple.
Let's add one more thing. 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"
Some additional information:
- Maple ``knows'' all the functions we studied in Chapter 1 of
our text. 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 = low..high. A range of y-values to plot can also
be specified, in the same format.
- 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).
Recall that we have introduced the derivative function f'(x)
for a function f(x). In Maple, the derivative function of
f is D(f).
Lab Questions
In these questions, we will study the function
f(x) = sin(x) - x cos(2 x).
and its derivative, etc.
To plot this function in Maple, you will need to translate the
mathematical formula into a Maple expression, and define
a function as in the handout of examples. Do this first.
- Plot the portion of the graph y = f(x)
on the x-range -4 <= x <= 4.
- Now, plot the portion of the graph y = f'(x)
for -4 <= x <= 4, on a separate set of axes.
- Use the graph of y = f'(x) to estimate the value
of f'(1). Use that value to find the equation of the
tangent line to y=f(x) at (1,f(1)) (do this by hand),
and plot that tangent line together with y = f(x).
- Answer the following questions in a text region in the
worksheet -- see the Maple Information handout for how to create
these:
- a. Over which intervals in the range -4 <= x <= 4 is
f'(x) positive?
- b. What is true about f(x) on each of the intervals from
part a? Explain why this is true and why the same relationship
between f and f' should be true
whenever f' is positive on an interval.
- c. Over which intervals in the range -4 <= x <= 4 is
f'(x) negative?
- d. What is true about f(x) on each of the intervals from
part c? Explain why this is true and why the same relationship
between f and f' should be true
whenever f' is negative on an interval.
- e. What is true about f(x) at each point where f'(x) = 0?
- The derivative of the derivative of a function f(x)
is called the second derivative of f, written
f''(x). In Maple, the second derivative function of f
is (D@@2)(f) (note the extra set of parentheses
around the D@@2 -- they must be included).
Plot the second derivative of f(x) = sin(x) - x cos(2 x) on
the same interval as in the previous questions.
- Answer the following questions in a second text region in your
worksheet:
- a. Over which intervals in the range -4 <= x <= 4 is
f''(x) positive?
- b. What is true about f'(x) on each of the intervals from
part a? What is true about f(x)?
- c. Over which intervals in the range -4 <= x <= 4 is
f''(x) negative?
- d. What is true about f'(x) on each of the intervals from
part c? What is true about f(x)?
Assignment
The lab write-up (a paper print-out of your worksheet, including all
graphs and explanations in text regions) is due on
Wednesday, October 17. Do not include the worked example, and
resize all of your plots smaller than the default output plot size that Maple
gives you
to conserve paper when you print.