1 | initial version |
If you intend to work with polynomials just work with polynomial rings. The symbolic expressions in Sage are very hard to parse. A simple example can be obtained as follows
sage: K.<x,y,z> = QQ[]
sage: p = x + 2*y - 3*z + 2*x*z + 3*x*y*z
sage: R.<z1,z2,z3,z4,z5> = QQ[]
sage: d = {x: z1, y: z2, z: z3, x*z: z4, x*y*z: z5}
sage: sum(p.monomial_coefficient(m) * v for m,v in d.iteritems())
z1 + 2*z2 - 3*z3 + 2*z4 + 3*z5