Ask Your Question

# Converting multivariable polynomial with complex coefficients to a polynomial with integer coefficients

If we make a polynomial involving $\sqrt{-2}$ like this

X = PolynomialRing(CC, names='X').gen()
r0 = (X**2 + 2).roots()
A,B = PolynomialRing(CC, 2, names='A,B').gens()
poly = (A + B + r0)*(A + B - r0)


we get $poly = A^2 + 2.00AB + B^2 + 2.00.$

How can this be changed into a polynomial with integer coefficients ?

If we had a univariate polynomial we could do this by mapping list(poly) to a list of integers and then defining a new polynomial with those. But this approach can't be translated directly to multivariable polynomials.

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted

There seems not to be a conversion from CC to ZZ, but there is one from CC to RR and one from RR to ZZ, so you can do:

sage: p = poly.change_ring(RR).change_ring(ZZ) ; p
A^2 + 2*A*B + B^2 + 2
sage: p.parent()
Multivariate Polynomial Ring in A, B over Integer Ring

more

## Your Answer

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

Add Answer

## Stats

Asked: 2021-01-13 18:03:37 +0200

Seen: 32 times

Last updated: Jan 14