Elements of Laurent polynomial rings
Bases: sage.structure.element.CommutativeAlgebraElement
Currently, one can only create LaurentPolynomials out of dictionaries and elements of the base ring.
EXAMPLES:
sage: L.<w,z> = LaurentPolynomialRing(QQ)
sage: f = L({(-1,-1):1}); f
w^-1*z^-1
sage: f = L({(1,1):1}); f
w*z
sage: f = L({(-1,-1):1, (1,3):4}); f
4*w*z^3 + w^-1*z^-1
sage: L(1/2)
1/2
Return the coefficient of mon in self, where mon must have the same parent as self.
The coefficient is defined as follows. If is this polynomial, then
the coefficient
is sum:
where the sum is over terms in
that are exactly divisible
by
.
A monomial ‘exactly divides’
if
and neither
nor
divides
.
INPUT:
OUTPUT:
Element of the parent of self.
Note
To get the constant coefficient, call constant_coefficient().
EXAMPLES:
sage: P.<x,y> = LaurentPolynomialRing(QQ)
The coefficient returned is an element of the parent of self; in this case, P.
sage: f = 2 * x * y
sage: c = f.coefficient(x*y); c
2
sage: c.parent()
Multivariate Laurent Polynomial Ring in x, y over Rational Field
sage: P.<x,y> = LaurentPolynomialRing(QQ)
sage: f = (y^2 - x^9 - 7*x*y^2 + 5*x*y)*x^-3; f
-x^6 - 7*x^-2*y^2 + 5*x^-2*y + x^-3*y^2
sage: f.coefficient(y)
5*x^-2
sage: f.coefficient(y^2)
-7*x^-2 + x^-3
sage: f.coefficient(x*y)
0
sage: f.coefficient(x^-2)
-7*y^2 + 5*y
sage: f.coefficient(x^-2*y^2)
-7
sage: f.coefficient(1)
-x^6 - 7*x^-2*y^2 + 5*x^-2*y + x^-3*y^2
Return the nonzero coefficients of this polynomial in a list. The returned list is decreasingly ordered by the term ordering of self.parent().
EXAMPLES:
sage: L.<x,y,z> = LaurentPolynomialRing(QQ,order='degrevlex')
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7
sage: f.coefficients()
[4, 3, 2, 1]
sage: L.<x,y,z> = LaurentPolynomialRing(QQ,order='lex')
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7
sage: f.coefficients()
[4, 1, 2, 3]
Return the constant coefficient of self.
EXAMPLES:
sage: P.<x,y> = LaurentPolynomialRing(QQ)
sage: f = (y^2 - x^9 - 7*x*y^2 + 5*x*y)*x^-3; f
-x^6 - 7*x^-2*y^2 + 5*x^-2*y + x^-3*y^2
sage: f.constant_coefficient()
0
sage: f = (x^3 + 2*x^-2*y+y^3)*y^-3; f
x^3*y^-3 + 1 + 2*x^-2*y^-2
sage: f.constant_coefficient()
1
Returns the degree of x in self
EXAMPLES:
sage: R.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7
sage: f.degree(x)
7
sage: f.degree(y)
1
sage: f.degree(z)
0
EXAMPLES:
sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7
sage: list(sorted(f.dict().iteritems()))
[((3, 1, 0), 3), ((4, 0, -2), 2), ((6, -7, 0), 1), ((7, 0, -1), 4)]
Returns a list of the exponents of self.
EXAMPLES:
sage: L.<w,z> = LaurentPolynomialRing(QQ)
sage: a = w^2*z^-1+3; a
w^2*z^-1 + 3
sage: e = a.exponents()
sage: e.sort(); e
[(0, 0), (2, -1)]
Returns a Laurent monomial (the unit part of the factorization) and a factored multi-polynomial.
EXAMPLES:
sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7
sage: f.factor()
(x^3*y^-7*z^-2) * (4*x^4*y^7*z + 3*y^8*z^2 + 2*x*y^7 + x^3*z^2)
Returns True if self contains any monomials with a negative exponent, False otherwise.
EXAMPLES:
sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7
sage: f.has_any_inverse()
True
sage: g = x^2 + y^2
sage: g.has_any_inverse()
False
INPUT:
OUTPUT:
Returns True if self contains a monomial including the inverse of self.parent().gen(i), False otherwise.
EXAMPLES:
sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7
sage: f.has_inverse_of(0)
False
sage: f.has_inverse_of(1)
True
sage: f.has_inverse_of(2)
True
Return the coefficient in the base ring of the monomial mon in self, where mon must have the same parent as self.
This function contrasts with the function coefficient() which returns the coefficient of a monomial viewing this polynomial in a polynomial ring over a base ring having fewer variables.
INPUT:
See also
For coefficients in a base ring of fewer variables, see coefficient().
EXAMPLES:
sage: P.<x,y> = LaurentPolynomialRing(QQ)
sage: f = (y^2 - x^9 - 7*x*y^3 + 5*x*y)*x^-3
sage: f.monomial_coefficient(x^-2*y^3)
-7
sage: f.monomial_coefficient(x^2)
0
Return the list of monomials in self.
EXAMPLES:
sage: P.<x,y> = LaurentPolynomialRing(QQ)
sage: f = (y^2 - x^9 - 7*x*y^3 + 5*x*y)*x^-3
sage: f.monomials()
[x^6, x^-3*y^2, x^-2*y, x^-2*y^3]
Note that this is a very unsophisticated implementation.
EXAMPLES:
sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = x + 2*y + 3*z
sage: f.subs(x=1)
2*y + 3*z + 1
sage: f.subs(y=1)
x + 3*z + 2
sage: f.subs(z=1)
x + 2*y + 3
sage: f.subs(x=1,y=1,z=1)
6
sage: f = x^-1
sage: f.subs(x=2)
1/2
sage: f.subs({x:2})
1/2
sage: f = x + 2*y + 3*z
sage: f.subs({x:1,y:1,z:1})
6
sage: f.substitute(x=1,y=1,z=1)
6
TESTS:
sage: f = x + 2*y + 3*z
sage: f(q=10)
x + 2*y + 3*z
Return a tuple of all variables occurring in self.
INPUT:
EXAMPLES:
sage: L.<x,y,z> = LaurentPolynomialRing(QQ)
sage: f = 4*x^7*z^-1 + 3*x^3*y + 2*x^4*z^-2 + x^6*y^-7
sage: f.variables()
(z, y, x)
sage: f.variables(sort=False) #random
(y, z, x)