Package sage :: Package rings :: Package polynomial :: Module polynomial_ring
[hide private]
[frames] | no frames]

Module polynomial_ring

source code


Univariate Polynomial Rings

SAGE implements sparse and dense polynomials over commutative and
non-commutative rings.  In the non-commutative case, the polynomial
variable commutes with the elements of the base ring.

AUTHOR:
   -- William Stein
   -- Kiran Kedlaya (2006-02-13): added macaulay2 option
   -- Martin Albrecht (2006-08-25): removed it again as it isn't needed anymore

EXAMPLES:
Creating a polynomial ring injects the variable into the interpreter namespace:
    sage: z = QQ['z'].0
    sage: (z^3 + z - 1)^3
    z^9 + 3*z^7 - 3*z^6 + 3*z^5 - 6*z^4 + 4*z^3 - 3*z^2 + 3*z - 1

Saving and loading of polynomial rings works:
    sage: loads(dumps(QQ['x'])) == QQ['x']
    True
    sage: k = PolynomialRing(QQ['x'],'y'); loads(dumps(k))==k
    True    
    sage: k = PolynomialRing(ZZ,'y'); loads(dumps(k)) == k
    True
    sage: k = PolynomialRing(ZZ,'y', sparse=True); loads(dumps(k))
    Sparse Univariate Polynomial Ring in y over Integer Ring

The rings of sparse and dense polynomials in the same variable are
canonically isomorphic:
    sage: PolynomialRing(ZZ,'y', sparse=True) == PolynomialRing(ZZ,'y')
    True

    sage: QQ['y'] < QQ['x']
    False
    sage: QQ['y'] < QQ['z']
    True

We create a polynomial ring over a quaternion algebra:
    sage: A.<i,j,k> = QuaternionAlgebra(QQ, -1,-1)
    sage: R.<w> = PolynomialRing(A,sparse=True)
    sage: f = w^3 + (i+j)*w + 1
    sage: f
    w^3 + (i + j)*w + 1
    sage: f^2
    w^6 + (2*i + 2*j)*w^4 + 2*w^3 + (-2)*w^2 + (2*i + 2*j)*w + 1
    sage: f = w + i ; g = w + j
    sage: f * g
    w^2 + (i + j)*w + k
    sage: g * f
    w^2 + (i + j)*w + -k

TESTS:
    sage: K.<x>=FractionField(QQ['x'])
    sage: V.<z> = K[]
    sage: x+z
    z + x



Classes [hide private]
  PolynomialRing_general
Univariate polynomial ring over a ring.
  PolynomialRing_commutative
Univariate polynomial ring over a commutative ring.
  PolynomialRing_integral_domain
  PolynomialRing_field
  PolynomialRing_dense_padic_ring_generic
  PolynomialRing_dense_padic_field_generic
  PolynomialRing_dense_padic_ring_capped_relative
  PolynomialRing_dense_padic_ring_capped_absolute
  PolynomialRing_dense_padic_ring_fixed_mod
  PolynomialRing_dense_padic_ring_lazy
  PolynomialRing_dense_padic_field_capped_relative
  PolynomialRing_dense_padic_field_lazy
  PolynomialRing_dense_mod_n
  PolynomialRing_dense_mod_p
Functions [hide private]
 
is_PolynomialRing(x)
Return True if x is a *univariate* polynomial ring (and not a sparse multivariate polynomial ring in one variable).
source code
 
polygen(ring_or_element, name='x')
Return a polynomial indeterminate.
source code
 
polygens(base_ring, names='x')
Return indeterminates over the given base ring with the given names.
source code
Variables [hide private]
  ZZ_sage = ['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-...
Function Details [hide private]

is_PolynomialRing(x)

source code 

Return True if x is a *univariate* polynomial ring (and not a sparse multivariate
polynomial ring in one variable).

EXAMPLES:
    sage: is_PolynomialRing(2)
    False

This polynomial ring is not univariate. 
    sage: is_PolynomialRing(ZZ['x,y,z'])
    False
    sage: is_MPolynomialRing(ZZ['x,y,z']) 
    True

    sage: is_PolynomialRing(ZZ['w']) 
    True
    
Univariate means not only in one variable, but is a specific data
type.  There is a multivariate (sparse) polynomial ring data type,
which supports a single variable as a special case.

    sage: is_PolynomialRing(PolynomialRing(ZZ,1,'w'))
    False
    sage: R = PolynomialRing(ZZ,1,'w'); R
    Multivariate Polynomial Ring in w over Integer Ring
    sage: is_PolynomialRing(R)
    False    
    sage: type(R)
    <class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain'>

polygen(ring_or_element, name='x')

source code 

Return a polynomial indeterminate.

INPUT:
   * polygen(base_ring, name="x")
   * polygen(ring_element, name="x")

If the first input is a ring, return a polynomial generator
over that ring.  If it is a ring element, return a polynomial
generator over the parent of the element. 

EXAMPLES:
    sage: z = polygen(QQ,'z')
    sage: z^3 + z +1
    z^3 + z + 1
    sage: parent(z)
    Univariate Polynomial Ring in z over Rational Field

NOTE: If you give a list or comma separated string to polygen, you'll
get a tuple of indeterminates, exactly as if you called polygens. 

polygens(base_ring, names='x')

source code 

Return indeterminates over the given base ring with the given names.

EXAMPLES:
    sage: x,y,z = polygens(QQ,'x,y,z')
    sage: (x+y+z)^2
    x^2 + 2*x*y + y^2 + 2*x*z + 2*y*z + z^2
    sage: parent(x)
    Multivariate Polynomial Ring in x, y, z over Rational Field
    sage: t = polygens(QQ,['x','yz','abc'])
    sage: t
    (x, yz, abc)    


Variables Details [hide private]

ZZ_sage

Value:
['4ti2-20061025',
 'R-2.6.0',
 'atlas-3.7.37',
 'atlas-3.8.1',
 'atlas-3.8.1.p1',
 'atlas-3.8.1.p3',
 'atlas-3.8.p11',
 'atlas-3.8.p6',
...