ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 13 Jun 2013 02:40:33 -0500How to write Buchberger algorithm?http://ask.sagemath.org/question/10223/how-to-write-buchberger-algorithm/Hello, I want to write this algorithm in sage, I know sage is python base but I'm not much familiar with this programming language so I'm working on it..
Could you please tell me how can I write Buchberger algorithm in sage? I know there is commands for computing it, but I want the algorithm..
input= (f1, ,fs)
output= a groebner basis G={ g1,...,gt} for f ? G
initialization :
G=F
*g*:= {(fi,fj) | fi,fj *?* G , fi!= fj }
h:=0
iteration
WHILE *g* != 0 DO
choose any {f,g} ? *g*
*g*:= *g* \ {{f,g}}
h:= (s(f,g)) ^G
IF h != 0 THEN
*g* := *g* U {{u,h}| u ? G }
G:= G U {h}
Tue, 11 Jun 2013 22:11:04 -0500http://ask.sagemath.org/question/10223/how-to-write-buchberger-algorithm/Answer by tmonteil for <p>Hello, I want to write this algorithm in sage, I know sage is python base but I'm not much familiar with this programming language so I'm working on it..
Could you please tell me how can I write Buchberger algorithm in sage? I know there is commands for computing it, but I want the algorithm..</p>
<p>input= (f1, ,fs)</p>
<p>output= a groebner basis G={ g1,...,gt} for f ? G</p>
<p>initialization :</p>
<p>G=F</p>
<p><em>g</em>:= {(fi,fj) | fi,fj <em>?</em> G , fi!= fj }</p>
<p>h:=0</p>
<p>iteration</p>
<pre><code> WHILE *g* != 0 DO
choose any {f,g} ? *g*
*g*:= *g* \ {{f,g}}
h:= (s(f,g)) ^G
IF h != 0 THEN
*g* := *g* U {{u,h}| u ? G }
G:= G U {h}
</code></pre>
http://ask.sagemath.org/question/10223/how-to-write-buchberger-algorithm/?answer=15071#post-id-15071A simpler way to find where `buchberger()` function is located could be the use of the `import_statements()` function:
sage: import_statements('buchberger')
from sage.rings.polynomial.toy_buchberger import buchberger
sage: from sage.rings.polynomial.toy_buchberger import buchberger
sage: buchberger??
Thu, 13 Jun 2013 02:40:33 -0500http://ask.sagemath.org/question/10223/how-to-write-buchberger-algorithm/?answer=15071#post-id-15071Answer by slelievre for <p>Hello, I want to write this algorithm in sage, I know sage is python base but I'm not much familiar with this programming language so I'm working on it..
Could you please tell me how can I write Buchberger algorithm in sage? I know there is commands for computing it, but I want the algorithm..</p>
<p>input= (f1, ,fs)</p>
<p>output= a groebner basis G={ g1,...,gt} for f ? G</p>
<p>initialization :</p>
<p>G=F</p>
<p><em>g</em>:= {(fi,fj) | fi,fj <em>?</em> G , fi!= fj }</p>
<p>h:=0</p>
<p>iteration</p>
<pre><code> WHILE *g* != 0 DO
choose any {f,g} ? *g*
*g*:= *g* \ {{f,g}}
h:= (s(f,g)) ^G
IF h != 0 THEN
*g* := *g* U {{u,h}| u ? G }
G:= G U {h}
</code></pre>
http://ask.sagemath.org/question/10223/how-to-write-buchberger-algorithm/?answer=15060#post-id-15060Check if it is in Sage's source code:
search_doc('buchberger')
This reveals that there is a file
$SAGE_ROOT/devel/sage/sage/rings/polynomial/toy_buchberger.py
(where $SAGE_ROOT is your Sage root directory).
In this file there is a function `buchberger` and a function `buchberger_improved`.
To get the code for Buchberger's algorithm, type
sage: from sage.rings.polynomial.toy_buchberger import buchberger
sage: buchberger??
It uses a function to compute the S-polynomial of two polynomials,
whose source code you can see by typing
sage: from sage.rings.polynomial.toy_buchberger import spol
sage: spol??
See also the online documentation for [toy_buchberger](http://www.sagemath.org/doc/reference/polynomial_rings/sage/rings/polynomial/toy_buchberger.html).
You can also browse the source code online at github. See [toy_buchberger](https://github.com/sagemath/sage/blob/master/src/sage/rings/polynomial/toy_buchberger.py) there.Tue, 11 Jun 2013 23:15:21 -0500http://ask.sagemath.org/question/10223/how-to-write-buchberger-algorithm/?answer=15060#post-id-15060