`;`

`>`

and Maple responds with an answer:
> 1/2+3;

The symbols for the basic operations are `+, `

`-`

, `*`

and
`/`

. Exponentiation is denoted by `^`

:

> 77*(3^5+5^2)/(99-47);

In the first example, the inverse of 2 is added to 3. In the second, we input , and Maple computes its value before printing the output.

You must always use the asterisk `*`

for multiplication. Forgetting it in
expressions like `sin(2*x)`

or `4*x`

is easy, and may result
in a syntax error message. Even if you don't get a syntax error, Maple will
not treat the expression as you expect.

Maple works primarily with whole numbers or fractions. However, you can
force it to write the decimal expansion of any number with `evalf`

:

> evalf(100*Pi);

> b:=sqrt(2);

> evalf(b);

> evalf(b,47);

Be careful with this example. The *assignment* of the variable `b`

to is done with `:=`

rather than with `=`

. This
will be the case of any other assignment operation you do in Maple, as we
discuss below. The equals sign `=`

is used to signify that two things
are equal, not to set one to the other.

Notice the difference in the following two examples:

> sum(1/(2*i),i=1..10);

> sum(1.0/(2*i),i=1..10);

In both cases, we compute
(2*i*)^{-1}. However, in the
second case, the presence of `1.0`

indicates to Maple the terms in
this computation are approximate, and gives you a decimal
expansion of the result.

> sum(i^3,i=1..n);

We can ask to factor the resulting polynomial in *n*:

> factor(

In this example, Maple's ``ditto operator'' `%`

is used^{1.3}
to refer to the result previously obtained.
Thus, in effect, the example above is equivalent to

> factor(1/4*(n + 1)^4 - 1/2*(n + 1)^3 + 1/4*(n + 1)^2);

One can expand or factor conveniently:

> p:=(x+1)^4*(x-6)^3;

> expand(

> factor(

We can use Maple to solve equations (if `b`

still has the value
from the previous section, first *unassign* it by executing
the command `b:='b'`

):

> quadeq:=a*x^2+b*x+c;

> solve(quadeq=0,x);

Notice that `solve`

provides both roots of the quadratic polynomial.

Maple also divides polynomials. Here the command you execute has a syntax which
is a little bit more complicated. Consider the following example:^{1.4}

> p:=x^10-1; q:=x-1; divide(p,q,b);

We assign the polynomials *x*^{10} - 1 and *x* - 1 to the variables `p`

and `q`

, respectively, and then ask Maple to divide `p`

by
`q`

.^{1.5}Maple replies with the statement `true`

to indicate that the
polynomial *q* = *x* - 1 divides the polynomial
*p* = *x*^{10} - 1 exactly, and places
the quotient in the third argument of the `divide`

command. Thus, if you
want to know the value of the quotient, you must see what the variable
`b`

stands for now:

> b;

Of course, the answer produced by `divide`

will be `false`

if
the polynomials do not divide each other exactly. Then one can use the
commands `quo`

and `rem`

to find the *quotient*
and *remainder* of the division:

> r:=x^2+2*x+3;

> divide(p,r,c);

> quo(p,r,x);

> rem(p,r,x);

We would have obtained an error if we would have tried `divide(p,r,b)`

,
trying to place the quotient of the division in the variable `b`

: it is
no longer a variable since it has a value from the previous example:

> divide(p,r,b);

The above command is equivalent to
`divide(p,r,x^9+x^8+x^7+x^6+x^5+x^4+x^3+x^2+x+1)`

, which makes no sense
at all. If we insist on calling the result of the division `b`

,
it would have been necessary to *unassign* the value of `b`

first:

> b:='b';

We could also have done this within the command itself, using
`divide(p,r,'b')`

.^{1.6}Further discussion on this is given in section 4.2.

We can use `solve`

for systems of equations. For example:

> solve(1*x+(1/2)*y+(1/6)*z =1, (1/2)*x+(1/6)*y+(1/24)*z =0, (1/6)*x+(1/24)*y+(1/120)*z =1, x,y,z );

Maple also solves inequalities:

> solve(x^2-4*x-7>0,x);

> solve(abs(1-x^2)<1/2,x);

Graphing in Maple

> plot(sin(x^2), x=-3..3);

Notice that within the worksheet interface, clicking the right mouse button on the displayed graph causes a menu to pop up that allows you to change some of its properties. Clicking the left mouse button causes a box to appear around the graph and the buttons on the toolbar to change. You can use the box to resize the graph, and the buttons to change attributes such as the style of the axes and the aspect ration.

In section 9 we shall discuss in further detail the graphing features of Maple.

- ... used
^{1.3} - In Maple V release 4 and earlier, Maple used the double-quote " to refer to the result of the previous command instead of %. If you encounter an older Maple program, you might have to change this, among some other things.
- ... example:
^{1.4} - In the worksheet interface, we can insert linebreaks by holding the
*shift*key and the*return*key simultaneously. Maple does not execute what we type until we hit the return key unshifted. - ...
`q`

.^{1.5} - Of course, we could have done all of this in a single Maple command divide(x^10-1, x-1, b); if we had no intention of using p or q again.
- ...
`divide(p,r,'b')`

.^{1.6} - In both cases, it is very important to use the proper quotation marks; using " or ` means a very different thing, and would not work. The quotation mark used here is the `single quote' or `right quote', and on most keyboards is on the same key as the double quoute, near the enter key.

2002-08-29