- Introduction
- Assigning labels
- Entering an expression
- Entering a function
- Evaluating functions and expressions
- Plotting
- Exercises

> myname := 1.5;Once you hit return after this Maple line, any time the string of characters

Reusing variable names within the same lab is not recommended. It can be done, however, Maple will only store in its memory the last value that you assigned to the variable. So, if you go back to work on a previous problem with the same variable and forget to re-execute the old value, you could get some incorrect answers. Even if you do it correctly, sometimes Maple keeps a value in memory even though you've deleted the Maple line and tried to re-assign it. The best way to re-use a variable is to "clear" its memory for that variable. You can try the next example to see how this works.

> a := 5; > a; > a := 'a'; > a;Once you have cleared the variable, you are free to use it again. Another thing to keep in mind is that if you close your Maple worksheet for any reason and reopen it, none of the commands will be stored in memory until you re-execute each command by hitting return after each of the Maple lines. This can also be done by clicking on the

> expr := x^3+3*x^2-x+1;Note that in the expression above, there is an asterisk between 3 and . A common mistake is to write two functions next to each other without the "*" symbol. This would give incorrect results when using this expression since Maple doesn't understand implied multiplication. Another thing to keep in mind is when entering expressions in Maple that require the use of parentheses for grouping, the symbols ``(`` and ``)'' should be used since square brackets and curley brackets have special purposes in Maple.

> f := x-> x^3+3*x^2-x+1;Below is how ``NOT'' to enter a function:

> f(x) := x^3+3*x^2-x+1;The difference between expressions and functions are first the obvious, that expressions do not have to satisfy the definition of a function in the sense that for each input , there is a unique value . A function may be defined as an expression, but not all expressions can be defined as functions. The differences in Maple are numerous as you will see below when we evaluate the expression or function for a given value as well as when using the

> subs(x=2,expr); > subs(x=2.,expr); > subs(x=1/2,expr); > subs(x=0.5,expr);In the

> subs(x=a+h,expr); > subs(theta=Pi,sin(theta)*cos(theta));In Maple, functions are much easier to evaluate than expressions. In order to evaluate the function at , then simply type

> f(2);Here are a few more examples of evaluating functions.

> f(a+h); > f(Pi); > evalf(f(Pi));Note the use of the

> evalf(Pi,10);

> f := x-> x^2; > plot(f(x),x=-2..2);The

> plot(x^2,x=-2..2,y=-5..5,title=`My First Plot`);This particular command allows you to add arguments, but if you were to leave off one of the essential arguments, you will get an error message. You can also plot more than one function or expression on the same graph by enclosing them in curly braces ``{}'' and separating them by commas. For example, we can plot and on the same graph.

> f := x-> x^2-2; > g := x-> -x+2; > plot({f(x),g(x)},x=-4..4);

- Enter
as an expression.
- Evaluate this expression at .
- Evaluate this expression at .
- Evaluate this expression at .
- Evaluate this expression at and make sure your output is in decimal form.
- Plot this expression over the range .

- Repeat all parts of exercise 1 by first defining as a function.
- Define and as functions. Plot them both on the same graph. Estimate the two intersection points by observing the plot. Plug each value back into both functions to show that the values are the same.

2009-09-09