next up previous contents index
suivant: Evaluate a primitive at monter: Algebraic expressions précédent: Substitue a variable by   Table des matières   Index


Substitue a variable by a value (Maple and Mupad compatibility) : subs

In Maple and in Mupad, one would use the subs command to substitue a variable by a value in an expression. But the order of the arguments differ between Maple and Mupad. Therefore, to achieve compatibility, Xcas subs command arguments order depends on the mode subs returns the expression with the substitution done. Note that subs does not quote it's argument, hence in a normal evaluation process, the substitution variable should be purged otherwise it will be replaced by it's assigned value before substitution is done.
Input in Maple mode (if the variable a is purged else input purge(a)) :
subs(a=2,a^2+1)
Output
2^2+1
Input in Maple mode (if the variables a and b are purged else input purge(a,b)):
subs([a=2,b=1],a^2+b)
Output :
2^2+1
Input :
subs(a^2+1,a=2)
or :
subs(a^2+1,a,2)
Output (if the variable a is purged else input purge(a)) :
5
Input :
subs(a^2+b,[a=2,b=1])
or :
subs(a^2+b,[a,b],[2,1])
Output (if the variables a and b are purged else input purge(a,b)) :
2^2+1


next up previous contents index
suivant: Evaluate a primitive at monter: Algebraic expressions précédent: Substitue a variable by   Table des matières   Index
giac documentation written by Renée De Graeve and Bernard Parisse