Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You could define a ring homomorphism to a ring in which the order of the variables is changed.

sage: K.<a> = QuadraticField(2)
sage: R = PolynomialRing(K, 'x', 3)
sage: S = PolynomialRing(QQ, 'x', 3)['a'].quotient(K.defining_polynomial(), names='a')
sage: f = R.hom(S.base_ring().gens(), codomain=S, base_map=S.convert_map_from(K))
sage: f
Ring morphism:
  From: Multivariate Polynomial Ring in x0, x1, x2 over Number Field in a with defining polynomial x^2 - 2 with a = 1.414213562373095?
  To:   Univariate Quotient Polynomial Ring in a over Multivariate Polynomial Ring in x0, x1, x2 over Rational Field with modulus a^2 - 2
  Defn: x0 |--> x0
        x1 |--> x1
        x2 |--> x2
        with map of base ring

Example:

sage: p = (3 + 2*a) * sum(R.gens()); p
(2*a + 3)*x0 + (2*a + 3)*x1 + (2*a + 3)*x2
sage: f(p)
(2*x0 + 2*x1 + 2*x2)*a + 3*x0 + 3*x1 + 3*x2

The two polynomials are the coefficients:

sage: q, r = f(p).lift().coefficients(); q, r
(3*x0 + 3*x1 + 3*x2, 2*x0 + 2*x1 + 2*x2)