9.1.15 Substituting a variable by a value (Maple and MuPAD compatibility)
In Maple and in MuPAD, you would use the
subs command to substitute a variable
by a value in an expression. But the order of the arguments differ between
Maple and MuPAD. Therefore, to achieve
compatibility, in Xcas, the subs command arguments
order depends on the mode (see Section 2.5.2).
-
In Maple mode, subs takes two arguments:
-
eq, an equality or list of equalities of the form
var=value.
- expr, an expression.
- subs(eq,expr)
returns the expression with the variables replaced by their given
values.
Examples
Input in Maple mode (if the variable a is purged,
otherwise first enter purge(a)):
Input in Maple mode (if the variables a and
b are purged, otherwise first enter purge(a,b)):
In MuPAD or Xcas or TI modes, subs
behaves like subst (see Section 9.1.13).
-
subst takes two or three arguments:
-
expr, an expression.
- eqs, an equality of the form var=value
or a list of such equalities, or
vars,vals, a variable or list of variables followed by a
value or a list of values for substitution.
- subs(expr,eqs) or
subs(expr,vars,vals)
returns the expression with the variables replaced by their given
values.
Examples
Input in MuPAD or Xcas or TI modes (if the
variable a is purged, otherwise first enter purge(a)):
or:
Input in MuPAD or Xcas or TI modes (if the
variables a and b are purged, otherwise first enter
purge(a,b) first):
or:
Note that subs does not quote its argument, hence in a normal
evaluation process, the substitution variable should be purged
otherwise it will be replaced by its assigned value before
substitution is done.