Mathematics 36, section 1 -- AP Analysis

Lab Day 3: Symbolic Calculations in Maple

September 17, 1997

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^2) - exp(2*x);

defines the function given in mathematical notation by f(x) = cos(x2) - e2x. 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(x2) - e2x as defined above, you can enter D(f);. The result:

x -> -2 sin(x2)x - 2 e(2x)

means the function that sends x to the value -2 sin(x2)x - 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 {it 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

Lab Assignment

Prepare a Maple worksheet showing all your computations and graphs for questions A,B above. Due: Tuesday, Sept. 23.