Previous Up Next

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).

Examples

Input in Maple mode (if the variable a is purged, otherwise first enter purge(a)):

subs(a=2,a^2+1)
     
5           

Input in Maple mode (if the variables a and b are purged, otherwise first enter purge(a,b)):

subs([a=2,b=1],a^2+b)
     
5           

In MuPAD or Xcas or TI modes, subs behaves like subst (see Section 9.1.13).

Examples

Input in MuPAD or Xcas or TI modes (if the variable a is purged, otherwise first enter purge(a)):

subs(a^2+1,a=2)

or:

subs(a^2+1,a,2)
     
5           

Input in MuPAD or Xcas or TI modes (if the variables a and b are purged, otherwise first enter purge(a,b) first):

subs(a^2+b,[a=2,b=1])

or:

subs(a^2+b,[a,b],[2,1])
     
5           

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.


Previous Up Next