AUTHORS:
TESTS:
We test coercion in a particularly complicated situation:
sage: W.<w>=QQ['w']
sage: WZ.<z>=W['z']
sage: m = matrix(WZ,2,2,[1,z,z,z^2])
sage: a = m.charpoly()
sage: R.<x> = WZ[]
sage: R(a)
x^2 + (-z^2 - 1)*x
Bases: sage.rings.polynomial.polynomial_element.Polynomial_generic_dense, sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_field
Bases: sage.rings.polynomial.polynomial_element.Polynomial, sage.structure.element.IntegralDomainElement
Return True if this polynomial is a unit.
EXERCISE (Atiyah-McDonald, Ch 1): Let be a polynomial
ring in one variable. Then
is a
unit if and only if
is a unit and
are
nilpotent.
EXAMPLES:
sage: R.<z> = PolynomialRing(ZZ, sparse=True)
sage: (2 + z^3).is_unit()
False
sage: f = -1 + 3*z^3; f
3*z^3 - 1
sage: f.is_unit()
False
sage: R(-3).is_unit()
False
sage: R(-1).is_unit()
True
sage: R(0).is_unit()
False
Bases: sage.rings.polynomial.polynomial_singular_interface.Polynomial_singular_repr, sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_domain, sage.structure.element.EuclideanDomainElement
EXAMPLES:
sage: R.<y> = PolynomialRing(QQ)
sage: K.<t> = NumberField(y^2 - 2)
sage: P.<x> = PolynomialRing(K)
sage: x.quo_rem(K(1))
(x, 0)
sage: x.xgcd(K(1))
(1, 0, 1)
Bases: sage.rings.polynomial.polynomial_element.Polynomial
A generic sparse polynomial.
EXAMPLES:
sage: R.<x> = PolynomialRing(PolynomialRing(QQ, 'y'), sparse=True)
sage: f = x^3 - x + 17
sage: type(f)
<class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_sparse'>
sage: loads(f.dumps()) == f
True
A more extensive example:
sage: A.<T> = PolynomialRing(Integers(5),sparse=True) ; f = T^2+1 ; B = A.quo(f)
sage: C.<s> = PolynomialRing(B)
sage: C
Univariate Polynomial Ring in s over Univariate Quotient Polynomial Ring in Tbar over Ring of integers modulo 5 with modulus T^2 + 1
sage: s + T
s + Tbar
sage: (s + T)**2
s^2 + 2*Tbar*s + 4
Return the coefficients of the monomials appearing in self.
EXAMPLES:
sage: R.<w> = PolynomialRing(Integers(8), sparse=True)
sage: f = 5 + w^1997 - w^10000; f
7*w^10000 + w^1997 + 5
sage: f.coefficients()
[5, 1, 7]
Return the degree of this sparse polynomial.
EXAMPLES:
sage: R.<z> = PolynomialRing(ZZ, sparse=True)
sage: f = 13*z^50000 + 15*z^2 + 17*z
sage: f.degree()
50000
Return a new copy of the dict of the underlying elements of self.
EXAMPLES:
sage: R.<w> = PolynomialRing(Integers(8), sparse=True)
sage: f = 5 + w^1997 - w^10000; f
7*w^10000 + w^1997 + 5
sage: d = f.dict(); d
{0: 5, 10000: 7, 1997: 1}
sage: d[0] = 10
sage: f.dict()
{0: 5, 10000: 7, 1997: 1}
Return the exponents of the monomials appearing in self.
EXAMPLES:
sage: R.<w> = PolynomialRing(Integers(8), sparse=True)
sage: f = 5 + w^1997 - w^10000; f
7*w^10000 + w^1997 + 5
sage: f.exponents()
[0, 1997, 10000]
Return a new copy of the list of the underlying elements of self.
EXAMPLES:
sage: R.<z> = PolynomialRing(Integers(100), sparse=True)
sage: f = 13*z^5 + 15*z^2 + 17*z
sage: f.list()
[0, 17, 15, 0, 0, 13]
Returns this polynomial multiplied by the power . If
is negative,
terms below
will be discarded. Does not change this polynomial.
EXAMPLES:
sage: R.<x> = PolynomialRing(ZZ, sparse=True)
sage: p = x^100000 + 2*x + 4
sage: type(p)
<class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_sparse'>
sage: p.shift(0)
x^100000 + 2*x + 4
sage: p.shift(-1)
x^99999 + 2
sage: p.shift(-100002)
0
sage: p.shift(2)
x^100002 + 2*x^3 + 4*x^2
AUTHOR: - David Harvey (2006-08-06)
EXAMPLES:
sage: R.<w> = PolynomialRing(GF(9,'a'), sparse=True)
sage: f = w^1997 - w^10000
sage: f.valuation()
1997
sage: R(19).valuation()
0
sage: R(0).valuation()
+Infinity
Bases: sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_sparse, sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_field
EXAMPLES:
sage: R.<x> = PolynomialRing(Frac(RR['t']), sparse=True)
sage: f = x^3 - x + 17
sage: type(f)
<class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_sparse_field'>
sage: loads(f.dumps()) == f
True
Bases: sage.rings.polynomial.polynomial_element_generic.Polynomial_padic_generic_dense, sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field
x.__init__(...) initializes x; see help(type(x)) for signature
Bases: sage.rings.polynomial.polynomial_element_generic.Polynomial_padic_field_dense
Bases: sage.rings.polynomial.polynomial_element.Polynomial_generic_dense, sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_domain
This function replaces coefficients of the polynomial that evaluate as equal to 0 with the zero element of the base ring that has the maximum possible precision.
WARNING: this function mutates the underlying polynomial.
x.__init__(...) initializes x; see help(type(x)) for signature
Bases: sage.rings.polynomial.polynomial_element_generic.Polynomial_padic_generic_dense
x.__init__(...) initializes x; see help(type(x)) for signature
Bases: sage.rings.polynomial.polynomial_element_generic.Polynomial_padic_ring_dense