# Revision history [back]

Perhaps what you are looking for is not a substitution but a quotient ring where y and x*y are identified:

sage: P.<x, y, u> = PolynomialRing(Zmod(5)) ; P
Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5
sage: f = x*y + x^2*y^2 + x*y^2
sage: f.parent()
Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5
sage: Q = P.quotient(x*y-u) ; Q
Quotient of Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5 by the ideal (x*y - u)
sage: ff = Q(f) ; ff
ybar*ubar + ubar^2 + ubar
sage: ff.parent()
Quotient of Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5 by the ideal (x*y - u)


Now, if you want your polynomial back in P, you can do:

sage: fff = ff.lift() ; fff
y*u + u^2 + u
sage: fff.parent()
Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5


Perhaps what you are looking for is not a substitution but a quotient ring where yu and x*y are identified:

sage: P.<x, y, u> = PolynomialRing(Zmod(5)) ; P
Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5
sage: f = x*y + x^2*y^2 + x*y^2
sage: f.parent()
Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5
sage: Q = P.quotient(x*y-u) ; Q
Quotient of Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5 by the ideal (x*y - u)
sage: ff = Q(f) ; ff
ybar*ubar + ubar^2 + ubar
sage: ff.parent()
Quotient of Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5 by the ideal (x*y - u)


Now, if you want your polynomial back in P, you can do:

sage: fff = ff.lift() ; fff
y*u + u^2 + u
sage: fff.parent()
Multivariate Polynomial Ring in x, y, u over Ring of integers modulo 5