name := expression. The thing on the left side of
:=is a name, i.e. a sequence of letters and digits that begins with a letter. Certain names must be avoided because Maple uses them for special purposes (see section 4.4):
> a:=3; b:=5; c:=22/7;
Now you can use
c as though they are numbers.
Thus, we have
If you specify
y as an expression involving
x and then
assign a particular value to
x, this value will get substituted
x gets changed, then
y will also change. Maple remembers the
original definition of
Notice that Maple evaluates
x before telling you what the variable
y stands for now. To undo this kind of thing, you can unassign
variables. To do this for
We can also tell Maple to forget entirely all assignments made so far
x; y; z;
Surrounding an expression in single quotes1.10tells Maple to delay evaluation of it.
This is why
x is assigned to mean just
x without any evaluation.
Note that stopping evaluation does not stop simplification:
'x + 2 + 5';
exp(x)for ex and either
ln(x)for the natural logarithm lnx. Logarithm in other bases are also available. For example,
Of course, you will find yourself in a situation where you would like to define your own functions. Suppose you are analyzing the expression , plugging several values into it and calculating the result. Maple does not have a built-in function to do this, but you can define one yourself:
Carefully notice the syntax.
f is the name of the function and is
written to the right side of
:=. The function f sends the variable
x to the expression
; this is indicated by the
arrow. The arrow
-> is made with the minus and greater-than keys.
After such an assignment, you can use the name
f in the same way you
use other names of functions known to Maple, e.g.
f(0); f(1); f(-1); f(3*x+1);
We are so accustomed to the notation f (x) to refer to a function that we
might accidentally use it in Maple.
Never try to define a function with an assignment like
It seemed like this worked, but in fact, the resulting
f(x) does not
work as expected. You will not be able to substitute into it or do anything
you normally do with functions.1.11
Maple uses parentheses
( ) to group expressions together in a
convenient form as in
or to delimit the arguments of a function. In mathematics, we
sometimes cheat and write sinx instead of sin(x). In Maple,
this is not permissible: you must always write
parentheses are permitted:
The names of these constants are
Be careful! Maple is case sensitive. Therefore
pi is not the same as
Pi. For example,
Maple also uses
I to represent the complex number .
Earlier versions used
exp(1); this is no
longer the case. If you'd like to add
E as a constant, you can do
constants := constants, E;
While protecting your new constant
E will stop you from accidentally
redefining it, adding
E to the list of known constants doesn't really
affect things very much.
There are many commands and special objects in Maple that have preassigned names. In creating your own expressions and setting the name of your own variables, you cannot use any of the following 30 keywords:
Maple also starts with a large number of predefined functions and
constants. Many of these can be listed with
ininames. If you try to use one by mistake, you will receive
If you insist, you can use
unprotect to allow you to assign to
this name. But don't do this unless you know what you are
doing; this changes the meaning of this name even when it is used
internally, and can have unexpected consequences.