Singular.jl example

Example for Singular.jl

In [1]:
using Singular

Welcome to Nemo version 0.16.4-dev

Nemo comes with absolutely no warranty whatsoever



Generate an integer polynomial ring

In [2]:
R, ( x, y, z ) = PolynomialRing( ZZ, [ "x", "y", "z" ] )

Out[2]:
(Singular Polynomial Ring (ZZ),(x,y,z),(dp(3),C), spoly{n_Z}[x, y, z])

Create some polynomials

In [3]:
p = x + y + z
q = x + y^2 + z^3
r = x^3 + y^3 + z^3

Out[3]:
x^3+y^3+z^3

Create an ideal containing the polynomials p,q,r

In [4]:
ideal = Ideal( R, [ p, q, r ] )

Out[4]:
Singular Ideal over Singular Polynomial Ring (ZZ),(x,y,z),(dp(3),C) with generators (x+y+z, z^3+y^2+x, x^3+y^3+z^3)

Compute a standard basis of the ideal

In [5]:
basis = std( ideal )

Out[5]:
Singular Ideal over Singular Polynomial Ring (ZZ),(x,y,z),(dp(3),C) with generators (x+y+z, z^3+y^2-y-z, 3*y^2*z+3*y*z^2, 3*y^4-6*y^3+3*y*z^2+3*y^2+3*y*z)

Compute the ideal of leading monomials of basis

In [6]:
basis_lead = lead( basis )

Out[6]:
Singular Ideal over Singular Polynomial Ring (ZZ),(x,y,z),(dp(3),C) with generators (x, z^3, 3*y^2*z, 3*y^4)

Compute the syzygies of basis

In [7]:
basis_syzygies = syz( basis )

Out[7]:
Singular Module over Singular Polynomial Ring (ZZ),(x,y,z),(dp(3),C), with Generators:
3*y^2*gen(2)+3*y*z*gen(2)-z^2*gen(3)-y*gen(3)-3*y*gen(2)+z*gen(3)-gen(4)+2*gen(3)
y^2*gen(3)-y*z*gen(3)-3*y*z*gen(2)+z^2*gen(3)-y*gen(3)-z*gen(4)+z*gen(3)
z^3*gen(1)+y^2*gen(1)-x*gen(2)-y*gen(2)-y*gen(1)-z*gen(2)-z*gen(1)
3*y^2*z*gen(1)+3*y*z^2*gen(1)-x*gen(3)-y*gen(3)-z*gen(3)
3*y^4*gen(1)-6*y^3*gen(1)+3*y*z^2*gen(1)+3*y^2*gen(1)+3*y*z*gen(1)-x*gen(4)-y*gen(4)-z*gen(4)

Compute the standard basis of the syzygies

In [8]:
std_syzygies = std( basis_syzygies )

Out[8]:
Singular Module over Singular Polynomial Ring (ZZ),(x,y,z),(dp(3),C), with Generators:
3*y^2*gen(2)+3*y*z*gen(2)-z^2*gen(3)-y*gen(3)-3*y*gen(2)+z*gen(3)-gen(4)+2*gen(3)
y^2*gen(3)-y*z*gen(3)-3*y*z*gen(2)+z^2*gen(3)-y*gen(3)-z*gen(4)+z*gen(3)
z^3*gen(1)+y^2*gen(1)-x*gen(2)-y*gen(2)-y*gen(1)-z*gen(2)-z*gen(1)
3*y^2*z*gen(1)+3*y*z^2*gen(1)-x*gen(3)-y*gen(3)-z*gen(3)
3*y^4*gen(1)-6*y^3*gen(1)+3*y*z^2*gen(1)+3*y^2*gen(1)+3*y*z*gen(1)-x*gen(4)-y*gen(4)-z*gen(4)

Use a polynomial ring over a Nemo number field

In [9]:
import Nemo
R, t = Nemo.PolynomialRing(Nemo.QQ, "t")
K, a = Nemo.NumberField(t^3 + 3t + 1, "a")
S, (x, y, z) = PolynomialRing(K, ["x", "y", "z"])

Out[9]:
(Singular Polynomial Ring (Coeffs(19)),(x,y,z),(dp(3),C), spoly{Singular.n_unknown{Nemo.nf_elem}}[x, y, z])

Create some polynomials

In [10]:
p = x + a^2*y + a*z
q = x + 2*a*y^2 + (a^2+a)*z^3
r = x^3 + y^3 + a*z^3

Out[10]:
x^3+y^3+(a)*z^3

Create an ideal containing the polynomials p,q,r

In [11]:
ideal = Ideal( S, [ p, q, r ] )

Out[11]:
Singular Ideal over Singular Polynomial Ring (Coeffs(19)),(x,y,z),(dp(3),C) with generators (x+(a^2)*y+(a)*z, (a^2 + 1*a)*z^3+(2*a)*y^2+x, x^3+y^3+(a)*z^3)

Compute a standard basis of the ideal

In [12]:
basis = std( ideal )

Out[12]:
Singular Ideal over Singular Polynomial Ring (Coeffs(19)),(x,y,z),(dp(3),C) with generators (x+(a^2)*y+(a)*z, z^3+(2//3*a^2 - 2//3*a + 8//3)*y^2+(1//3*a^2 - 1//3*a + 1//3)*y+(-1//3*a^2 + 1//3*a - 4//3)*z, y^3+(-6//35*a^2 - 31//35*a - 9//35)*y^2*z+(9//35*a^2 - 6//35*a - 4//35)*y*z^2+(2//7*a^2 - 4//21*a + 16//21)*y^2+(2//21*a^2 + 1//21*a + 1//7)*y+(-1//7*a^2 + 2//21*a - 8//21)*z)