4.7.1 rings.multi_polynomial_ring - Multivariate Polynomials

The module rings.multi_polynomial_ring defines the following classes:

class MPolynomialRing_base

class MPolynomialRing_polydict

class MPolynomialRing_polylist

The module rings.multi_polynomial_ring defines the following methods:

MPolynomialRing( base_ring, [n=dict], [var=x], [repr=1])

Create a Multivariate polynomial ring.

INPUT:
    base_ring -- Ring
    n -- int, number of variables  (default: 1)
    var -- list or str; list of n variable names or a string;
           if a string, names the variables var_0, var_1, etc.
           (default: 'x')
    repr -- str; choice of underlying representation
            of polynomials.
           (default: 'dict')
           The choices are
               'dict' -- Use a Python dictionary-based
                         representation  (faster)
               'list' -- Use a Python list-based representation

sage: R = MPolynomialRing(RationalField(), 3)
sage: R
Polynomial ring in x0, x1, x2 over Rational Field
sage: x0,x1,x2 = R.gens()
sage: x0.element()
PolyDict with representation {(1, 0, 0): 1}
sage: x0 + x1 + x2
x2 + x1 + x0
sage: (x0 + x1 + x2)**2
x2^2 + 2*x1*x2 + x1^2 + 2*x0*x2 + 2*x0*x1 + x0^2

Next we specify all the variables and do some additional examples of arithmetic.

sage: R = MPolynomialRing(RationalField(), 3, repr='list', var=['a','b','c'])
sage: R
Polynomial ring in a, b, c over Rational Field
sage: a,b,c = R.gens()
sage: a.element()
PolyList with distributive representation [[1, [1, 0, 0]]]
sage: (a+b)**2
2*a*b + a^2 + b^2
sage: (a + 2*b + 3*c**2)**3
27*a*c^4 + 8*b^3 + 27*c^6 + 9*a^2*c^2 + 36*a*b*c^2 + a^3 +
54*b*c^4 + 6*a^2*b + 12*a*b^2 + 36*b^2*c^2

We can construct multi-variate polynomials rings over completely arbitrary SAGE rings. In this example, we construct a polynomial ring S in 3 variables over a polynomial ring in 2 variables over GF(9). Then we construct a polynomial ring in 20 variables over S!

sage: R = MPolynomialRing(GF(9),2, var=['n1','n2']); n1,n2=R.gens()
sage: n1**2 + 2*n2
2*n2 + n1^2
sage: S = MPolynomialRing(R,3, var='a'); a0,a1,a2=S.gens()
sage: S
Polynomial ring in a0, a1, a2 over Polynomial ring in n1, n2
over Finite field of size 3^2
sage: x = (n1+n2)*a0 + 2*a1**2
sage: x
2*a1^2 + (n2 + n1)*a0
sage: x**3
2*a1^6 + (n2^3 + n1^3)*a0^3
sage: T = MPolynomialRing(S, 20)
sage: T
Polynomial ring in x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
x11, x12, x13, x14, x15, x16, x17, x18, x19 over Polynomial
ring in a0, a1, a2 over Polynomial ring in n1, n2 over Finite
field of size 3^2



Subsections
See About this document... for information on suggesting changes.