This interface is extremely flexible, since it's exactly like typing into the Singular interpreter, and anything that works there should work here. Unfortunately, it's sometimes much slower than using C-library calls.
pexpect
module must be installed, which is not standard
with Python (but is included with SAGE), and the singular
command
must be in your path.
AUTHORS: David Joyner and William Stein
sage: import sage.interfaces.singular as sing sage: Sing = sing.SING()
First we illustrate multivariate polynomial factorization.
sage: i1="ring r1 = 0,(x,y),dp; r1;" sage: i2="poly f = 9x16-18x13y2-9x12y3+9x10y4-18x11y2+36x8y4+18x7y5-18x5y6+9x6y4-18x3y6-9x2y7+9y8; f;" sage: i3="list L=factorize(f); L;" sage: o1 = Sing(i1); o2 = Sing(i2); o3 = Sing(i3) sage: print o1 // characteristic : 0 // number of vars : 2 // block 1 : ordering dp // : names x y // block 2 : ordering C sage: print o2 9x16-18x13y2-9x12y3+9x10y4-18x11y2+36x8y4+18x7y5-18x5y6+9x6y4-1 8x3y6-9x2y7+9y8 sage: print o3 [1]: _[1]=9 _[2]=x6-2x3y2-x2y3+y4 _[3]=-x5+y2 [2]: 1,1,2
This example illustrates polynomial GCD's:
sage: i4 = "ring r2=0,(x,y,z),lp; r2;" sage: i5 = "poly g=gcd(3x2*(x+y),9x*(y2-x2)); g;" sage: o4 = Sing(i4); o5 = Sing(i5) sage: print o4 // characteristic : 0 // number of vars : 3 // block 1 : ordering lp // : names x y z // block 2 : ordering C sage: print o5 x2+xy
This example illustrates computation of a Groebner basis:
sage: i6 = "ring r3=0,(a,b,c,d),lp; r3;" sage: i7 = "ideal i=a+b+c+d,ab+ad+bc+cd,abc+abd+acd+bcd,abcd-1; i;" sage: i8 = "ideal i2=groebner(i);i2;" sage: o6 = Sing(i6); o7 = Sing(i7); o8 = Sing(i8) sage: print o6 // characteristic : 0 // number of vars : 4 // block 1 : ordering lp // : names a b c d // block 2 : ordering C sage: print o7 i[1]=a+b+c+d i[2]=ab+ad+bc+cd i[3]=abc+abd+acd+bcd i[4]=abcd-1 sage: print o8 i2[1]=c2d6-c2d2-d4+1 i2[2]=c3d2+c2d3-c-d i2[3]=bd4-b+d5-d i2[4]=bc-bd5+c2d4+cd-d6-d2 i2[5]=b2+2bd+d2 i2[6]=a+b+c+d
Here is another example, which is the same as the one in the gap interface documentation:
sage: i9="ring R=0,(x0,x1,x2),lp; R;" sage: i10="ideal I1 = [ x0*x1*x2 -x0^2*x2, x0^2*x1*x2-x0*x1^2*x2-x0*x1*x2^2, x0*x1-x0*x2-x1*x2];" sage: i11="ideal I2=groebner(I1); I2;" sage: o9 = Sing(i9); o10 = Sing(i10); o11 = Sing(i11) sage: print o9 // characteristic : 0 // number of vars : 3 // block 1 : ordering lp // : names x0 x1 x2 // block 2 : ordering C sage: print o11 I2[1]=x1^2*x2^2 I2[2]=x0*x2^3-x1^2*x2^2+x1*x2^3 I2[3]=x0*x1-x0*x2-x1*x2 I2[4]=x0^2*x2-x0*x1*x2
The module interfaces.singular defines the following classes: