previous  next
1.2.15. Substitutions
To substitute a list of numbers or polynomials for the indeterminates
(in the order specified by the definition of the ring), one may use
the function 'Eval'.  To substitute out of order, use the function
'Subst'.

Example

Use R ::= Q[x,y,z];
F := x^2+y^2+z^2;
Eval(F,[1]);  -- substitute x=1
y^2 + z^2 + 1
-------------------------------
Eval(F,[1,2,3]);  -- substitute x=1, y=2, z=3
14
-------------------------------
Subst(F,y,2);  -- substitute y=2
x^2 + z^2 + 4
-------------------------------
Eval(F,[x,2,z]); -- same as above
x^2 + z^2 + 4
-------------------------------
Subst(F,[[y,y^2],[z,z^2]]);  -- substitute y^2 for y, z^2 for z
y^4 + z^4 + x^2
-------------------------------
Eval(Ideal(F),[x^2,z]); -- substitute x^2 for x, z for y
Ideal(x^4 + 2z^2)
-------------------------------