substitution



> I have an expression with x, y and x*y and powers of this 
> numbers. I want to replace : x by E(x) y by E(y) x*y by E(x*y)...
> I have done this, but i think there is a more generic 
> solution

Regular "subst" only matches complete subtrees of the expression.  So 

  subst(qq,x*y,[x*y,x^2*y,x^2*y^2,x*y*z])
      => [qq,x^2*y,x^2*y^2,x*y*z]

ratsubst, on the other hand, will find partial subtrees:

  ratsubst(qq,x*y,[x*y,x^2*y,x^2*y^2,x*y*z])
      =>  [qq,qq*x,qq^2,qq*z]

(note that ratsubst does not recognize the subst(a=b,c) form -- I
consider this a bug)

ratsubst converts the whole expression to CRE form, so it recognizes
products in the expanded form:

  ratsubst(qq,x*y,(x+y)^5)
      => y^5 + 5*qq*y^3 + ...

This may be a problem in some applications:

  ratsubst(qq,x*y,(x*y+1)^50)
      => 1 + 50*qq + 1225*qq^2 + ...

Hope this helps.

      -s