Ask Your Question
2

From one polynomial over an algebraic extension to several over Q.

asked 2020-05-12 09:55:23 -0500

Jose Samper gravatar image

Hello, I have what I assume is a basic question, but it deals with objects I usually don't work with on Sage and want to save some time. I have a polynomial $p(x_1,...,x_n)$ with coefficients in $Q[\sqrt 2 ]$. The way how i am extracting it gives a bunch of coefficients of the field that are fractions with irrational denominators. On the other hand, the polynomial can be written as $p(x_1,\dots,x_n) = q(x_1,\dots, x_n) + \sqrt {2} r(x_1,x_2,\dots, x_n)$ with $q$ and $r$ polynomials with rational coefficients. I am not used to work with field extensions and changing fields, but was wondering how to write a function that takes $p$ as an input and outputs $q$ and $r$.

(PS. in my particular case I have several inputs of $p$ and the number of variables is $n=15$). Thank you.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2020-05-12 11:13:09 -0500

tmonteil gravatar image

updated 2020-05-12 11:14:49 -0500

First, we can define the quadratic field of coefficients:

sage: R.<sqrt2> = QuadraticField(2)
sage: R
Number Field in sqrt2 with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095?
sage: sqrt2^2
2

An interesting method on those objects is the vector method:

sage: a = 3*sqrt2 + 1
sage: a
3*sqrt2 + 1
sage: a.vector()
(1, 3)
sage: a^2
6*sqrt2 + 19
sage: (a^2).vector()
(19, 6)

Now let us define you polynomial, let me use only 3 variables for the example:

sage: S.<x,y,z> = R[]
sage: S
Multivariate Polynomial Ring in x, y, z over Number Field in sqrt2 with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095?

sage: p = (1+3*sqrt2)*x*y + y*z^2
sage: p
y*z^2 + (3*sqrt2 + 1)*x*y

We can iterate over the coefficients as follows:

sage: for coeff, monom in p:
....:     print(coeff)
....:     print(monom)
....:     print(coeff*monom)
1
y*z^2
y*z^2
3*sqrt2 + 1
x*y
(3*sqrt2 + 1)*x*y

Now, we just have to combine such an iteration and the vector method to get what you want:

sage: q = sum(coeff.vector()[0]*monom for coeff, monom in p)
sage: q
y*z^2 + x*y
sage: r = sum(coeff.vector()[1]*monom for coeff, monom in p)
sage: r
3*x*y
sage: q+sqrt2*r
y*z^2 + (3*sqrt2 + 1)*x*y
sage: q+sqrt2*r == p
True
edit flag offensive delete link more
1

answered 2020-05-12 14:36:23 -0500

mwageringel gravatar image

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)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-05-12 09:21:46 -0500

Seen: 44 times

Last updated: May 12