up previous next
4.9.2 Evaluation of Polynomials
Polynomials may be evaluated using the function Subst . More generally, Subst allows one to substitute polynomials from the current ring for the indeterminates of a given polynomial. If substitutions are to be made for each indeterminate, in order, it is easier to use Eval . For more general substitutions, see Image .

Example
  Use R ::= QQ[x,y,z];
  F := x+y+z;
  Eval(F,[2,1]); -- let x=2 and y=1 in F
z + 3
-------------------------------
  Subst(F,[[x,2],[y,1]]);  -- the same thing using Subst
z + 3
-------------------------------
  Subst(F,y,1); -- the syntax is easier when substituting for a single
                -- indeterminate
x + z + 1
-------------------------------
  Subst(F,[[y,x-y],[z,2]]);  -- substitute x-y for y and 2 for z
2x - y + 2
-------------------------------