A Brief Introduction to Maple

 

Maple as a calculator

We will start by trying to do with Maple the basic operations that a calculator does. Try the following:

> 134 + 17;                             (you type)
                     151                (Maple's answer)

Basic rules: you must end each line in Maple with a semi-colon, otherwise Maple will not do anything. After you input a line ending with a semi-colon by hitting return, Maple will either produce an output or echo command, signifying the fact that it "heard" you.  Try now

> 145 * 45 + 2^8;                       (you type)
                    6781                (Maple's answer)
 
The basic operations are  for sum, the asterisk  for multiplication,  for division and the caret  to indicate powers.  It is important to observe the following for rational numbers:

> 36/9;                                 (you type)
                      4                 (Maple's answer)
> 36/11;                                (you type)
                    36/11               (Maple's answer)

Maple displays the exact answers. If you want an approximation by a decimal number, you can use the Maple function  evalf( );

> evalf(36/11);                         (you type)
                3.272727273             (Maple's answer)
> % + 5;                                (you type)
                8.272727273             (Maple's answer)

The operator  % is simply a shorthand notation identifying the previous result.  You can use parentheses as usual in algebra. Do not use square brackets [ ]  or curly brackets { } as algebraic delimeters, since they have special meaning in Maple.

Maple includes all basic functions,  such as sin, cos, exp, tan etc. Their arguments should be enclosed in round parentheses. For example,

> cos(0);                               (you type)
                      1                 (Maple's answer)

Maple knows the standard mathematical constants, such as  pi=3.141592... denoted by  Pi,  and the base of natural logarithm,  e = 2.718281828...  It works with them as exact quantities.

> evalf(Pi);                            (you type)
                 3.141592654            (Maple's answer)

> sin(3*Pi/2);                          (you type)
                     -1                 (Maple's answer)

> exp(1);                               (you type)
                      e                 (Maple's answer)

> ln(exp(5));                           (you type)
                      5                 (Maple's answer)
 

Maple as a symbolic manipulator

Maple knows how to work with mathematical unknowns, and expressions which contain them. For example, try

> y:= 2*cos(x)^2 + 6*x;                 (you type)
               y:= 2 cos(x)2 + 6x       (Maple's answer)

Entering  y:= 2*cos(x)^2 + 3*x; assigns to the variable  y the expression      2 cos(x)2   + 6x.  Maple can differentiate the expression  y with respect to  x

> diff(y,x);                            (you type)
              -4 cos(x) sin(x) + 6      (Maple's answer)

or integrate

> int(y,x);                             (you type)
            cos(x) sin(x) + x + 3x    (Maple's answer)

> int(y, x=0..1);                       (you type)
                cos(1) sin(1) + 4       (Maple's answer)

> evalf(int(y, x=0..1));                (you type)
                   4.454648713          (Maple's answer)

As you see, Maple's answers are not always decimal. In fact, Maple tries not to evaluate an expression until it is absolutely necessary. If you want to obtain a decimal answer, use  evalf( ) as above.  Maple can compute the values of the expression  y for a given value of  x :

> subs(x=0, y);                         (you type)
                        2               (Maple's answer)

So the command  subs(x=a, y); substitutes x=a in y.  Notice that the substitution does not make Maple forget the relationship between   x and  y.
 
 

Plotting graphs of one-variable functions

Maple can plot the graphs of one-variable functions: typing

> plot(x^2 - 5*x + 6,x=-1..5);           (you type)

will return a graph of the function  f(x) = x2 - 5x + 6 for the values of  x between  -1 and  5.  The graph will be displayed inline or in a separate window depending on how you set up the "Plot display" option in your "Options" menu.

In general, to plot the graph of a function of one variable, the command is
 

plot(expression, range);

Here,  "expression" can be something like  x^2 - 5*x + 6,  or if you have assigned this expression to a variable, say  w,  then "expression" can be just  w.  Also, "range" is the range of the independent variable, and it is entered as follows. Suppose the independent variable is  x  and you want a plot with  x  in the interval between  -1 and 5. Then you type  x=-1..5.  For example, to plot the graph of the function  g(x)= sin(2x), x=-Pi..Pi,  you may type

> z:= sin(2*x);
> plot(z,x=-Pi..Pi);

or simply

> plot(sin(2*x),x=-Pi..Pi);

Exercise.
Plot the graph of the function  f(x)=x4-5x2+4,  first for  x  between  -3  and 3 and then for  x  between -10  and  10. Notice how the change in scale changes the overall picture. This is an example of the limitations of the computer: the pictures provide only an approximate information about the real functions.

It is sometimes helpful to plot graphs of one or more functions simultaneously. Maple can do this, provided the range of the independent variable is the same for all functions. Here's how it is done. Suppose you have defined two functions of  x,  say  y and  z. To plot both of their graphs simultaneously, enter

> plot({y,z},range);

where  range is common to both functions and to be entered as explained above. Note that the two functions go into the "expression" field of  plot, inside curly brackets and separated by a comma. You can do this with more than two functions.

Exercise.
Plot the graph of the function  f(x)=x4-5x2+4 and the graph of its derivative on the same plot in the range between  -2.1 and  2.1.  Here is the solution:

> y:= x^4-5x^2+4;
> z:= diff(y,x);
> plot({y,z},x=-2.1..2.1);

Notice that the local max and min of  y correspond the zeroes of its derivative,  y is increasing where its derivative is positive etc.

Exercises.
Let  f(x)=x3-2x+1.
(a)  Evaluate  f(-1.5), f(0), f(1.5)
(b)  Plot the graph of the function f for  x between  -2 and  2.  Is this plot consistent with your answer to part (a) ?
(c)  Find a function  g(x)=mx+b whose graph is tangent to the graph of  f(x) at   x=0.
(d)  Plot the graphs of both functions simultaneously for  x between  -2 and  2 and then for  x between  -1 and  1.
 

Three-dimensional graphics

You must  begin your Maple session with the command

> with(plots);

Try the following exercise: enter exactly the following

> with(plots);                                     (return)
> polyhedraplot([0,0,0],polytype=icosahedron,
  style=patch,scaling=constrained);                (return)

You should get a new window with a picture of a solid dodecahedron (instead of "icosahedron" you can also type "dodecahedron", "octahedron", "hexahedron"  or "tetrahedron"). You can now rotate it in space as follows:  with the pointer in the picture window, click and hold the left mouse button.  Drag the pointer - this has the effect of rotating the picture.

Now try changing the style of display. Open the "Style" menu then choose for example "Wireframe". Experiment with the remaining styles. Try for example the style"Contour". What do you think Maple is displaying ? Experiment with other menus. Try especially the "Axes" menu.
 

More commands

The command  solve(equation,variable); attempts to solve an equation for the indicated variable. If there is only one variable, then there is no need to specify it. Try the following examples:

> solve(x^2+3*x-10=0);
> solve(exp(2*x)+1=0);
> solve(x+y=0);

The commands  simplify( ); and  expand( ); are self-explanatory. Try the following:

> expand((x-2)*(x+2)*(x^2+9));
> expand(sin(x+y));
> simplify(cos(x)^2+sin(x)^2);
 
 

Links to more advanced topics

 Space curves and parametric surfaces

 Level curves and surfaces

 Gradients

 Lagrange multipliers

 Vector fields