Path: blob/master/sage/schemes/elliptic_curves/ell_padic_field.py
4159 views
"""1Elliptic curves over padic fields2"""34#*****************************************************************************5# Copyright (C) 2007 Robert Bradshaw <[email protected]>6# William Stein <[email protected]>7#8# Distributed under the terms of the GNU General Public License (GPL)9#10# This code is distributed in the hope that it will be useful,11# but WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13# General Public License for more details.14#15# The full text of the GPL is available at:16#17# http://www.gnu.org/licenses/18#*****************************************************************************192021import sage.rings.ring as ring22from ell_field import EllipticCurve_field23import ell_point24from sage.rings.all import PolynomialRing2526# Elliptic curves are very different than genus > 1 hyperelliptic curves,27# there is an "is a" relationship here, and common implementation with regard28# Coleman integration.29from sage.schemes.hyperelliptic_curves.hyperelliptic_padic_field import HyperellipticCurve_padic_field3031import sage.databases.cremona323334class EllipticCurve_padic_field(EllipticCurve_field, HyperellipticCurve_padic_field):35"""36Elliptic curve over a padic field.37"""38def __init__(self, x, y=None):39"""40Constructor from [a1,a2,a3,a4,a6] or [a4,a6].41EXAMPLES:42sage: Qp=pAdicField(17)43sage: E=EllipticCurve(Qp,[2,3]); E44Elliptic Curve defined by y^2 = x^3 + (2+O(17^20))*x + (3+O(17^20)) over 17-adic Field with capped relative precision 2045sage: E == loads(dumps(E))46True47"""48if y is None:49if isinstance(x, list):50ainvs = x51field = ainvs[0].parent()52else:53if isinstance(y, str):54field = x55X = sage.databases.cremona.CremonaDatabase()[y]56ainvs = [field(a) for a in X.a_invariants()]57else:58field = x59ainvs = y60if not (isinstance(field, ring.Ring) and isinstance(ainvs,list)):61raise TypeError6263EllipticCurve_field.__init__(self, [field(x) for x in ainvs])6465self._point = ell_point.EllipticCurvePoint_field66self._genus = 16768def frobenius(self, P=None):69"""70Returns the Frobenius as a function on the group of points of71this elliptic curve.7273EXAMPLE:74sage: Qp=pAdicField(13)75sage: E=EllipticCurve(Qp,[1,1])76sage: type(E.frobenius())77<type 'function'>78sage: point=E(0,1)79sage: E.frobenius(point)80(0 : 1 + O(13^20) : 1 + O(13^20))81"""82try:83_frob = self._frob84except AttributeError:85K = self.base_field()86p = K.prime()87x = PolynomialRing(K, 'x').gen(0)8889a1, a2, a3, a4, a6 = self.a_invariants()90if a1 != 0 or a2 != 0:91raise NotImplementedError, "Curve must be in weierstrass normal form."9293f = x*x*x + a2*x*x + a4*x + a694h = (f(x**p) - f**p)9596# internal function: I don't know how to doctest it...97def _frob(P):98x0 = P[0]99y0 = P[1]100uN = (1 + h(x0)/y0**(2*p)).sqrt()101yres=y0**p * uN102xres=x0**p103if (yres-y0).valuation() == 0:104yres=-yres105return self.point([xres,yres, K(1)])106107self._frob = _frob108109if P is None:110return _frob111else:112return _frob(P)113114115