Sage Days 14 Talk system:sage



Sage

Creating a viable free open source alternative to
Magma, Maple, Mathematica and Matlab

William Stein, Associate Professor, University of Washington


 

{{{id=215| /// }}} {{{id=2| /// }}}

 

History

 

{{{id=117| /// }}} {{{id=214| /// }}}

 


sagemath.org

 

Each day about 1500-2000 different real human visitors each day.

 

 


 



Sage Devel Headquarters: Four 24-core Sun X4450's with 128GB RAM each + 1 Sun X4540 with 24TB disk

 

 


 

sagenb.org

{{{id=62| /// }}}

Some Advantages of Sage...

  1. Python-- a general purpose language at core of Sage; huge user base compared to Matlab, Mathematica, Maple and Magma

  2. Cython -- write fast compiled code in Sage

  3. Free and Open source

  4. Peer review of Code: "I do really and truly believe that the Sage refereeing model results in better code." -- John Cremona
{{{id=119| /// }}} {{{id=118| /// }}}

 


Sage Is...


{{{id=96| /// }}}

 

Examples: Calculus

Symbolic expressions:

{{{id=23| x, y = var('x,y') type(x) /// }}} {{{id=197| reset('e') /// }}} {{{id=19| a = 1 + sqrt(7)^2 + pi^e + 2/3 + x^y /// }}} {{{id=163| show(a) ///
{x}^{y} + {\pi}^{e} + \frac{26}{3}
}}} {{{id=253| show(expand(a^2)) ///
{x}^{{2 y}} + {{2 {\pi}^{e} } {x}^{y} } + \frac{{52 {x}^{y} }}{3} + {\pi}^{{2 e}} + \frac{{52 {\pi}^{e} }}{3} + \frac{676}{9}
}}} {{{id=254| show(integrate(sin(x^2))) ///
\frac{{\sqrt{ \pi } \left( {\left( {\sqrt{ 2 } i} + \sqrt{ 2 } \right) \text{erf} \left( \frac{{\left( {\sqrt{ 2 } i} + \sqrt{ 2 } \right) x}}{2} \right)} + {\left( {\sqrt{ 2 } i} - \sqrt{ 2 } \right) \text{erf} \left( \frac{{\left( {\sqrt{ 2 } i} - \sqrt{ 2 } \right) x}}{2} \right)} \right)}}{8}
}}} {{{id=252| /// }}}


Example: Some Rings

{{{id=207| QQ[sqrt(2)] /// Number Field in sqrt2 with defining polynomial x^2 - 2 }}} {{{id=201| RDF /// Real Double Field }}} {{{id=202| R = RealIntervalField(100); R /// Real Interval Field with 100 bits of precision }}} {{{id=203| R((1.01030,1.010332)) /// 1.0103? }}} {{{id=164| A = random_matrix(QQ, 500); v = random_matrix(QQ,500,1) time x = A \ v /// Time: CPU 1.56 s, Wall: 1.54 s }}} {{{id=3| len(str(x[0])) /// 1484 }}} {{{id=32| /// }}}

Example: A Huge Integer Determinant

{{{id=31| a = random_matrix(ZZ,200,200,x=-2^127,y=2^127) time d = a.determinant() len(str(d)) /// Time: CPU 3.26 s, Wall: 3.33 s 7785 }}}

We can also copy this matrix over to Maple and compute the same determinant there...

{{{id=167| a[0,0] /// -57511480170851074417469190457182575086 }}} {{{id=27| maple.with_package('LinearAlgebra') B = maple(a) t = maple.cputime() time c = B.Determinant() maple.cputime(t) /// Time: CPU 0.00 s, Wall: 23.42 s 21.962 }}} {{{id=168| c == d /// True }}}

This ability to easily move objects between math software is unique to Sage.

{{{id=82| B = magma(a) t = magma.cputime() time e = B.Determinant() magma.cputime(t) /// Time: CPU 0.00 s, Wall: 11.01 s 10.75 }}} {{{id=208| e == d /// True }}} {{{id=261| import scipy.stats /// }}} {{{id=262| /// }}} {{{id=260| [ZZ.random_element(-5,5) for _ in [1..1000]] /// [-3, -3, 3, -3, 2, 1, 4, -1, -2, -5, -4, -3, 3, -1, -1, 0, -1, 0, 2, -2, 2, 1, 4, 4, 3, 4, 0, -1, -2, -1, -2, 0, 1, 3, -4, 4, 0, -3, -3, 3, -4, -1, 1, 0, 3, 0, -1, -3, 2, 4, -5, -3, -5, -2, -3, -1, 4, 2, 0, -1, -4, 0, -4, -5, 0, 1, 2, 2, 1, 1, -5, 3, 1, -3, -1, 2, 0, -3, 4, 1, 3, 2, -1, -1, 2, -2, -2, 2, 2, 4, -5, 2, -1, -3, 2, 3, -5, 3, -4, -2, -2, -3, 0, -5, -3, 0, 4, 4, 0, -5, -3, -3, 3, -5, 4, -3, -5, 1, 4, -3, 1, -1, 2, 2, 2, -1, 3, 3, -4, 1, -5, 3, 0, -1, -1, -4, -3, 3, 1, -5, -5, -2, -2, 1, -4, -2, 4, -3, 1, -3, 1, 2, -3, -4, -4, 0, -5, -4, -1, 2, -2, 2, 2, 4, 3, -3, -5, 0, -1, 2, 1, -4, 1, 4, 4, -5, 4, 3, -1, -5, -3, -5, 2, 4, 3, -4, 1, -3, -3, -4, 3, -2, -4, 4, 2, 1, 0, -1, 1, 4, -5, -5, -2, -3, 1, -5, -5, -3, -2, 1, -1, 4, 4, -5, -4, -5, 4, -4, 1, 4, 4, -4, -5, 2, -1, -3, -1, 4, 0, 0, -4, -5, 0, 1, 0, -5, 4, 0, -1, 2, 1, -1, -5, -2, 2, -5, 1, 0, -4, 3, 0, -5, 4, 3, -2, 4, 4, 0, -3, 1, 1, 1, -2, 0, -3, -4, -3, -4, -5, 1, 0, 2, 3, 3, 3, -2, 3, 0, -2, 2, 3, 4, -5, 1, 3, -5, 1, -4, -2, 4, -3, 4, -1, 1, 1, 3, -2, 1, 4, 3, 2, 4, -5, -2, -3, 4, 1, -4, 3, 3, 4, -5, -4, 0, -4, -4, 1, 4, -2, 0, 0, -4, -4, 0, -5, -2, -3, -2, -1, -5, 2, -5, 4, -5, -4, 0, -3, 0, 3, 4, 0, -2, -2, 2, 4, -4, -3, 3, 2, 3, 0, -4, 1, -3, -1, -3, -4, -1, -5, 0, -3, 0, -5, 2, -3, -4, -3, 3, -1, -3, 0, 0, -4, -1, -2, -2, 2, -4, 1, -5, 1, -2, 0, 2, -5, 2, -5, -3, -3, -2, 2, 4, 3, 3, -4, 0, 2, -3, -1, 1, -3, 0, 1, 4, -2, 3, 2, 2, 4, -3, 2, 3, 0, 1, -3, -4, -3, 0, -4, 0, -3, -1, -3, -5, -2, 4, 4, 3, -3, 0, 3, 2, -2, -3, 2, -4, -2, -5, -5, -2, -3, -5, -4, -2, 0, 2, -5, 1, -3, -4, -4, -2, -5, 3, 1, 3, 2, 4, 3, 3, 2, 2, -5, 1, 4, -5, -1, 4, -2, -2, -3, 3, -3, 1, -5, 3, 0, 2, 1, -1, 3, 4, 4, -5, 3, -3, -3, 3, -2, -4, -2, 1, -3, -3, -4, 4, -4, 4, -1, -5, 0, 3, -5, 3, 3, -3, -2, -5, -3, -3, 3, 1, -4, -1, 0, -2, -4, -2, -2, 1, 1, -2, -1, -2, -3, -5, 4, 2, -2, 0, 3, 2, -5, -2, -4, 0, -3, -3, 4, 0, -3, -1, -4, -4, -1, -2, -2, 2, 2, -3, -1, -4, 2, 1, 2, 4, 3, -3, -2, 2, -5, -3, 4, 1, 4, 2, 4, 4, 4, 2, -2, 1, -2, -1, 3, -4, 3, -4, -2, -4, 1, -5, -2, -5, -5, 1, -4, 0, 4, -5, 0, -3, 4, -3, 0, -4, -2, -3, -1, -4, 0, 2, -4, -3, -3, -4, 1, 2, 3, 0, 2, -4, -1, 2, 2, 4, -1, -4, -2, -2, 1, 3, 1, -3, -4, 1, -2, 0, -5, 2, 3, -1, -3, -1, 2, 3, 1, -2, -4, -1, 0, -5, -4, 4, 4, 2, -2, -4, -5, 4, -3, -1, 4, -4, 4, 3, 1, 1, -4, 4, -1, 4, 1, -4, 4, -2, 3, 3, 2, -1, -1, 4, 4, 2, 0, -1, 2, -3, 2, 2, -2, -2, 3, 0, 2, 2, 0, 4, -3, 2, 4, -4, 3, 3, 0, 0, 1, -5, -1, -3, 0, 3, 2, -1, 3, -4, -3, -5, -4, -4, 4, -2, 3, 3, 0, -3, -4, 0, 2, -1, 0, 0, 4, 3, 4, 2, 2, -1, -2, -4, 4, 2, -3, -2, -5, -1, -4, 2, 2, 1, -2, -1, -3, 3, 0, -1, -1, 2, 4, 4, 3, 4, -1, -1, 3, 4, 0, 1, 3, 1, 0, -3, 1, -3, 1, 0, -1, -3, -3, 1, -4, -2, -1, 0, 3, 3, -5, 4, -1, -4, 0, 2, 0, -4, 1, -5, 1, -2, 4, 4, 3, -2, 1, 4, 2, 2, -4, 0, 2, -5, 3, 1, 2, -4, -3, 4, 2, 4, 4, 0, 4, 4, -5, -1, -4, -5, -2, 2, -1, -4, -4, 0, 1, 1, -2, 4, -3, 0, 4, 4, 2, -3, -3, -3, -5, 3, -4, -1, -2, -1, 0, -1, -1, -2, 1, 2, -2, -4, 3, 1, -5, 2, -3, 4, -4, -2, 0, 2, -4, 1, -4, 3, 3, -3, 2, -5, -1, 1, -2, -2, -3, 4, 4, 3, -4, -1, 0, 2, 4, 2, -2, 4, -5, -4, 4, -2, -3, -1, 3, 0, 3, -2, -3, -5, 2, -4, 4, 3, -3, -2, -2, -5, -4, 2, -5, -2, 4, -2, -5, 0, 2, 4, 1, -5, -5, 0, -1, 0, -1, 0, 2, 0, 4, -4, 2, 0, -3, -4, -3, -1, -2, 1, -1, 3, -1, 3, 1, 0, 0, 3, 3, 4, -4, -2, -4, 2, 3, 4, 4, 2, -4, -3, 2, -2, 4, -2, -3, -3, -2, 0, 0, -3, -3, 4, -3, -5, 0, -2, -5, -3, 4, 1, -5, 2, 3, -5, -3, -4, -2, -5, -3, 0, -2, -3, 4, 3, -5, 0, 1, -5, -1, -4, 2, -1, -2, -3, -3, -2, -2, -5] }}} {{{id=259| QQ.random_element?? /// }}} {{{id=25| /// }}}

Example:  Plotting a Symbolic Expression

{{{id=50| x = var('x') f(x) = sin(3*x)*x+log(x) + 1/(x+1)^2 show(f) ///
x \ {\mapsto}\ {x \sin \left( {3 x} \right)} + \log \left( x \right) + \frac{1}{{\left( x + 1 \right)}^{2} }
}}}

Plotting functions has similar syntax to Mathematica:

{{{id=109| plot(f,(0.01,2), thickness=4) + text("Mathematica-style plotting in Sage", (1,-2), rgbcolor='black') /// }}}


NOTE: Sage also has 2d plotting that is almost identical to MATLAB's 2d plotting:

{{{id=159| import pylab as p p.figure() t = p.arange(0.01, 2.0, 0.01) s = p.sin(2 * p.pi * t) s = p.array([float(f(x)) for x in t]) P = p.plot(t, s, linewidth=4) p.xlabel('time (s)'); p.ylabel('voltage (mV)') p.title('Matlab-style plotting in Sage') p.grid(True) p.savefig('sage.png') /// }}} {{{id=110| /// }}} {{{id=73| /// }}}

Example: Fast Evaluation

{{{id=172| f(x,y,z) = sin(3*x)*x + log(x*y*z)^3 + 1/(1+y)^2 /// }}} {{{id=263| timeit('f(4.5r,3.2r,5.7r)') /// 625 loops, best of 3: 398 µs per loop }}} {{{id=74| g = f._fast_float_(x,y,z) timeit('g(4.5r,3.2r,5.7r)') /// 625 loops, best of 3: 726 ns per loop }}} {{{id=75| %python import math def g(x,y,z): return math.sin(3*x)*x + log(x*y*z)**3 + 1/(1+y)**2 /// }}} {{{id=77| timeit('g(4.5r,3.2r,5.7r)') /// 625 loops, best of 3: 7.18 µs per loop }}} {{{id=213| 7.15/.669 /// 10.6875934230194 }}} {{{id=48| /// }}} {{{id=76| /// }}}

Example: Interface with Maple and Mathematica

{{{id=83| var('x') f = sin(3*x)*x+log(x) + 1/(x+1)^2 show(integrate(f)) ///
\frac{\sin \left( {3 x} \right) - {{3 x} \cos \left( {3 x} \right)}}{9} + {x \log \left( x \right)} - \frac{1}{x + 1} - x
}}}

The command maple(...) fires up Maple (if you have it!), and creates a reference to a live object:

{{{id=0| m = maple(f); m /// sin(3*x)*x+ln(x)+1/(x+1)^2 }}} {{{id=89| type(m) /// }}} {{{id=90| m.parent() /// Maple }}} {{{id=91| m.parent().pid() /// 67798 }}} {{{id=92| os.system('ps ax |grep 24038') /// 67818 s001 S+ 0:00.00 sh -c ps ax |grep 24038 67820 s001 R+ 0:00.00 grep 24038 0 }}}

Use Maple objects via a Pythonic notation:

{{{id=88| show(m.integrate('x')) ///
1/9\,\sin \left( 3\,x \right) -1/3\,\cos \left( 3\,x \right) x+\ln \left( x \right) x-x- \left( x+1 \right) ^{-1}
}}} {{{id=42| mathematica(f).Integrate(x) /// -x - (1 + x)^(-1) - (x*Cos[3*x])/3 + x*Log[x] + Sin[3*x]/9 }}} {{{id=43| /// }}}

Example: Interactive Image Compression

This illustrates pylab (matplotlib + numpy), Sage plotting, html output, and @interact.

{{{id=97| # first just play import pylab A = pylab.imread(DATA + 'simons.png') graphics_array([matrix_plot(A), matrix_plot(A[0:,0:,1]*A[0:,0:,1])]).show(figsize=[10,4]) /// }}} {{{id=174| A[0,0,] /// array([ 0.03529412, 0.04705882, 0.01960784, 1. ], dtype=float32) }}} {{{id=44| import pylab A_image = pylab.mean(pylab.imread(DATA + 'simons.png'), 2) @interact def svd_image(i=(20,(1..100)), j=[1..30], display_axes=True, m=matrix(QQ,2,2), color=Color('red'), f=sin(x^2)): u,s,v = pylab.linalg.svd(A_image) A = sum(s[j]*pylab.outer(u[0:,j], v[j,0:]) for j in range(i)) g = graphics_array([matrix_plot(A),matrix_plot(A_image)]) show(g, axes=display_axes, figsize=(8,3)) html('

Compressed using %s eigenvalues

'%i) ///
display_axes 
color 
}}} {{{id=94| /// }}} {{{id=220| /// }}}

Example: Implicit 2d Plot

{{{id=223| var("x y") @interact def foo(f = y^3 + x*y - x^2 - x, n=(10..500)): implicit_plot(f, (-2,3), (-3,3), plot_points=n, cmap='hsv').show(aspect_ratio=1) ///
}}} {{{id=55| /// }}}

Example: 3d Plots

{{{id=84| var('x,y') P = plot3d(sqrt(x^2-y^2+3), (x,-3,3), (y,-2,2), color='blue', opacity=0.7) P + sphere((0,0,0),2,color='red', aspect_ratio=[1,1,1], opacity=0.6) /// }}} {{{id=124| A = ( sphere((0,0,0), opacity=0.7) + sphere((0,1,0), color='red', opacity=0.5) + icosahedron((1,1,0), color='green') ) A.show(viewer='tachyon') /// }}} {{{id=224| # implicit_plot3d -- not yet released # (see http://trac.sagemath.org/sage_trac/ticket/5249)!! var('x,y,z') T = RDF(golden_ratio) p = (2 - (cos(x + T*y) + cos(x - T*y) + cos(y + T*z) + cos(y - T*z) + cos(z - T*x) + cos(z + T*x))) r = 4.77 implicit_plot3d(p, (-r, r), (-r, r), (-r, r), plot_points=40) /// }}}

3d plotting (using jmol) is fast even though it does not use Java3d or OpenGL or require any special signed code or drivers. 

{{{id=53| # Yoda! -- over 50,000 triangles. from scipy import io X = io.loadmat(DATA + 'yodapose.mat') from sage.plot.plot3d.index_face_set import IndexFaceSet V = X['V']; F3=X['F3']-1; F4=X['F4']-1 Y = IndexFaceSet(F3,V,color='green') + IndexFaceSet(F4,V,color='green') Y = Y.rotateX(-1) Y.show(aspect_ratio=[1,1,1], frame=False, figsize=4) html('"Use the source, Luke..."') /// "Use the source, Luke..." }}} {{{id=145| /// }}}

Example: Write Fast Code (using Cython)

 

to	sage-support 
date	Sat, Jan 31, 2009 at 11:15 AM
Hi,

I received first a MemoryError, and later on Sage reported:

uitkomst1=[]
uitkomst2=[]
eind=int((10^9+2)/(2*sqrt(3)))
print eind
for y in srange(1,eind):
 test1=is_square(3*y^2+1,True)
 test2=is_square(48*y^2+1,True)
 if test1[0] and test1[1]%3==2: uitkomst1.append((y,(2*test1[1]-1)/3))
 if test2[0] and test2[1]%3==1: uitkomst2.append((y,(2*test2[1]+1)/3))
print uitkomst1
een=sum([3*x-1 for (y,x) in uitkomst1 if 3*x-1<10^9])
print uitkomst2
twee=sum([3*x+1 for (y,x) in uitkomst2 if 3*x+1<10^9])
print een+twee

If you replace 10^9 with 10^6, the above listing works properly.

Maybe I made a mistake?

Rolandb

I rewrote Roland's code slightly so it wouldn't waste memory by constructing big lists... but the result was slow.

{{{id=150| def f_python(n): uitkomst1=[] uitkomst2=[] eind=int((n+2)/(2*sqrt(3))) print eind for y in (1..eind): test1=is_square(3*y^2+1,True) test2=is_square(48*y^2+1,True) if test1[0] and test1[1]%3==2: uitkomst1.append((y,(2*test1[1]-1)/3)) if test2[0] and test2[1]%3==1: uitkomst2.append((y,(2*test2[1]+1)/3)) print uitkomst1 een=sum(3*x-1 for (y,x) in uitkomst1 if 3*x-1<10^9) print uitkomst2 twee=sum(3*x+1 for (y,x) in uitkomst2 if 3*x+1<10^9) print een+twee /// }}} {{{id=182| time f_python(10^5) /// 28868 [(1, 1), (15, 17), (209, 241), (2911, 3361)] [(1, 5), (14, 65), (195, 901), (2716, 12545)] 51408 Time: CPU 0.72 s, Wall: 0.77 s }}} {{{id=8| time f_python(10^6) /// 288675 [(1, 1), (15, 17), (209, 241), (2911, 3361), (40545, 46817)] [(1, 5), (14, 65), (195, 901), (2716, 12545), (37829, 174725)] 716034 Time: CPU 7.14 s, Wall: 7.65 s }}}

Rewrite using CYTHON

{{{id=1| %cython from sage.all import is_square cdef extern from "math.h": long double sqrtl(long double) def f(n): uitkomst1=[] uitkomst2=[] cdef long long eind=int((n+2)/(2*sqrt(3))) cdef long long y, t for y in range(1,eind): t = sqrtl( (3*y*y + 1)) if t * t == 3*y*y + 1: uitkomst1.append((y, (2*t-1)/3)) t = sqrtl( (48*y*y + 1)) if t * t == 48*y*y + 1: uitkomst2.append((y, (2*t+1)/3)) print uitkomst1 een=sum([3*x-1 for (y,x) in uitkomst1 if 3*x-1<10^9]) print uitkomst2 twee=sum([3*x+1 for (y,x) in uitkomst2 if 3*x+1<10^9]) print een+twee /// }}} {{{id=4| time f(10^6) /// [(1L, 1L), (4L, 4L), (15L, 17L), (56L, 64L), (209L, 241L), (780L, 900L), (2911L, 3361L), (10864L, 12544L), (40545L, 46817L), (151316L, 174724L)] [(1L, 5L), (14L, 65L), (195L, 901L), (2716L, 12545L), (37829L, 174725L)] 2 Time: CPU 0.03 s, Wall: 0.03 s }}}

A speedup by a factor of 238!!

{{{id=255| 7.14/0.03 /// 238.000000000000 }}} {{{id=5| time f(10^9) /// 288675135 [(1L, 1L), (4L, 4L), (15L, 17L), (56L, 64L), (209L, 241L), (780L, 900L), (2911L, 3361L), (10864L, 12544L), (40545L, 46817L), (151316L, 174724L), (564719L, 652081L), (2107560L, 2433600L), (7865521L, 9082321L), (29354524L, 33895684L), (109552575L, 126500417L)] [(1L, 5L), (14L, 65L), (195L, 901L), (2716L, 12545L), (37829L, 174725L), (526890L, 2433601L), (7338631L, 33895685L), (102213944L, 472105985L)] 2 Time: CPU 25.60 s, Wall: 26.50 s }}} {{{id=6| /// }}} {{{id=242| /// }}} {{{id=243| /// }}}

Example: Multiply Polynomials

{{{id=245| R. = GF(997)[]; R /// Multivariate Polynomial Ring in x, y, z over Finite Field of size 997 }}} {{{id=247| show((x+y+z+3)^2) ///
x^{2} + 2 x y + y^{2} + 2 x z + 2 y z + z^{2} + 6 x + 6 y + 6 z + 9
}}} {{{id=246| f = (x+y+z+1)^20 time g = f*(f+1) /// Time: CPU 0.11 s, Wall: 0.12 s }}} {{{id=248| %magma R := PolynomialRing(GF(997),3); f := (x+y+z+1)^20; time g := f*(f+1); /// Time: 0.280 }}} {{{id=249| mf = magma(f) time g = mf*(mf+1) /// Time: CPU 0.00 s, Wall: 0.30 s }}} {{{id=250| /// }}} {{{id=151| /// }}}

Example: Compute a Groebner Bases

{{{id=228| P. = PolynomialRing(QQ,3, order='lex'); P /// Multivariate Polynomial Ring in a, b, c over Rational Field }}} {{{id=258| I = sage.rings.ideal.Katsura(P,3); show(I.gens()) ///
\left(a + 2 b + 2 c - 1, a^{2} - a + 2 b^{2} + 2 c^{2}, 2 a b + 2 b c - b\right)
}}} {{{id=227| I.groebner_basis() /// [a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c] }}}

NOTE: Sage includes Singular and is very tightly integrated with it.

{{{id=229| sage.rings.ideal.Katsura(P,3).groebner_basis('singular:std') /// [a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c] }}} {{{id=230| sage.rings.ideal.Katsura(P,3).groebner_basis('singular:slimgb') /// [a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c] }}}

NOTE: You must have Macaulay 2 installed for this to work...

{{{id=231| sage.rings.ideal.Katsura(P,3).groebner_basis('macaulay2') /// [a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c] }}} {{{id=232| sage.rings.ideal.Katsura(P,3).groebner_basis('magma') /// [a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c] }}}

Example: Compute a Groebner Fan

{{{id=133| P. = PolynomialRing(QQ,3, order='lex'); P I = sage.rings.ideal.Katsura(P,3) /// }}} {{{id=61| F = I.groebner_fan(); F /// Groebner fan of the ideal: Ideal (a + 2*b + 2*c - 1, a^2 - a + 2*b^2 + 2*c^2, 2*a*b + 2*b*c - b) of Multivariate Polynomial Ring in a, b, c over Rational Field }}} {{{id=233| F.weight_vectors() /// [(4, 4, 1), (3, 2, 1), (5, 2, 3), (2, 1, 3), (2, 3, 5), (2, 3, 1), (2, 5, 3), (1, 4, 4)] }}} {{{id=108| F.render().show(axes=False) /// }}} {{{id=239| /// }}} {{{id=238| /// }}} {{{id=237| /// }}} {{{id=236| /// }}} {{{id=234| /// }}}