# Replacing Polynomials with another Polynomial

So I am working with quotient rings so I want to be able to replace terms as there can be many representatives. Let's say I have a polynomial ring of four variables quotiented off by some ideal. Futhermore, we have

x*w "=" x*y+y*z


in the quotient. Is there some replace function that will let me replace polynomial expressions with one another? For example, if I had 3xw+x*y, is there something like

replace(3*x*w+x*y, x*w for x*y+y*z)


which should output

4*x*y+3*y*z

edit retag close merge delete

Sort by ยป oldest newest most voted

One way is to use a polynomial ring and to reduce modulo an ideal.

Define a polynomial ring:

sage: R.<w, x, y, z> = QQ[]


Define an ideal:

sage: I = R.ideal([x*y + y*z - x*w])


Define a polynomial:

sage: P = 3*x*w+x*y


Reduce the polynomial modulo the ideal:

sage: P.reduce(I)
4*x*y + 3*y*z

more

How does Sage choose what it replaces? For example, in the thing you gave above, P=3xw + xy, it can choose to replace xw or choose to replace x*y. Does it go with the first one?

( 2020-07-18 19:44:08 +0200 )edit