;
and the corresponding stroke of the return key.
To familiarize yourself with it, try to run the following examples
and analyze the results. The commands that you type in and the Maple results
are shown here in a way that is similar to what you see on the screen.
>
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
(2i)-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 used1.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 x10 - 1 and x - 1 to the variables p
and q
, respectively, and then ask Maple to divide p
by
q
.1.5Maple replies with the statement true
to indicate that the
polynomial q = x - 1 divides the polynomial
p = x10 - 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.6Further 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);
>
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.
q
.1.5
divide(p,r,'b')
.1.6