Sophie

Sophie

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

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>working with multiple rings</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_basic_spconstruction_cm_spsource_spand_sptarget_spof_spa_spring_spmap.html">next</a> | <a href="_substitute.html">previous</a> | <a href="_basic_spconstruction_cm_spsource_spand_sptarget_spof_spa_spring_spmap.html">forward</a> | <a href="_substitute.html">backward</a> | <a href="_substitution_spand_spmaps_spbetween_springs.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="_substitution_spand_spmaps_spbetween_springs.html" title="">substitution and maps between rings</a> > <a href="_working_spwith_spmultiple_springs.html" title="">working with multiple rings</a></div>
<hr/>
<div><h1>working with multiple rings</h1>
<div>Working with multiple rings is more subtle than simply replacing values of the variables in a ring.  On the other hand it is particularly easy in Macaulay2.  We define a sequence of rings below and move between each to show both the dangers and the convenience.<h2>defining multiple rings</h2>
<table class="examples"><tr><td><pre>i1 : R1 = ZZ/101;</pre>
</td></tr>
<tr><td><pre>i2 : R2 = ZZ/101[s,t];</pre>
</td></tr>
<tr><td><pre>i3 : describe R2

o3 = R1[s..t, Degrees => {2:1}, Heft => {1}, MonomialOrder =>
                                                             
                                                             
     ------------------------------------------------------------------------
     {MonomialSize => 32}, DegreeRank => 1]
     {GRevLex => {2:1}  }
     {Position => Up    }</pre>
</td></tr>
</table>
Notice that Macaulay2 sees the coefficient ring as R1, we could just as easily defined <tt>R2</tt> as <tt>R1[s,t]</tt> .  Movement and addition between these rings is easy.<table class="examples"><tr><td><pre>i4 : I = ideal (s^4+t^2+1);

o4 : Ideal of R2</pre>
</td></tr>
<tr><td><pre>i5 : R3 = R2/I;</pre>
</td></tr>
<tr><td><pre>i6 : describe R3

          R2
o6 = -----------
      4    2
     s  + t  + 1</pre>
</td></tr>
</table>
Since <tt>I</tt> is defined as an ideal in <tt>R2</tt> we cannot type <tt>ZZ/101[s,t]/I</tt> as the computer sees <tt>ZZ/101[s,t]</tt> as different from <tt>R2</tt> and so does not see <tt>I</tt> as being in this ring.  For more about defining rings see <a href="_rings.html" title="">rings</a>.  We now work with moving between <tt>R2</tt> and <tt>R3</tt>.<h2>moving between rings using use and substitute</h2>
<table class="examples"><tr><td><pre>i7 : f = s^4+1

       2
o7 = -t

o7 : R3</pre>
</td></tr>
<tr><td><pre>i8 : g = s^4+t^2+1

o8 = 0

o8 : R3</pre>
</td></tr>
</table>
f and g are elements in <tt>R3</tt> now and this is shown by the fact that Macaulay2 sees them as <tt>-t^2</tt> and 0.  To recover these elements as polynomials in <tt>R2</tt> type <tt>use R2</tt> and define them again in <tt>R2</tt>.  The command substitute does not work well here, where as if we want to see the image of elements of <tt>R2</tt> in <tt>R3</tt> it does work well and without using the command <tt>use</tt>.  Macaulay2 always tells you which ring an element is in on the line after it prints the ring element.<table class="examples"><tr><td><pre>i9 : use R2;</pre>
</td></tr>
<tr><td><pre>i10 : substitute(g,R2)

o10 = 0

o10 : R2</pre>
</td></tr>
<tr><td><pre>i11 : f = s^4+1

       4
o11 = s  + 1

o11 : R2</pre>
</td></tr>
<tr><td><pre>i12 : g = s^4+t^2+1

       4    2
o12 = s  + t  + 1

o12 : R2</pre>
</td></tr>
<tr><td><pre>i13 : substitute(f,R3)

        2
o13 = -t

o13 : R3</pre>
</td></tr>
</table>
<h2>subtleties of substitute and describe</h2>
Now we complicate things further by constructing a fraction field and then further constructing polynomial rings and quotient rings.  First we see that while <tt>describe</tt> helped us to see how we defined <tt>R2</tt> and <tt>R3</tt>, the same does not hold when a fraction field is constructed.  Note that R3 is a domain.<table class="examples"><tr><td><pre>i14 : describe R3

           R2
o14 = -----------
       4    2
      s  + t  + 1</pre>
</td></tr>
<tr><td><pre>i15 : R4 = frac R3;</pre>
</td></tr>
<tr><td><pre>i16 : describe R4

          /     R2    \
o16 = frac|-----------|
          | 4    2    |
          \s  + t  + 1/</pre>
</td></tr>
</table>
The command <tt>substitute</tt> works well to move elements from <tt>R2</tt> or <tt>R3</tt> to <tt>R4</tt> substitute works well here. An alternative to substitute is to form the canonical injection of R3 into R4 (the same can be done for the canonical projection from R2 to R3 above - we do the example here).  To move elements from <tt>R4</tt> back to <tt>R3</tt> an alternate method must be used.  Also, the method of constructing a map does not work well in the reverse direction for the same reasons <tt>substitute</tt> does not.<table class="examples"><tr><td><pre>i17 : use R2;</pre>
</td></tr>
<tr><td><pre>i18 : f = s^4+1;</pre>
</td></tr>
<tr><td><pre>i19 : substitute(f,R4)

        2
o19 = -t

o19 : R4</pre>
</td></tr>
<tr><td><pre>i20 : use R3;</pre>
</td></tr>
<tr><td><pre>i21 : g = substitute(f,R3);</pre>
</td></tr>
<tr><td><pre>i22 : substitute(g,R4)

        2
o22 = -t

o22 : R4</pre>
</td></tr>
<tr><td><pre>i23 : F = map(R4,R3)

o23 = map(R4,R3,{s, t})

o23 : RingMap R4 &lt;--- R3</pre>
</td></tr>
<tr><td><pre>i24 : F(f)

        2
o24 = -t

o24 : R4</pre>
</td></tr>
</table>
<h2>non-standard coefficient fields</h2>
We can go through the whole process again using R4 now as the field.<table class="examples"><tr><td><pre>i25 : R5 = R4[u,v,w];</pre>
</td></tr>
<tr><td><pre>i26 : describe R5

o26 = R4[u..w, Degrees => {3:1}, Heft => {1}, MonomialOrder =>
                                                              
                                                              
      -----------------------------------------------------------------------
      {MonomialSize => 32}, DegreeRank => 1]
      {GRevLex => {3:1}  }
      {Position => Up    }</pre>
</td></tr>
<tr><td><pre>i27 : J = ideal(u^3-v^2*w+w^3,v^2+w^2,u*v-v*w+u*w)

              3    2     3   2    2
o27 = ideal (u  - v w + w , v  + w , u*v + u*w - v*w)

o27 : Ideal of R5</pre>
</td></tr>
<tr><td><pre>i28 : R6 = R5/J;</pre>
</td></tr>
<tr><td><pre>i29 : describe R6

                          R5
o29 = -----------------------------------------
        3    2     3   2    2
      (u  - v w + w , v  + w , u*v + u*w - v*w)</pre>
</td></tr>
</table>
Notice that at each stage Macaulay2 only refers back to the last ring we defined.  All of the methods above work still here in theory, but caution is advised.  We give an example below to illustrate.  Also, note that many other computations will no longer work, because Gröbner basis computations only work over <a href="___Z__Z.html" title="the class of all integers">ZZ</a>, <tt>ZZ/n</tt> and <a href="___Q__Q.html" title="the class of all rational numbers">QQ</a> at this time. <h2>using maps to move between rings</h2>
<table class="examples"><tr><td><pre>i30 : map(R6,R2)

o30 = map(R6,R2,{s, t})

o30 : RingMap R6 &lt;--- R2</pre>
</td></tr>
<tr><td><pre>i31 : substitute(f,R6)

        2
o31 = -t

o31 : R6</pre>
</td></tr>
</table>
Macaulay2 claims this is the zero map, and that the image of <tt>f</tt> is 1, but we know better.  By forming a series of maps and composing them we see the map that makes sense.  We also contrast the map with using <tt>substitute</tt>.<table class="examples"><tr><td><pre>i32 : use R2;</pre>
</td></tr>
<tr><td><pre>i33 : f = s^4+1;</pre>
</td></tr>
<tr><td><pre>i34 : F = map(R4,R2);

o34 : RingMap R4 &lt;--- R2</pre>
</td></tr>
<tr><td><pre>i35 : G = map(R5,R4);

o35 : RingMap R5 &lt;--- R4</pre>
</td></tr>
<tr><td><pre>i36 : H = map(R6,R5);

o36 : RingMap R6 &lt;--- R5</pre>
</td></tr>
<tr><td><pre>i37 : H(G(F(f)))

        2
o37 = -t

o37 : R6</pre>
</td></tr>
<tr><td><pre>i38 : f1 = substitute(f,R4)

        2
o38 = -t

o38 : R4</pre>
</td></tr>
<tr><td><pre>i39 : f2 = substitute(f1,R5)

        2
o39 = -t

o39 : R5</pre>
</td></tr>
<tr><td><pre>i40 : substitute(f2,R6)

        2
o40 = -t

o40 : R6</pre>
</td></tr>
</table>
<h2>elements versus matrices</h2>
Finally, note that everywhere we used the element <tt>f</tt> we can place a matrix or an ideal and get similar results.<h2>substitute(J,vars R)</h2>
We close this long example with a brief discussion of <tt>substitute(J,vars R)</tt>.  This command is more sensitive than <tt>substitute</tt> as it will give an error message when the variables involved do not match up.<table class="examples"><tr><td><pre>i41 : substitute(f,vars R3)

        2
o41 = -t

o41 : R3</pre>
</td></tr>
<tr><td><pre>i42 : try substitute(f,vars R5) else "found error"

o42 = found error</pre>
</td></tr>
</table>
</div>
</div>
</body>
</html>