Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 4902

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>polynomial rings</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_monoid.html">next</a> | <a href="_finite_spfields.html">previous</a> | <a href="_monoid.html">forward</a> | <a href="_finite_spfields.html">backward</a> | <a href="_rings.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<div><a href="index.html" title="">Macaulay2Doc</a> > <a href="_rings.html" title="">rings</a> > <a href="_polynomial_springs.html" title="">polynomial rings</a></div>
<hr/>
<div><h1>polynomial rings</h1>
<div>Create a polynomial ring using the usual mathematical notation.<table class="examples"><tr><td><pre>i1 : R = QQ[x,y,z];</pre>
</td></tr>
<tr><td><pre>i2 : R

o2 = R

o2 : PolynomialRing</pre>
</td></tr>
</table>
Notice that after assignment to a global variable, Macaulay2 knows the ring's name, and this name is used when printing the ring.The original description of the ring can be recovered with <a href="_describe.html" title="real description">describe</a>.<table class="examples"><tr><td><pre>i3 : describe R

o3 = QQ[x..z, Degrees => {3:1}, Heft => {1}, MonomialOrder =>
                                                             
                                                             
     ------------------------------------------------------------------------
     {MonomialSize => 32}, DegreeRank => 1]
     {GRevLex => {3:1}  }
     {Position => Up    }</pre>
</td></tr>
</table>
Use the following subscript notation to obtain 0,1, or any multiple of 1, as elements in the ring.<table class="examples"><tr><td><pre>i4 : 0_R

o4 = 0

o4 : R</pre>
</td></tr>
<tr><td><pre>i5 : 1_R

o5 = 1

o5 : R</pre>
</td></tr>
<tr><td><pre>i6 : 11_R

o6 = 11

o6 : R</pre>
</td></tr>
</table>
Obtain the variables (generators) of the ring by subscripting the name of the ring.  As always in Macaulay2, indexing starts at 0.<table class="examples"><tr><td><pre>i7 : R_0^10+R_1^3+R_2

      10    3
o7 = x   + y  + z

o7 : R</pre>
</td></tr>
</table>
The number of variables is provided by <a href="_numgens.html" title="the number of generators">numgens</a>.<table class="examples"><tr><td><pre>i8 : numgens R

o8 = 3</pre>
</td></tr>
<tr><td><pre>i9 : apply(numgens R, i -> R_i^i)

             2
o9 = {1, y, z }

o9 : List</pre>
</td></tr>
<tr><td><pre>i10 : sum(numgens R, i -> R_i^i)

       2
o10 = z  + y + 1

o10 : R</pre>
</td></tr>
</table>
(See <a href="_apply.html" title="apply a function to each element">apply</a> and <a href="_sum.html" title="compute the sum">sum</a>.)  Use <a href="_generators.html" title="provide matrix or list of generators">generators</a> to obtain a list of the variables of the ring.<table class="examples"><tr><td><pre>i11 : gens R

o11 = {x, y, z}

o11 : List</pre>
</td></tr>
</table>
A matrix (with one row) containing the variables of the ring can be obtained using <a href="_vars_lp__Ring_rp.html" title="row matrix of the variables">vars(Ring)</a>.<table class="examples"><tr><td><pre>i12 : vars R

o12 = | x y z |

              1       3
o12 : Matrix R  &lt;--- R</pre>
</td></tr>
</table>
The <a href="_index.html" title="numeric index of a ring variable">index</a> of a variable:<table class="examples"><tr><td><pre>i13 : index x, index y, index z

o13 = (0, 1, 2)

o13 : Sequence</pre>
</td></tr>
</table>
The coefficient ring can be recovered with <a href="_coefficient__Ring.html" title="get the coefficient ring">coefficientRing</a>.<table class="examples"><tr><td><pre>i14 : coefficientRing R

o14 = QQ

o14 : Ring</pre>
</td></tr>
</table>
A random homogeneous element can be obtained with <a href="_random.html" title="get a random element">random</a>.<table class="examples"><tr><td><pre>i15 : random(2,R)

      1 2   9      3 2   8      4        2
o15 = -x  + -x*y + -y  + -x*z + -y*z + 9z
      2     2      2     7      9

o15 : R</pre>
</td></tr>
</table>
A basis of the subspace of ring elements of a given degree can be obtained in matrix form with <a href="_basis.html" title="basis of all or part of a module or ring">basis</a>.<table class="examples"><tr><td><pre>i16 : basis(2,R)

o16 = | x2 xy xz y2 yz z2 |

              1       6
o16 : Matrix R  &lt;--- R</pre>
</td></tr>
</table>
We may construct polynomial rings over polynomial rings.<table class="examples"><tr><td><pre>i17 : ZZ[a,b,c][d,e,f];</pre>
</td></tr>
</table>
When displaying an element of an iterated polynomial ring, parentheses are used to organize the coefficients recursively, which may themselves be polynomials.<table class="examples"><tr><td><pre>i18 : (a+d+1)^2

       2                2
o18 = d  + (2a + 2)d + a  + 2a + 1

o18 : ZZ[a, b, c][d, e, f]</pre>
</td></tr>
</table>
Variable names may be words.<table class="examples"><tr><td><pre>i19 : QQ[rho,sigma,tau];</pre>
</td></tr>
<tr><td><pre>i20 : (rho - sigma)^2

         2                     2
o20 = rho  - 2rho*sigma + sigma

o20 : QQ[rho, sigma, tau]</pre>
</td></tr>
</table>
There are various other ways to specify the variables in a polynomial ring.  A sequence of variables can be obtained as follows.<table class="examples"><tr><td><pre>i21 : ZZ[b..k];</pre>
</td></tr>
</table>
In this example, if you had previously assigned either b or k a value that was not a ring generator, then Macaulay2 would complain about this: it would no longer understand what variables you wanted.  To get around this, we could either do<table class="examples"><tr><td><pre>i22 : ZZ[symbol b .. symbol k];</pre>
</td></tr>
</table>
or we may obtain the single-letter variables with <a href="_vars.html" title="variables">vars</a>.<table class="examples"><tr><td><pre>i23 : vars (0..4)

o23 = (a, b, c, d, e)

o23 : Sequence</pre>
</td></tr>
<tr><td><pre>i24 : ZZ[vars (0..4),vars(26..30),vars 51]

o24 = ZZ[a, b, c, d, e, A, B, C, D, E, Z]

o24 : PolynomialRing</pre>
</td></tr>
</table>
Subscripted variables can be used, provided the base for the subscripted variable has not been used for something else.<table class="examples"><tr><td><pre>i25 : ZZ[t,p_0,p_1,q_0,q_1];</pre>
</td></tr>
</table>
Sequences of subscripted variables can also be used.<table class="examples"><tr><td><pre>i26 : ZZ[p_(0,0) .. p_(2,1),q_0..q_5]

o26 = ZZ[p   , p   , p   , p   , p   , p   , q , q , q , q , q , q ]
          0,0   0,1   1,0   1,1   2,0   2,1   0   1   2   3   4   5

o26 : PolynomialRing</pre>
</td></tr>
<tr><td><pre>i27 : (p_(0,0)+q_2-1)^2

       2                2
o27 = p    + 2p   q  + q  - 2p    - 2q  + 1
       0,0     0,0 2    2     0,0     2

o27 : ZZ[p   , p   , p   , p   , p   , p   , q , q , q , q , q , q ]
          0,0   0,1   1,0   1,1   2,0   2,1   0   1   2   3   4   5</pre>
</td></tr>
</table>
The subscripts can be much more general, but care is required when using symbols as subscripts, for the symbols may acquire values later that would interfere with your original use of them as symbols.  Thus you should protect symbols that will be used in this way.<table class="examples"><tr><td><pre>i28 : protect xx; protect yy; protect zz;</pre>
</td></tr>
<tr><td><pre>i31 : ZZ[ee_[xx],ee_[yy],ee_[zz]]

o31 = ZZ[ee    , ee    , ee    ]
           [xx]    [yy]    [zz]

o31 : PolynomialRing</pre>
</td></tr>
</table>
Polynomial rings over polynomial rings work:<table class="examples"><tr><td><pre>i32 : R = QQ[a,b][x]

o32 = R

o32 : PolynomialRing</pre>
</td></tr>
<tr><td><pre>i33 : (a+b+x)^3

       3             2      2            2      3     2        2    3
o33 = x  + (3a + 3b)x  + (3a  + 6a*b + 3b )x + a  + 3a b + 3a*b  + b

o33 : R</pre>
</td></tr>
</table>
<p>Internally, the polynomials in such towers are expressed in terms of a flattened monoid containing all the variables, obtainable with the key <a href="___Flat__Monoid.html" title="">FlatMonoid</a>.</p>
<table class="examples"><tr><td><pre>i34 : R.FlatMonoid

o34 = [x, a..b, Degrees => {{1}, 2:{0}}, Heft => {2:1}, MonomialOrder => {MonomialSize => 32}, DegreeRank => 2]
                            {0}    {1}                                   {GRevLex => {1}    }
                                                                         {Position => Up    }
                                                                         {GRevLex => {2:1}  }

o34 : GeneralOrderedMonoid</pre>
</td></tr>
</table>
Some things to watch out for when using polynomial rings:<ul><li>Defining a ring twice gives different rings, as far as Macaulay2 is concerned: We use the strict comparison operator <a href="___Thing_sp_eq_eq_eq_sp__Thing.html" title="strict equality">===</a> to demonstrate this.<table class="examples"><tr><td><pre>i35 : ZZ[a,b,c] === ZZ[a,b,c]

o35 = false</pre>
</td></tr>
</table>
Thus it is a good idea to assign a new ring to a variable for future reference.</li>
</ul>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="_heft_spvectors.html" title="">heft vectors</a></span></li>
<li><span><a href="_division_spin_sppolynomial_springs_spwith_spmonomials_spless_spthan_sp1.html" title="">division in polynomial rings with monomials less than 1</a></span></li>
</ul>
</div>
</div>
</body>
</html>