{{{id=1| # here is something useful: define a list of variabels x_i x = list(var('x%d' % i) for i in range(6)) /// }}} {{{id=2| x /// [x0, x1, x2, x3, x4, x5] }}} {{{id=3| # we can use this to define a polynomial ring R = PolynomialRing(QQ,x);R # another syntax we can use without defining the variables first # R. = PolynomialRing(QQ,6) /// }}} {{{id=4| # define a polynomial using the x variable poly = (x0^2-x1^2)^2 /// }}} {{{id=8| # by the way: derivative(poly,x0) /// 4*x0^3 - 4*x0*x1^2 }}} {{{id=9| I = R.ideal(poly) /// }}} {{{id=10| Ir = I.radical() /// }}} {{{id=11| Ir == I /// False }}} {{{id=12| Ir.primary_decomposition() /// [Ideal (x0 - x1) of Multivariate Polynomial Ring in x0, x1, x2, x3, x4, x5 over Rational Field, Ideal (x0 + x1) of Multivariate Polynomial Ring in x0, x1, x2, x3, x4, x5 over Rational Field] }}} {{{id=13| Ir.dimension() # one eq in 6 variables /// 5 }}}

not unexpected: we have 1 equation in 6 variables

{{{id=14| # lets do something more tricky p = matrix([[x0,x1],[x2,x3],[x4,x5]]).minors(2) /// }}} {{{id=20| p /// [-x1*x2 + x0*x3, -x1*x4 + x0*x5, -x3*x4 + x2*x5] }}} {{{id=16| Id = R.ideal(p) /// }}} {{{id=17| Id.dimension() /// 4 }}}

so only 2 of the 3 eqs are independent !

we can also start defining interestring rings from toric varieties

{{{id=18| CP4 = toric_varieties.P(4) /// }}}

as you see, simple varieties such as $\mathbb{CP}^4$ are already known to sage and can be accessed by the above command

{{{id=22| Rt = CP4.coordinate_ring(); Rt /// Multivariate Polynomial Ring in z0, z1, z2, z3, z4 over Rational Field }}}

this is the ring of homogeneous coordinates, so the $\mathbb{C}^5$ before substracting the SR ideal and identifying

{{{id=24| z0 # doesn't work /// Traceback (most recent call last): File "", line 1, in File "_sage_input_26.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ejAgIyBkb2Vzbid0IHdvcms="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/tmp/tmpdf49oC/___code___.py", line 2, in exec compile(u"z0 # doesn't work" + '\n', '', 'single') File "", line 1, in NameError: name 'z0' is not defined }}} {{{id=26| # instead try co = Rt.gens() /// }}} {{{id=27| co[0] /// z0 }}} {{{id=28| monos = CP4.divisor([5,0,0,0,0]).sections_monomials() /// }}} {{{id=29| len(monos) /// 126 }}}

we can e.g. write a polynomial as

{{{id=30| poly = monos[0] + monos[53] + monos[125]; poly /// z0^5 + z1^4*z3 + z4^5 }}}

also working:

{{{id=31| polyq = co[0]^5 + co[1]^5 + co[2]^5 + co[3]^5 + co[4]^5 - 5*co[0]*co[1]*co[2]*co[3]*co[4] /// }}}

this defines a quintic Calabi-Yau threefold which has a conifold singularity;

try changing the 5 to something else to get a smooth CY

{{{id=34| V = CP4.subscheme(polyq) # scheme is like 'submanifold' for our purpose /// }}}

we can write this in affine patches by:

{{{id=35| polyqpatch = [V.affine_patch(i) for i in range(5)] /// }}} {{{id=37| polyqpatch[0].defining_polynomials() /// (z1^5 + z2^5 + z3^5 + z4^5 - 5*z1*z2*z3*z4 + 1,) }}} {{{id=44| eq = polyqpatch[0].defining_polynomials()[0] /// }}}

lets see if this is singular; the partial derivatives are

{{{id=38| Jac = [polyqpatch[0].Jacobian_matrix()[0][i] for i in range(4)]; Jac /// [5*z1^4 - 5*z2*z3*z4, 5*z2^4 - 5*z1*z3*z4, 5*z3^4 - 5*z1*z2*z4, 5*z4^4 - 5*z1*z2*z3] }}}

we want

{{{id=51| R = polyqpatch[0].coordinate_ring(); R /// Quotient of Multivariate Polynomial Ring in z1, z2, z3, z4 over Rational Field by the ideal (z1^5 + z2^5 + z3^5 + z4^5 - 5*z1*z2*z3*z4 + 1) }}}

this is the coordinate Ring of the Calabi-Yau embedded in $\mathbb{CP}^4$ for the patch $z_0 =1$

{{{id=52| I = R.ideal(Jac) /// }}} {{{id=54| I.dimension() /// 0 }}}

dimension 0 means there are points on which all equations in Jac plus the defining equation vanish, so we have a singularity.

if all these 5 equations are independen, the dimension is -1

quicker:

{{{id=48| V.is_smooth() /// False }}} {{{id=55| /// }}}