Ring of Laurent Polynomials¶
If \(R\) is a commutative ring, then the ring of Laurent polynomials in \(n\) variables over \(R\) is \(R[x_1^{\pm 1}, x_2^{\pm 1}, \ldots, x_n^{\pm 1}]\). We implement it as a quotient ring
AUTHORS:
David Roe (2008-2-23): created
David Loeffler (2009-07-10): cleaned up docstrings
- sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing(base_ring, *args, **kwds)[source]¶
Return the globally unique univariate or multivariate Laurent polynomial ring with given properties and variable name or names.
There are four ways to call the Laurent polynomial ring constructor:
LaurentPolynomialRing(base_ring, name, sparse=False)
LaurentPolynomialRing(base_ring, names, order='degrevlex')
LaurentPolynomialRing(base_ring, name, n, order='degrevlex')
LaurentPolynomialRing(base_ring, n, name, order='degrevlex')
The optional arguments
sparse
andorder
must be explicitly named, and the other arguments must be given positionally.INPUT:
base_ring
– a commutative ringname
– stringnames
– list or tuple of names, or a comma separated stringn
– positive integersparse
– boolean (default:False
); whether or not elements are sparseorder
– string orTermOrder
, e.g.,'degrevlex'
– default; degree reverse lexicographic'lex'
– lexicographic'deglex'
– degree lexicographicTermOrder('deglex',3) + TermOrder('deglex',3)
– block ordering
OUTPUT:
LaurentPolynomialRing(base_ring, name, sparse=False)
returns a univariate Laurent polynomial ring; all other input formats return a multivariate Laurent polynomial ring.UNIQUENESS and IMMUTABILITY: In Sage there is exactly one single-variate Laurent polynomial ring over each base ring in each choice of variable and sparseness. There is also exactly one multivariate Laurent polynomial ring over each base ring for each choice of names of variables and term order.
sage: R.<x,y> = LaurentPolynomialRing(QQ, 2); R # needs sage.modules Multivariate Laurent Polynomial Ring in x, y over Rational Field sage: f = x^2 - 2*y^-2 # needs sage.modules
>>> from sage.all import * >>> R = LaurentPolynomialRing(QQ, Integer(2), names=('x', 'y',)); (x, y,) = R._first_ngens(2); R # needs sage.modules Multivariate Laurent Polynomial Ring in x, y over Rational Field >>> f = x**Integer(2) - Integer(2)*y**-Integer(2) # needs sage.modules
R.<x,y> = LaurentPolynomialRing(QQ, 2); R # needs sage.modules f = x^2 - 2*y^-2 # needs sage.modules
You can’t just globally change the names of those variables. This is because objects all over Sage could have pointers to that polynomial ring.
sage: R._assign_names(['z','w']) # needs sage.modules Traceback (most recent call last): ... ValueError: variable names cannot be changed after object creation.
>>> from sage.all import * >>> R._assign_names(['z','w']) # needs sage.modules Traceback (most recent call last): ... ValueError: variable names cannot be changed after object creation.
R._assign_names(['z','w']) # needs sage.modules
EXAMPLES:
LaurentPolynomialRing(base_ring, name, sparse=False)
sage: LaurentPolynomialRing(QQ, 'w') Univariate Laurent Polynomial Ring in w over Rational Field
>>> from sage.all import * >>> LaurentPolynomialRing(QQ, 'w') Univariate Laurent Polynomial Ring in w over Rational Field
LaurentPolynomialRing(QQ, 'w')
Use the diamond brackets notation to make the variable ready for use after you define the ring:
sage: R.<w> = LaurentPolynomialRing(QQ) sage: (1 + w)^3 1 + 3*w + 3*w^2 + w^3
>>> from sage.all import * >>> R = LaurentPolynomialRing(QQ, names=('w',)); (w,) = R._first_ngens(1) >>> (Integer(1) + w)**Integer(3) 1 + 3*w + 3*w^2 + w^3
R.<w> = LaurentPolynomialRing(QQ) (1 + w)^3
You must specify a name:
sage: LaurentPolynomialRing(QQ) Traceback (most recent call last): ... TypeError: you must specify the names of the variables sage: R.<abc> = LaurentPolynomialRing(QQ, sparse=True); R Univariate Laurent Polynomial Ring in abc over Rational Field sage: R.<w> = LaurentPolynomialRing(PolynomialRing(GF(7),'k')); R Univariate Laurent Polynomial Ring in w over Univariate Polynomial Ring in k over Finite Field of size 7
>>> from sage.all import * >>> LaurentPolynomialRing(QQ) Traceback (most recent call last): ... TypeError: you must specify the names of the variables >>> R = LaurentPolynomialRing(QQ, sparse=True, names=('abc',)); (abc,) = R._first_ngens(1); R Univariate Laurent Polynomial Ring in abc over Rational Field >>> R = LaurentPolynomialRing(PolynomialRing(GF(Integer(7)),'k'), names=('w',)); (w,) = R._first_ngens(1); R Univariate Laurent Polynomial Ring in w over Univariate Polynomial Ring in k over Finite Field of size 7
LaurentPolynomialRing(QQ) R.<abc> = LaurentPolynomialRing(QQ, sparse=True); R R.<w> = LaurentPolynomialRing(PolynomialRing(GF(7),'k')); R
Rings with different variables are different:
sage: LaurentPolynomialRing(QQ, 'x') == LaurentPolynomialRing(QQ, 'y') False
>>> from sage.all import * >>> LaurentPolynomialRing(QQ, 'x') == LaurentPolynomialRing(QQ, 'y') False
LaurentPolynomialRing(QQ, 'x') == LaurentPolynomialRing(QQ, 'y')
LaurentPolynomialRing(base_ring, names, order='degrevlex')
sage: R = LaurentPolynomialRing(QQ, 'a,b,c'); R # needs sage.modules Multivariate Laurent Polynomial Ring in a, b, c over Rational Field sage: S = LaurentPolynomialRing(QQ, ['a','b','c']); S # needs sage.modules Multivariate Laurent Polynomial Ring in a, b, c over Rational Field sage: T = LaurentPolynomialRing(QQ, ('a','b','c')); T # needs sage.modules Multivariate Laurent Polynomial Ring in a, b, c over Rational Field
>>> from sage.all import * >>> R = LaurentPolynomialRing(QQ, 'a,b,c'); R # needs sage.modules Multivariate Laurent Polynomial Ring in a, b, c over Rational Field >>> S = LaurentPolynomialRing(QQ, ['a','b','c']); S # needs sage.modules Multivariate Laurent Polynomial Ring in a, b, c over Rational Field >>> T = LaurentPolynomialRing(QQ, ('a','b','c')); T # needs sage.modules Multivariate Laurent Polynomial Ring in a, b, c over Rational Field
R = LaurentPolynomialRing(QQ, 'a,b,c'); R # needs sage.modules S = LaurentPolynomialRing(QQ, ['a','b','c']); S # needs sage.modules T = LaurentPolynomialRing(QQ, ('a','b','c')); T # needs sage.modules
All three rings are identical.
sage: (R is S) and (S is T) # needs sage.modules True
>>> from sage.all import * >>> (R is S) and (S is T) # needs sage.modules True
(R is S) and (S is T) # needs sage.modules
There is a unique Laurent polynomial ring with each term order:
sage: # needs sage.modules sage: R = LaurentPolynomialRing(QQ, 'x,y,z', order='degrevlex'); R Multivariate Laurent Polynomial Ring in x, y, z over Rational Field sage: S = LaurentPolynomialRing(QQ, 'x,y,z', order='invlex'); S Multivariate Laurent Polynomial Ring in x, y, z over Rational Field sage: S is LaurentPolynomialRing(QQ, 'x,y,z', order='invlex') True sage: R == S False
>>> from sage.all import * >>> # needs sage.modules >>> R = LaurentPolynomialRing(QQ, 'x,y,z', order='degrevlex'); R Multivariate Laurent Polynomial Ring in x, y, z over Rational Field >>> S = LaurentPolynomialRing(QQ, 'x,y,z', order='invlex'); S Multivariate Laurent Polynomial Ring in x, y, z over Rational Field >>> S is LaurentPolynomialRing(QQ, 'x,y,z', order='invlex') True >>> R == S False
# needs sage.modules R = LaurentPolynomialRing(QQ, 'x,y,z', order='degrevlex'); R S = LaurentPolynomialRing(QQ, 'x,y,z', order='invlex'); S S is LaurentPolynomialRing(QQ, 'x,y,z', order='invlex') R == S
LaurentPolynomialRing(base_ring, name, n, order='degrevlex')
If you specify a single name as a string and a number of variables, then variables labeled with numbers are created.
sage: LaurentPolynomialRing(QQ, 'x', 10) # needs sage.modules Multivariate Laurent Polynomial Ring in x0, x1, x2, x3, x4, x5, x6, x7, x8, x9 over Rational Field sage: LaurentPolynomialRing(GF(7), 'y', 5) # needs sage.modules Multivariate Laurent Polynomial Ring in y0, y1, y2, y3, y4 over Finite Field of size 7 sage: LaurentPolynomialRing(QQ, 'y', 3, sparse=True) # needs sage.modules Multivariate Laurent Polynomial Ring in y0, y1, y2 over Rational Field
>>> from sage.all import * >>> LaurentPolynomialRing(QQ, 'x', Integer(10)) # needs sage.modules Multivariate Laurent Polynomial Ring in x0, x1, x2, x3, x4, x5, x6, x7, x8, x9 over Rational Field >>> LaurentPolynomialRing(GF(Integer(7)), 'y', Integer(5)) # needs sage.modules Multivariate Laurent Polynomial Ring in y0, y1, y2, y3, y4 over Finite Field of size 7 >>> LaurentPolynomialRing(QQ, 'y', Integer(3), sparse=True) # needs sage.modules Multivariate Laurent Polynomial Ring in y0, y1, y2 over Rational Field
LaurentPolynomialRing(QQ, 'x', 10) # needs sage.modules LaurentPolynomialRing(GF(7), 'y', 5) # needs sage.modules LaurentPolynomialRing(QQ, 'y', 3, sparse=True) # needs sage.modules
By calling the
inject_variables()
method, all those variable names are available for interactive use:sage: R = LaurentPolynomialRing(GF(7), 15, 'w'); R # needs sage.modules Multivariate Laurent Polynomial Ring in w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14 over Finite Field of size 7 sage: R.inject_variables() # needs sage.modules Defining w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14 sage: (w0 + 2*w8 + w13)^2 # needs sage.modules w0^2 + 4*w0*w8 + 4*w8^2 + 2*w0*w13 + 4*w8*w13 + w13^2
>>> from sage.all import * >>> R = LaurentPolynomialRing(GF(Integer(7)), Integer(15), 'w'); R # needs sage.modules Multivariate Laurent Polynomial Ring in w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14 over Finite Field of size 7 >>> R.inject_variables() # needs sage.modules Defining w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14 >>> (w0 + Integer(2)*w8 + w13)**Integer(2) # needs sage.modules w0^2 + 4*w0*w8 + 4*w8^2 + 2*w0*w13 + 4*w8*w13 + w13^2
R = LaurentPolynomialRing(GF(7), 15, 'w'); R # needs sage.modules R.inject_variables() # needs sage.modules (w0 + 2*w8 + w13)^2 # needs sage.modules
- class sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing_mpair(R)[source]¶
Bases:
LaurentPolynomialRing_generic
EXAMPLES:
sage: L = LaurentPolynomialRing(QQ,2,'x') # needs sage.modules sage: type(L) # needs sage.modules <class 'sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing_mpair_with_category'> sage: L == loads(dumps(L)) # needs sage.modules True
>>> from sage.all import * >>> L = LaurentPolynomialRing(QQ,Integer(2),'x') # needs sage.modules >>> type(L) # needs sage.modules <class 'sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing_mpair_with_category'> >>> L == loads(dumps(L)) # needs sage.modules True
L = LaurentPolynomialRing(QQ,2,'x') # needs sage.modules type(L) # needs sage.modules L == loads(dumps(L)) # needs sage.modules
- monomial(*exponents)[source]¶
Return the monomial whose exponents are given in argument.
EXAMPLES:
sage: # needs sage.modules sage: L = LaurentPolynomialRing(QQ, 'x', 2) sage: L.monomial(-3, 5) x0^-3*x1^5 sage: L.monomial(1, 1) x0*x1 sage: L.monomial(0, 0) 1 sage: L.monomial(-2, -3) x0^-2*x1^-3 sage: x0, x1 = L.gens() # needs sage.modules sage: L.monomial(-1, 2) == x0^-1 * x1^2 # needs sage.modules True sage: L.monomial(1, 2, 3) # needs sage.modules Traceback (most recent call last): ... TypeError: tuple key (1, 2, 3) must have same length as ngens (= 2)
>>> from sage.all import * >>> # needs sage.modules >>> L = LaurentPolynomialRing(QQ, 'x', Integer(2)) >>> L.monomial(-Integer(3), Integer(5)) x0^-3*x1^5 >>> L.monomial(Integer(1), Integer(1)) x0*x1 >>> L.monomial(Integer(0), Integer(0)) 1 >>> L.monomial(-Integer(2), -Integer(3)) x0^-2*x1^-3 >>> x0, x1 = L.gens() # needs sage.modules >>> L.monomial(-Integer(1), Integer(2)) == x0**-Integer(1) * x1**Integer(2) # needs sage.modules True >>> L.monomial(Integer(1), Integer(2), Integer(3)) # needs sage.modules Traceback (most recent call last): ... TypeError: tuple key (1, 2, 3) must have same length as ngens (= 2)
# needs sage.modules L = LaurentPolynomialRing(QQ, 'x', 2) L.monomial(-3, 5) L.monomial(1, 1) L.monomial(0, 0) L.monomial(-2, -3) x0, x1 = L.gens() # needs sage.modules L.monomial(-1, 2) == x0^-1 * x1^2 # needs sage.modules L.monomial(1, 2, 3) # needs sage.modules
We also allow to specify the exponents in a single tuple:
sage: L.monomial((-1, 2)) # needs sage.modules x0^-1*x1^2 sage: L.monomial((-1, 2, 3)) # needs sage.modules Traceback (most recent call last): ... TypeError: tuple key (-1, 2, 3) must have same length as ngens (= 2)
>>> from sage.all import * >>> L.monomial((-Integer(1), Integer(2))) # needs sage.modules x0^-1*x1^2 >>> L.monomial((-Integer(1), Integer(2), Integer(3))) # needs sage.modules Traceback (most recent call last): ... TypeError: tuple key (-1, 2, 3) must have same length as ngens (= 2)
L.monomial((-1, 2)) # needs sage.modules L.monomial((-1, 2, 3)) # needs sage.modules
- class sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing_univariate(R)[source]¶
Bases:
LaurentPolynomialRing_generic
EXAMPLES:
sage: L = LaurentPolynomialRing(QQ,'x') sage: type(L) <class 'sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing_univariate_with_category'> sage: TestSuite(L).run()
>>> from sage.all import * >>> L = LaurentPolynomialRing(QQ,'x') >>> type(L) <class 'sage.rings.polynomial.laurent_polynomial_ring.LaurentPolynomialRing_univariate_with_category'> >>> TestSuite(L).run()
L = LaurentPolynomialRing(QQ,'x') type(L) TestSuite(L).run()
- Element[source]¶
alias of
LaurentPolynomial_univariate
- sage.rings.polynomial.laurent_polynomial_ring.from_fraction_field(L, x)[source]¶
Helper function to construct a Laurent polynomial from an element of its parent’s fraction field.
INPUT:
L
– an instance ofLaurentPolynomialRing_generic
x
– an element of the fraction field ofL
OUTPUT:
An instance of the element class of
L
. If the denominator fails to be a unit inL
an error is raised.EXAMPLES:
sage: # needs sage.modules sage: from sage.rings.polynomial.laurent_polynomial_ring import from_fraction_field sage: L.<x, y> = LaurentPolynomialRing(ZZ) sage: F = L.fraction_field() sage: xi = F(~x) sage: from_fraction_field(L, xi) == ~x True
>>> from sage.all import * >>> # needs sage.modules >>> from sage.rings.polynomial.laurent_polynomial_ring import from_fraction_field >>> L = LaurentPolynomialRing(ZZ, names=('x', 'y',)); (x, y,) = L._first_ngens(2) >>> F = L.fraction_field() >>> xi = F(~x) >>> from_fraction_field(L, xi) == ~x True
# needs sage.modules from sage.rings.polynomial.laurent_polynomial_ring import from_fraction_field L.<x, y> = LaurentPolynomialRing(ZZ) F = L.fraction_field() xi = F(~x) from_fraction_field(L, xi) == ~x
- sage.rings.polynomial.laurent_polynomial_ring.is_LaurentPolynomialRing(R)[source]¶
Return
True
if and only if R is a Laurent polynomial ring.EXAMPLES:
sage: from sage.rings.polynomial.laurent_polynomial_ring import is_LaurentPolynomialRing sage: P = PolynomialRing(QQ, 2, 'x') sage: is_LaurentPolynomialRing(P) doctest:warning... DeprecationWarning: is_LaurentPolynomialRing is deprecated; use isinstance(..., sage.rings.polynomial.laurent_polynomial_ring_base.LaurentPolynomialRing_generic) instead See https://github.com/sagemath/sage/issues/35229 for details. False sage: R = LaurentPolynomialRing(QQ,3,'x') # needs sage.modules sage: is_LaurentPolynomialRing(R) # needs sage.modules True
>>> from sage.all import * >>> from sage.rings.polynomial.laurent_polynomial_ring import is_LaurentPolynomialRing >>> P = PolynomialRing(QQ, Integer(2), 'x') >>> is_LaurentPolynomialRing(P) doctest:warning... DeprecationWarning: is_LaurentPolynomialRing is deprecated; use isinstance(..., sage.rings.polynomial.laurent_polynomial_ring_base.LaurentPolynomialRing_generic) instead See https://github.com/sagemath/sage/issues/35229 for details. False >>> R = LaurentPolynomialRing(QQ,Integer(3),'x') # needs sage.modules >>> is_LaurentPolynomialRing(R) # needs sage.modules True
from sage.rings.polynomial.laurent_polynomial_ring import is_LaurentPolynomialRing P = PolynomialRing(QQ, 2, 'x') is_LaurentPolynomialRing(P) R = LaurentPolynomialRing(QQ,3,'x') # needs sage.modules is_LaurentPolynomialRing(R) # needs sage.modules