### Maple Tutor

Part 1:  Elementary Calculations

Each of the command entry instructions below is sent to Maple for processing by pressing the RETURN or ENTER key on your keyboard.

1.  In the Maple worksheet, type
2+3

and then press RETURN or ENTER. (From now on, we will not add this last part of the instruction.)

2.  Enter
2^3

Note where that the cursor remains in the exponent until you move it.

3.  Enter
2*(8-2^3)

Part 2: Variables

1.  Enter
x:=3; y:=2

Note where that the semicolon allows you to put two commands on the same line

2. Enter
2*x+y

3. The result of the preceding step follows from the fact that the variable x has been assigned the value 3 and the variable y has been assigned the value 2. Check this by entering
x; y

4.  Enter the following line. Note that it ends with a colon

z:=5:

5.  Enter
z+y

Note that entering a line with a colon has the effect as entering it without a colon, except that nothing is displayed afterwards.

6.  Use pencil and paper to decide what number xy2 + 3z represents, and then check your answer by entering
x*y^2+3*z

Use your mouse to return to the expression just entered, replace the 3 by 4, and press RETURN.

7.   Suppose we want to remove the identification of x with 3. Enter
x:='x'

Check this by entering
x
Now remove the identifications of y with 2 and z with 5. Check by entering
x*y*z

You should see  xyz  as the output.

8.   Maple distinguishes between := and =. The first is used for definitions. The equals sign alone is used to enter equations.
Check this by entering
solve(s^2-s-1=0,s)
(Here the s after the comma in the command tells Maple what to solve for.)

9.   Enter
2+3

and then
% + 5

The percent sign has the value of the last quantity calculated. Check this by entering
x*y

and then
% + z

Part 3: Text

1.  You may enter text as you would in any word processor by clicking on the word "Text" on the toolbar (next to the word "Math").

2.  You can return to Maple Notation input by clicking on the word "Math".

Part 4: What Maple remembers

1. Create a new region and type
x:=15

On a new line type
x+5
2. Go back into the region, delete the line
x:=15

and press RETURN. In the new region,
enter
x
Notice that Maple still remembers that x has been assigned the value 15 -- even though that line no longer appears in the worksheet.

Maple remembers what has been entered in the order it was entered.

• It doesn't matter what is currently in the worksheet, nor the order things appear in that worksheet. You may have assigned a value, erased the assigning command line, and forgotten about it. But Maple remembers. If you use x later, assuming it is an unassigned variable, strange things will happen.
• If variables are assigned new values, formulas using those variables acquire new values as well.

If you save a Maple file without removing the output, then reload it later, it will look the same as when you saved it. But Maple will not remember any of the displayed commands. All of those commands must be reentered before you are again in the same state as when you saved and closed the file.

3.  Enter
z:=3*s*t+2

Now assign the value 7 to s and the value 1 to t.
s:=7; t:=1

Then enter
z

to see the current value of z.

4. Go back up to the line

s:=7;

and change the 7 to 8. Then press RETURN while the cursor is still in this line. Again note that an altered line must be entered for the

altered value to be acknowledged by Maple. Similarly, change the value of t to -1. Now enter
z

again.

Maple remembers what has been entered in the order it was entered.

5.   A very useful command is the restart command. If you enter
restart
packages, must be reentered.

Part 5:  Functions

1. Next we define a function to assign the value 10 sin x to each x. Enter
x:='x'
f:=x->10*sin(x)

and then
f(1)

You may be surprised to see 10 sin(1)  rather than a decimal approximation.

2. To obtain a decimal approximation, enter
evalf(10*sin(1))   or    evalf(%)

The command "evalf" stands for "floating point evaluation."

3. To be sure that the action of evalf is clear, enter
2/3

and then
evalf(2/3)

and then
evalf(2/3,14)

4. Let's evaluate f at pi/6. First, we need the value of pi. Enter
Pi

evalf(Pi)

Compare this with
pi
evalf(pi)

Both "pi" symbols look the same, but only the one obtained with an upper case "P" and a lower-case "i" carries the numerical value.
Now find a decimal approximation to f(pi/6)

Part 6:  Graphing

1. In order to  plot 3 sin(2x) over the interval [0,2 pi]. Enter
plot(3*sin(2*x), x=0..2*Pi)
We can obtain the same result by defining the function f given by f(x) = 3 sin(2x) and plotting f(x). Enter the following:
f:= x->3*sin(2*x)
plot(f(x), x=0..2*Pi)

2. When the plot appears, use your mouse to "select" it -- you should see a box around the graphic. Experiment with the drag buttons at the corners and sides of the box. Experiment with the icons at the top of the screen to see what they do.

3.  Next we plot data given as ordered pairs. Enter
data:=[[0,1],[2,2],[4,6],[5,1]]
Then enter
plot(data, style=point)
Go back and see what happens if you delete "style=point."

4.  Often we wish to view several graphs at the same time. One way to do this is to enter the desired plots directly into the plot command.
Enter
plot([sin(x),cos(x)],x=0..2*Pi, color=[green,blue])

5.  Another way to create multiple plots is to use the display command in the plots package. To access this package click on "Tools" on the top toolbar, then click on "Load Package" then click on "Plots".
Now enter
graph1:=plot(sin(x),x=0..2*Pi,color=blue):
This creates a plot and names it "graph1."  Create a second plot by entering

graph2:=plot(cos(x),x=0..2*Pi, color=green):
To see both plots together, enter
display(graph1,graph2)

6.  To plot a curve defined implicitly, like the unit circle for example, first make sure that you have loaded the plots package (see 5 above)
then on a new line type
implicitplot(x^2+y^2 = 1, x = -1 .. 1, y = -1 .. 1).

7.  Try ploting x^2-y^2=1  with x = -3..3 and y = -3..3.

8.  In the Maple worksheet, click on the word   plots  (following the  word loading) to see many other possible plot commands.

Part 7:  Differentiation and Integration

1. Define g to be the function given by   g(x) = x2cos x.
Check your work by evaluating g(pi). You should obtain -pi2. If you have trouble, look at Part 5 again.

2. Now enter
diff(g(x),x)

Then enter
diff(g(x),x,x)

How would you calculate the third derivative?

3. If you want to calculate the derivative of an expression that you have not yet entered, just replace g(x) by the expression.
For example, enter
diff(x^3-x^2+2,x)
Now insert a literal constant in the expression: Enter
diff(x^3-a*x^2+2,x)
Then change the final x to an a. That is, enter
diff(x^3-a*x^2+2,a)

What is the role of the symbol after the comma in the differentiation expression?

4. Next  we calculate indefinite integrals. If necessary, unassign x:
x:='x'

Then enter
int(x*sin(x),x)

You can check that the result is an antiderivative of x sin(x) by entering
diff(%,x)

5.   Next try to find an antiderivative for sin(x3 + x5). Maple does not know an antiderivative of this function that may be defined in terms of functions known to it. On the other hand, try

int(exp(-x^2),x)

Note that Maple gives an answer involving the "erf" function , which you probably never heard of and not that useful to you at the moment.  We'll discuss this more later in the course.

6.  Next we calculate definite integrals. To integrate x sin(x) over the interval [0,pi/2], enter
int(x*sin(x),x=0..Pi/2)

7.   Now try this method on the integral of sin(x3+x5) over the interval [0,pi/2]. Maple still doesn't know an antiderivative for sin(x3+x5). To obtain a numerical estimate, enter
evalf(int(sin(x^3+x^5),x=0..Pi/2))
If you know that all you want is a numerical estimate, you can enter
evalf(Int(sin(x^3+x^5),x=0..Pi/2));
The significance of the upper-case I in Int is that Maple does not try to find a symbolic solution before starting on the numerical estimate.

8.   Maple can also compute improper integrals.  Enter
int(1/x^2,x=1..infinity)

Part 8: Algebraic Operations

1.  Enter the polynomial
P:=3*x^5-18*x^4-7*x^3+42*x^2-40*x+240

2.  Use the following command to factor P
factor(P)

Note that there is no space bewtween factor and (P)

3.  Enter
expand(%)

4.  We may use the solve command to obtain a complete factorization. Enter the following
S:=solve(P=0,x)

Notice in the complex roots that Maple uses a capital I for the imaginary unit -- rather than just i.

Part 9: Limits

1.  Limits are easy to calculate in Maple. As a test we'll calculate the limit of sin(x)/x as x approaches 0. Enter the following:
limit(sin(x)/x, x = 0)

2.  The Maple limit command also calculates limits at infinity. Enter
limit((1 + x3)/((1 + x)*(1+2*x2)), x = infinity)

3.  The standard limit command will deal with one-sided limits if there is no possibility of confusion. Enter
limit(sqrt(x)/sqrt(x + x^2), x=0

4.  Now try
limit(abs(x)/x, x = 0)

5.   Why is this limit ambiguous? Try
limit(abs(x)/x, x = 0, right)

Now replace "right" by "left."