<?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>extracting generators of an ideal</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_dimension_cm_spcodimension_cm_spand_spdegree.html">next</a> | <a href="_equality_spand_spcontainment.html">previous</a> | <a href="_dimension_cm_spcodimension_cm_spand_spdegree.html">forward</a> | <a href="_equality_spand_spcontainment.html">backward</a> | <a href="_ideals.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="_ideals.html" title="">ideals</a> > <a href="_extracting_spgenerators_spof_span_spideal.html" title="">extracting generators of an ideal</a></div> <hr/> <div><h1>extracting generators of an ideal</h1> <div><h2>obtain a single generator as an element</h2> Once an ideal has been constructed it is possible to obtain individual elements using <a href="__us.html" title="a binary operator, used for subscripting and access to elements">_</a>. As always in Macaulay2, indexing starts at 0. <table class="examples"><tr><td><pre>i1 : R = ZZ[w,x,y,z];</pre> </td></tr> <tr><td><pre>i2 : I = ideal(z*w-2*x*y, 3*w^3-z^3,w*x^2-4*y*z^2,x); o2 : Ideal of R</pre> </td></tr> <tr><td><pre>i3 : I_0 o3 = - 2x*y + w*z o3 : R</pre> </td></tr> <tr><td><pre>i4 : I_3 o4 = x o4 : R</pre> </td></tr> </table> <h2>the generators as a matrix or list of elements</h2> Use <a href="_generators.html" title="provide matrix or list of generators">generators</a> or its abbreviation <a href="_generators.html" title="provide matrix or list of generators">generators</a> to get the generators of an ideal <tt>I</tt> as a matrix. Applying <tt>first entries</tt> to this matrix converts it to a list.<table class="examples"><tr><td><pre>i5 : gens I o5 = | -2xy+wz 3w3-z3 wx2-4yz2 x | 1 4 o5 : Matrix R <--- R</pre> </td></tr> <tr><td><pre>i6 : first entries gens I 3 3 2 2 o6 = {- 2x*y + w*z, 3w - z , w*x - 4y*z , x} o6 : List</pre> </td></tr> </table> <h2>number of generators</h2> The command <a href="_numgens.html" title="the number of generators">numgens</a> gives the number of generators of an ideal <tt>I</tt>.<table class="examples"><tr><td><pre>i7 : numgens I o7 = 4</pre> </td></tr> </table> <h2>minimal generating set</h2> To obtain a minimal generating set of a homogeneous ideal use <a href="_mingens.html" title="minimal generator matrix">mingens</a> to get the minimal generators as a matrix and use <a href="_trim.html" title="minimize generators and relations">trim</a> to get the minimal generators as an ideal.<table class="examples"><tr><td><pre>i8 : mingens I o8 = | x wz 4yz2 3w3-z3 | 1 4 o8 : Matrix R <--- R</pre> </td></tr> <tr><td><pre>i9 : trim I 2 3 3 o9 = ideal (x, w*z, 4y*z , 3w - z ) o9 : Ideal of R</pre> </td></tr> </table> The function <tt>mingens</tt> is only well-defined for a homogeneous ideal or in a local ring. However, one can still try to get as small a generating set as possible and when it is implemented this function will be done by <tt>trim</tt>.<h2>obtaining the input form of an ideal</h2> If the ideal was defined using a function like <tt>monomialCurveIdeal</tt> and the generators are desired in the usual format for input of an ideal, the function <a href="_to__String.html" title="convert to a string">toString</a> is very useful. (Note: We are changing rings because <a href="_monomial__Curve__Ideal.html" title="make the ideal of a monomial curve">monomialCurveIdeal</a> is not implemented for rings over <a href="___Z__Z.html" title="the class of all integers">ZZ</a>.)<table class="examples"><tr><td><pre>i10 : R = QQ[a..d];</pre> </td></tr> <tr><td><pre>i11 : I = monomialCurveIdeal(R,{1,2,3}); o11 : Ideal of R</pre> </td></tr> <tr><td><pre>i12 : toString I o12 = ideal(c^2-b*d,b*c-a*d,b^2-a*c)</pre> </td></tr> </table> </div> </div> </body> </html>