# Recasting Laurent polynomials

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi,

I have 2 Laurent polynomials, f and g, and I'm trying to recast them into multivariable polynomials over ZZ (I'm eventually going to take their gcd).

However, I'm not able to do so on the Sage Cloud.

So far, I've tried the following:

1. Extracting the monomials of f and g, and their coefficients, and reconstructed f by:

sum(map(mul,zip(f.coefficients(),f.monomials())))

However, this didn't help, because SAGE thinks the type is:

<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>


so I still can't take the gcd.

1. I also tried to recast into R.<x,y> = ZZ[], but this didn't work either: when I do sage: f.change_ring(R), I get the following error:

AttributeError: 'sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_mpair' object has no attribute 'change_ring'

Any suggestions would be greatly appreciated!! Thanks so much.

edit retag close merge delete

Also, I have already seen (https://ask.sagemath.org/question/33260/gcd-of-multivariable-polynomials-and-conversion-of-laurent-polynomials-to-ordinary-polynomials/ (https://ask.sagemath.org/question/332...)), but it didn't help me fix the issue at hand. Thanks again!

( 2017-06-11 18:52:12 -0500 )edit

Please give two simple polynomials f and g, (simple, but still relevant as an example,) and the code initializing them. Then what does it mean to "recast" them? (Mathematically...) And which gcd (over which polynomial ring) should be taken?

( 2017-06-12 10:02:39 -0500 )edit
1

If your Laurent polynomials happen to be classical polynomials (no negative powers), you can do as follows:

sage: R.<x,y> = LaurentPolynomialRing(ZZ)
sage: S.<X,Y> = PolynomialRing(ZZ)
sage: f = x^2+y^2+1 # Laurent polynomial
sage: g = x*y - 1 # Laurent polynomial
sage: F = S(f.dict()) # Classical polynomial
sage: G = S(g.dict()) # Classical polynomial
sage: H = F.gcd(G) # Classical polynomial
sage: h = R(H) # Laurent polynomial


Note that you could then define a gcd for Laurent polynomial that have no negative power quite easily.

( 2017-06-13 04:21:18 -0500 )edit

Note that change_ring is for changing the base ring (ZZ in your case)

( 2017-07-13 16:56:37 -0500 )edit