The difference between = and :=
Recall that Maple uses := as the assignment operator. Thus a statement like
x := 3
actually sets
x
equal to 3 and Maple will then substitute in 3 every time it sees the variable
x,
until you set
x
equal to something else. This is in contrast to the
equal
operator = (no colon). The "=" operator is a comparison operator used when setting up equations. Here's an example. First, let's consider the expression
> x := 3;
This actually sets
x
equal to 3. If you ask Maple what
x
or
x
squared is:
> x; x^2;
Contrast this to using "=" with no colon:
> y = 3;
This did NOT set
y
equal to 3. You can check by asking Maple what it thinks
y
is:
> y;
The expression
y = 3
is an equation, waiting around to be solved or otherwise manipulated. The difference between
y := 3
and
y = 3
might roughly be translated into plain English as follows. To tell Maple
y := 3
means "Set y equal to 3", while telling Maple
y = 3
is like saying "what if y was equal to 3?"
As another example, you can sensibly combine ":=" and "=" in one expression. Suppose we want to construct the equation
. You can do this with the expression
> 6*y - 2 = 0;
At times it's advantageous to actually name equations. Suppose we want to name the above equation "
eqn
". We do this by assigning "
eqn
" to be the equation
,
> eqn := 6*y - 2 = 0;
You can now refer to the equation
by just typing the name,
> eqn;
or solve it:
> solve(eqn, y);
>
This illustrates that one can assign a variable to be any value (in this case, an equation), not just a number. If the difference between ":=" and "=" seems confusing, just remember for now to use ":=" when you actually want to assign a value to some variable and "=" when you set up equations to solve.