Recasting Laurent polynomials

asked 2017-06-12 01:52:04 +0200

this post is marked as community wiki

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


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:


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 flag offensive close merge delete


Also, I have already seen ( (, but it didn't help me fix the issue at hand. Thanks again!

krishna gravatar imagekrishna ( 2017-06-12 01:52:12 +0200 )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?

dan_fulea gravatar imagedan_fulea ( 2017-06-12 17:02:39 +0200 )edit

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.

B r u n o gravatar imageB r u n o ( 2017-06-13 11:21:18 +0200 )edit

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

vdelecroix gravatar imagevdelecroix ( 2017-07-13 23:56:37 +0200 )edit