Path: blob/master/src/sage/schemes/toric/weierstrass_higher.py
8820 views
r"""1Weierstrass for Elliptic Curves in Higher Codimension23The :mod:`~sage.schemes.toric.weierstrass` module lets you transform a4genus-one curve, given as a hypersurface in a toric surface, into5Weierstrass form. The purpose of this module is to extend this to6higher codimension subschemes of toric varieties. In general, this is7an unsolved problem. However, for certain special cases this is known.89The simplest codimension-two case is the complete intersection of two10quadratic equations in `\mathbb{P}^3` ::1112sage: R.<w,x,y,z> = QQ[]13sage: quadratic1 = w^2+x^2+y^214sage: quadratic2 = z^2 + w*x15sage: WeierstrassForm([quadratic1, quadratic2])16(-1/4, 0)1718Hence, the Weierstrass form of this complete intersection is $Y^2 =19X^3 - \frac{1}{4} X Z^4$.20"""2122#*****************************************************************************23# Copyright (C) 2012 Volker Braun <[email protected]>24#25# Distributed under the terms of the GNU General Public License (GPL)26# as published by the Free Software Foundation; either version 2 of27# the License, or (at your option) any later version.28# http://www.gnu.org/licenses/29#*****************************************************************************3031from sage.rings.all import PolynomialRing32from sage.rings.invariant_theory import invariant_theory33from sage.schemes.toric.weierstrass import (34_check_homogeneity, _extract_coefficients )353637######################################################################38def WeierstrassForm2(polynomial, variables=None, transformation=False):39r"""40Helper function for :func:`~sage.schemes.toric.weierstrass.WeierstrassForm`4142Currently, only the case of the complete intersection of two43quadratic equations in `\mathbb{P}^3` is supported.4445INPUT / OUTPUT:4647See :func:`~sage.schemes.toric.weierstrass.WeierstrassForm`4849TESTS::5051sage: from sage.schemes.toric.weierstrass_higher import WeierstrassForm252sage: R.<w,x,y,z> = QQ[]53sage: quadratic1 = w^2+x^2+y^254sage: quadratic2 = z^2 + w*x55sage: WeierstrassForm2([quadratic1, quadratic2])56(-1/4, 0)57"""58if transformation:59return WeierstrassMap_P3(*polynomial, variables=variables)60else:61return WeierstrassForm_P3(*polynomial, variables=variables)626364######################################################################65#66# Weierstrass form of complete intersection of two quadratics in P^367#68######################################################################69def _check_polynomials_P3(quadratic1, quadratic2, variables):70"""71Check that the polynomial is weighted homogeneous in standard variables.7273INPUT:7475- ``quadratic1``, ``quadratic2`` -- two quadratic polynomials in 476homogeneous or 3 inhomogeneous variables.7778- ``variables`` -- the variables or ``None`` (default).7980OUTPUT:8182This function returns ``variables``, potentially guessed from the83polynomial ring. A ``ValueError`` is raised if the polynomial is84not homogeneous.8586EXAMPLES:8788sage: from sage.schemes.toric.weierstrass_higher import _check_polynomials_P389sage: R.<w,x,y,z> = QQ[]90sage: quadratic = w^2+x^2+y^2+z^291sage: _check_polynomials_P3(w^2, quadratic, [w,x,y,z])92(w, x, y, z)93sage: _check_polynomials_P3(w^2, quadratic, None)94(w, x, y, z)95sage: _check_polynomials_P3(z^2, quadratic.subs(w=0), None)96(x, y, z, None)97sage: R.<w,x,y,z,t> = QQ[]98sage: quadratic = w^2+x^2+y^2+z^2 + t*(x*y+y*z+z*w+w*x)99sage: _check_polynomials_P3(w^2, quadratic, [w,x,y,z])100(w, x, y, z)101sage: _check_polynomials_P3(w^2, quadratic, [w,x,y,t])102Traceback (most recent call last):103...104ValueError: The polynomial is not homogeneous with weights (1, 1, 1, 1)105"""106if quadratic1.parent() is not quadratic2.parent():107raise ValueError('The two quadratics must be in the same polynomial ring.')108if variables is None:109from sage.misc.misc import uniq110variables = uniq(quadratic1.variables() + quadratic2.variables())111variables.reverse()112if len(variables) == 4:113w, x, y, z = variables114_check_homogeneity(quadratic1, [w, x, y, z], (1, 1, 1, 1), 2)115_check_homogeneity(quadratic2, [w, x, y, z], (1, 1, 1, 1), 2)116elif len(variables) == 3:117w, x, y = variables118z = None119else:120raise ValueError('Need three or four variables, got '+str(variables))121return (w, x, y, z)122123124125######################################################################126def _biquadratic_syzygy_quartic(quadratic1, quadratic2, variables=None):127r"""128Helper function for the Weierstrass form of a biquadratic in $`\mathbb{P}^3$129130The invariants and covariants of a quaternary biquadratic satisfy131the relation132:meth:`sage.rings.invariant_theory.TwoQuaternaryQuadratics.syzygy`,133which is (modulo the two quadratic equations) of the form $J^2 =134p_4(T, T')$ where135136* $J$, $T$, $T'$ are the covariants of the biquadratic.137138* $p_4$ is some quartic polynomial whose coefficients are139invariants of the biquadratic.140141INPUT:142143See :func:`WeierstrassForm_P3`144145OUTPUT:146147A triple consisting of148149- The quaternary biquadratic as an algebraic form150:class:`~sage.rings.invariant_theory.TwoQuaternaryQuadratics`151152- The binary quartic $p_4$ as a153:class:`~sage.rings.invariant_theory.BinaryQuartic`154155- The dictionary of variable substitutions from the variables of156the quartic to the variables of the biquadratic.157158EXAMPLES::159160sage: from sage.schemes.toric.weierstrass_higher import _biquadratic_syzygy_quartic161sage: R.<w,x,y,z> = QQ[]162sage: _biquadratic_syzygy_quartic(w^2+x^2+y^2, z^2)163(Joint quaternary quadratic with coefficients (1, 1, 1, 0, 0, 0, 0, 0, 0, 0)164and quaternary quadratic with coefficients (0, 0, 0, 1, 0, 0, 0, 0, 0, 0),165Binary quartic with coefficients (0, 0, 0, -1, 0), {aux...})166"""167w, x, y, z = _check_polynomials_P3(quadratic1, quadratic2, variables)168biquadratic = invariant_theory.quaternary_biquadratic(quadratic1, quadratic2, [w, x, y, z])169170# construct auxiliary polynomial ring to work with the rhs of the syzygy171R = biquadratic.ring()172n = R.ngens()173R_aux = PolynomialRing(R.base_ring(), n+2, 'aux')174to_aux = dict()175from_aux = dict()176for var, var_aux in zip(R.gens(), R_aux.gens()[0:n]):177to_aux[var] = var_aux178from_aux[var_aux] = var179T, T_prime = R_aux.gens()[n:]180from_aux[T] = biquadratic.T_covariant()181from_aux[T_prime] = biquadratic.T_prime_covariant()182183# Syzygy is J^2 = syz_rhs + (terms that vanish on the biquadratic) with184# J = biquadratic.J_covariant()185syz_rhs = T**4 * biquadratic.Delta_invariant().subs(to_aux) \186- T**3*T_prime * biquadratic.Theta_invariant().subs(to_aux) \187+ T**2*T_prime**2 * biquadratic.Phi_invariant().subs(to_aux) \188- T*T_prime**3 * biquadratic.Theta_prime_invariant().subs(to_aux) \189+ T_prime**4 * biquadratic.Delta_prime_invariant().subs(to_aux)190quartic = invariant_theory.binary_quartic(syz_rhs, [T, T_prime])191return (biquadratic, quartic, from_aux)192193194######################################################################195def WeierstrassForm_P3(quadratic1, quadratic2, variables=None):196r"""197Bring a complete intersection of two quadratics into Weierstrass form.198199Input/output is the same as200:func:`sage.schemes.toric.weierstrass.WeierstrassForm`, except201that the two input polynomials must be quadratic polynomials in202`\mathbb{P}^3`.203204EXAMPLES::205206sage: from sage.schemes.toric.weierstrass_higher import WeierstrassForm_P3207sage: R.<w,x,y,z> = QQ[]208sage: quadratic1 = w^2+x^2+y^2209sage: quadratic2 = z^2 + w*x210sage: WeierstrassForm_P3(quadratic1, quadratic2)211(-1/4, 0)212213TESTS::214215sage: R.<w,x,y,z,a0,a1,a2,a3,b0,b1,b2,b3,b4,b5> = QQ[]216sage: p1 = w^2 + x^2 + y^2 + z^2217sage: p2 = a0*w^2 + a1*x^2 + a2*y^2 + a3*z^2218sage: p2 += b0*x*y + b1*x*z + b2*x*w + b3*y*z + b4*y*w + b5*z*w219sage: a, b = WeierstrassForm_P3(p1, p2, [w,x,y,z])220sage: a.total_degree(), len(a.coefficients())221(4, 107)222sage: b.total_degree(), len(b.coefficients())223(6, 648)224"""225biquadratic, quartic, from_aux = \226_biquadratic_syzygy_quartic(quadratic1, quadratic2, variables=variables)227a = quartic.EisensteinD().subs(from_aux)228b = quartic.EisensteinE().subs(from_aux)229return (-4*a, 16*b)230231232######################################################################233def WeierstrassMap_P3(quadratic1, quadratic2, variables=None):234r"""235Bring a complete intersection of two quadratics into Weierstrass form.236237Input/output is the same as238:func:`sage.schemes.toric.weierstrass.WeierstrassForm`, except239that the two input polynomials must be quadratic polynomials in240`\mathbb{P}^3`.241242EXAMPLES::243244sage: from sage.schemes.toric.weierstrass_higher import \245....: WeierstrassMap_P3, WeierstrassForm_P3246sage: R.<w,x,y,z> = QQ[]247sage: quadratic1 = w^2+x^2+y^2248sage: quadratic2 = z^2 + w*x249sage: X, Y, Z = WeierstrassMap_P3(quadratic1, quadratic2)250sage: X2511/1024*w^8 + 3/256*w^6*x^2 + 19/512*w^4*x^4 + 3/256*w^2*x^6 + 1/1024*x^8252sage: Y2531/32768*w^12 - 7/16384*w^10*x^2 - 145/32768*w^8*x^4 - 49/8192*w^6*x^6254- 145/32768*w^4*x^8 - 7/16384*w^2*x^10 + 1/32768*x^12255sage: Z256-1/8*w^2*y*z + 1/8*x^2*y*z257258sage: a, b = WeierstrassForm_P3(quadratic1, quadratic2); a, b259(-1/4, 0)260261sage: ideal = R.ideal(quadratic1, quadratic2)262sage: (-Y^2 + X^3 + a*X*Z^4 + b*Z^6).reduce(ideal)2630264265TESTS::266267sage: R.<w,x,y,z,a0,a1,a2,a3> = GF(101)[]268sage: p1 = w^2 + x^2 + y^2 + z^2269sage: p2 = a0*w^2 + a1*x^2 + a2*y^2 + a3*z^2270sage: X, Y, Z = WeierstrassMap_P3(p1, p2, [w,x,y,z])271sage: X.total_degree(), len(X.coefficients())272(22, 4164)273sage: Y.total_degree(), len(Y.coefficients())274(33, 26912)275sage: Z.total_degree(), len(Z.coefficients())276(10, 24)277sage: Z278w*x*y*z*a0^3*a1^2*a2 - w*x*y*z*a0^2*a1^3*a2 - w*x*y*z*a0^3*a1*a2^2279+ w*x*y*z*a0*a1^3*a2^2 + w*x*y*z*a0^2*a1*a2^3 - w*x*y*z*a0*a1^2*a2^3280- w*x*y*z*a0^3*a1^2*a3 + w*x*y*z*a0^2*a1^3*a3 + w*x*y*z*a0^3*a2^2*a3281- w*x*y*z*a1^3*a2^2*a3 - w*x*y*z*a0^2*a2^3*a3 + w*x*y*z*a1^2*a2^3*a3282+ w*x*y*z*a0^3*a1*a3^2 - w*x*y*z*a0*a1^3*a3^2 - w*x*y*z*a0^3*a2*a3^2283+ w*x*y*z*a1^3*a2*a3^2 + w*x*y*z*a0*a2^3*a3^2 - w*x*y*z*a1*a2^3*a3^2284- w*x*y*z*a0^2*a1*a3^3 + w*x*y*z*a0*a1^2*a3^3 + w*x*y*z*a0^2*a2*a3^3285- w*x*y*z*a1^2*a2*a3^3 - w*x*y*z*a0*a2^2*a3^3 + w*x*y*z*a1*a2^2*a3^3286"""287biquadratic, quartic, from_aux = \288_biquadratic_syzygy_quartic(quadratic1, quadratic2, variables=variables)289J = biquadratic.J_covariant()290g = quartic.g_covariant().subs(from_aux)291h = quartic.h_covariant().subs(from_aux)292return (4*g, 4*h, J)293294295296