Substitutions and the subs command
Suppose you have a variable
thing
, defined in terms of another variable
t:
> thing := t^4 - 2*t^3 + t + 6;
You'd like to know the value of
thing
if
. One way to do this is to assign
t := 2
and then look at the value of
thing.
One drawback to this approach is that now
t
has been set equal to 2 and if you're planning to use
t
again you'll have to clear its value. There is an alternate approach that will tell you the value of thing when
, without actually assigning
t
equal to 2. It's Maple's
subs
command. An example:
> subs( t=2, thing );
The above command told Maple "tell me the value of
thing
supposing
t
is equal to 2", without actually setting
t
equal to 2; you can check that
t
has not been assigned any value. Also, the
subs
command can substitute several variables at once. To find the value of
when
,
, and
,
>
subs( {s=a+5, t=9, u=-4}, u^2 - t - s );
s;
t;
u;
>
Note that the values of
s, t,
and
u
have not been altered.
Do you see why the curly braces {} are needed here?