Mathematics 36, section 5 -- AP Calculus
Lab Day 2: Symbolic Calculations in Maple
September 20, 1999
Goals
Today, we will use some of the "shortcut rules" for differentiation
of functions defined by functions defined by formulas, as they are built
into Maple. We will see several new features of Maple, including the
D, diff (differentiate) commands and combine their
output with the plot command we have used before.
Some New Maple
1. Expressions and Functions
In plotting, we have used commands of the form
plot(expression,range,options);, where the expression
is the formula for the function we want to graph. Maple also allows you to
define functions
that can be evaluated, plotted, differentiated, and manipulated in other ways. This is done
by entering a command of the form
name := var -> expression(var);
The := is made by typing a colon, immediately followed by
an equals sign -- no space in between!
The name here is the name of the function
(like f, or g), the var
is the variable the function depends on. The -> sign is typed by entering a
minus and then a greater than with no space in between. The
expression(var) is
a formula or expression involving the variable. You can read this Maple
command as saying that the named function ``sends var to the value
of the expression.'' For instance,
f := x -> cos(x^3) - exp(-3*x);
defines the function given in mathematical notation by
f(x) = cos(x3) - e-2x.
A function can be plotted in exactly the same way we have seen.
For instance try the command:
plot(f(x), x=-2..2);
(If you like you can also say plot(f,-2..2); without the x's. However
if you leave the x out of the function, you must also leave it out of the specification
of the range.)
2. The D and diff commands.
To differentiate a
function given by a formula, for instance
f(x) = cos(x3) - e-2x
as defined above,
you can enter D(f);. The result:
x -> -3 sin(x3)x2 + 2 e(-2x)
means the function that sends x to the value
-3 sin(x2)x2 + 2 e(-2x). Note that this
function does not have a name as it stands. For a way to give it a name,
see point 3. next.
An alternate form of differentiation, useful for
expressions too, is diff(f(x),x);. The difference between these
is that
result of D(f) is the derivative function of f,
while diff gives
the formula (expression) defining the derivative function.
3. Symbolic names.
In many cases, it will
be useful to have a name or abbreviation for the result
of a computation, so that it can be easily accessed for
use in later work. This can be done with an assignment command
such as
name := expression;
For instance, if you enter d := D(f); (and until you assign a
different value to d) when you supply d as a function to
be plotted, etc., the result of the differentiation will be
substituted in for d everywhere it appears. For instance,
continuing from above, you could enter
dd := D(d);
What is the function dd in terms of f?
4. Maple's Biases.
When Maple can, it will try to supply you with an exact form of the
result of the calculation you asked for. For instance, try entering
f(1) to find the value of the function f defined before.
If you want to get a decimal
approximation instead, you can enter a command like:
evalf(f(1)));
This will give you a numerical result, if possible. evalf
means "EVALuate in the Floating point -- decimal number -- context,"
not as a symbolic expression.)
Lab Questions
- A) For each of the following functions, say what rules
you need to compute the derivative, compute the derivative by hand, and
check your results using Maple. Some of these involve functions like
arcsin(x), arctan(x), ln(x) and so forth, for
which we have not talked about the derivative rules yet in class. You
will need to recall the derivative rules for these from last year. (You
can also use Maple to "look them up" if you don't remember them!)
If your answer is different, show
how to simplify and/or rewrite it to get Maple's result.
- f(x) = arctan(x) esin(PI x) (in Maple format:
arctan(x)*exp(sin(Pi*x))).
- g(y) = ln(ln(2y4)).
- h(t) = cos2(5t + PI) (in Maple format:
(cos(5*t + Pi))^2)
- B)
- Using Maple, find a quadratic polynomial function
p(x) = Ax2 + Bx + C which has the same
value, the same first derivative, and the same second derivative
as f(x) = sin(arctan(x^2 - 2) + ln(x)),
when x = 1.9.
- Plot your quadratic and f together
on the same axes. (Note: To plot several functions together
on the same axes, in the plot, put their formulas
in a set of braces ({ , }), separated by commas, then the x-range,
and any options you want.) For what
range of x values does p(x) seem to be a good
approximation of f(x)? (Be careful
in choosing your range of x-values for plotting.)
Lab Assignment
Prepare a Maple worksheet showing all your
computations and graphs for questions A,B above.
Due: Wednesday, Sept. 22.