Sophie

Sophie

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

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>substituting values for variables</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_substring.html">next</a> | <a href="_subsets_lp__Z__Z_cm__Z__Z_rp.html">previous</a> | <a href="_substring.html">forward</a> | <a href="_subsets_lp__Z__Z_cm__Z__Z_rp.html">backward</a> | up | <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>
<hr/>
<div><h1>substituting values for variables</h1>
<div>Once a ring is defined that has variables, values can be given to these variables using <a href="_substitute.html" title="substituting values for variables">substitute</a>.  We give an example.<table class="examples"><tr><td><pre>i1 : R = ZZ/101[x,y,z];</pre>
</td></tr>
<tr><td><pre>i2 : f = x^3+3*y^2*z+2*z^3;</pre>
</td></tr>
<tr><td><pre>i3 : substitute(f,matrix{{-1,2,5}})

o3 = 309</pre>
</td></tr>
<tr><td><pre>i4 : substitute(f,{x=>-1,y=>2,z=>5})

o4 = 309</pre>
</td></tr>
</table>
The same command works for putting values into ideals or matrices.  Also, it is not required that the values be elements from the coefficient ring, nor do you have to give a value for every variable.<table class="examples"><tr><td><pre>i5 : M = matrix{{x^2,x-y},{x-z,z^2},{y-z,y^2}}

o5 = | x2  x-y |
     | x-z z2  |
     | y-z y2  |

             3       2
o5 : Matrix R  &lt;--- R</pre>
</td></tr>
<tr><td><pre>i6 : substitute(M,matrix{{-1,2,x+y}})

o6 = | 1      -3        |
     | -x-y-1 x2+2xy+y2 |
     | -x-y+2 4         |

             3       2
o6 : Matrix R  &lt;--- R</pre>
</td></tr>
<tr><td><pre>i7 : I = ideal M

             2                        2   2
o7 = ideal (x , x - z, y - z, x - y, z , y )

o7 : Ideal of R</pre>
</td></tr>
<tr><td><pre>i8 : substitute(I,{x=>-1,y=>2})

                                      2
o8 = ideal (1, - z - 1, - z + 2, -3, z , 4)

o8 : Ideal of R</pre>
</td></tr>
</table>
</div>
</div>
</body>
</html>