I was looking into this issue <https://github.com/sagemath/sage/issues/36201#issue-1885203561>
This throws error: ----------------------------------------------------------------------------------------- sage: R1.<x,y,z> = QQ[] sage: p = (x^2 - y^2) * (x + y + z) sage: S = QQ['z']['x,y'] sage: try: ....: S(p) ....: except Exception as e: ....: print(e) x^3 + x^2*y - x*y^2 - y^3 is not a constant polynomial But this passes -------------------------------------------------------------------------------------------- sage: R2.<z,x,y> = QQ[] sage: p = (x^2 - y^2) * (x + y + z) sage: S(p) x^3 + x^2*y - x*y^2 - y^3 + z*x^2 + (-z)*y^2 sage: So the output of p = R1.random_element() S(p) and S(R2(p)) should they be same or different ? One reason to this behavior is the ordering of monomial. Ref1 <https://github.com/sagemath/sage/blob/79c047c0a22a98bea4567d182c694fd4df1aea81/src/sage/rings/polynomial/multi_polynomial.pyx#L487C1-L487C38> The 1st one hits the Ref1 but 2nd one don't. That leads to ConstantPolynomial <https://doc.sagemath.org/html/en/reference/polynomial_rings/sage/rings/polynomial/polynomial_element.html#sage.rings.polynomial.polynomial_element.ConstantPolynomialSection> Error. On Sunday, July 28, 2024 at 3:42:28 AM UTC+5:30 Dima Pasechnik wrote: > On Sat, Jul 27, 2024 at 9:59 PM 'Animesh Shree' via sage-support > <sage-s...@googlegroups.com> wrote: > > > > I saw this behavior > > > > sage: R1.<x,y,z> = QQ[] > > sage: R2.<z,x,y> = QQ[] # Rearrange variables of R1 > > sage: R1 > > Multivariate Polynomial Ring in x, y, z over Rational Field > > sage: R2 > > Multivariate Polynomial Ring in z, x, y over Rational Field > > sage: R1 is R2 > > False > > sage: print(R1.gens(), R1.variable_names()) > > (x, y, z) ('x', 'y', 'z') > > sage: print(R2.gens(), R2.variable_names()) > > (z, x, y) ('z', 'x', 'y') > > sage: > > > > > > It looks like the order in which we initiate the polynomials leads to > different polynomial spaces. I thought this should not be the case. > > I got confused. Is it right or bug or intentional? > > It is by design. Multivariate polynomial rings come with monomial > orders (https://en.wikipedia.org/wiki/Monomial_order) > and in this case R1 and R1 have different monomial orders. > Monomial orders are crucial for many algorithms operating on > multivariate polynomial rings, their ideals, etc. > > Dima > > > > > -- > > You received this message because you are subscribed to the Google > Groups "sage-support" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to sage-support...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sage-support/30b4f982-9b1a-434f-a512-7690b6c16e6bn%40googlegroups.com > . > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/f25ed01f-2b98-47bd-bb56-52a42ed19149n%40googlegroups.com.