Path: blob/master/src/sage/schemes/elliptic_curves/ell_padic_field.py
8820 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].4142EXAMPLES::4344sage: Qp=pAdicField(17)45sage: E=EllipticCurve(Qp,[2,3]); E46Elliptic Curve defined by y^2 = x^3 + (2+O(17^20))*x + (3+O(17^20)) over 17-adic Field with capped relative precision 2047sage: E == loads(dumps(E))48True49"""50if y is None:51if isinstance(x, list):52ainvs = x53field = ainvs[0].parent()54else:55if isinstance(y, str):56field = x57X = sage.databases.cremona.CremonaDatabase()[y]58ainvs = [field(a) for a in X.a_invariants()]59else:60field = x61ainvs = y62if not (isinstance(field, ring.Ring) and isinstance(ainvs,list)):63raise TypeError6465EllipticCurve_field.__init__(self, [field(x) for x in ainvs])6667self._point = ell_point.EllipticCurvePoint_field68self._genus = 16970def frobenius(self, P=None):71"""72Returns the Frobenius as a function on the group of points of73this elliptic curve.7475EXAMPLE::7677sage: Qp=pAdicField(13)78sage: E=EllipticCurve(Qp,[1,1])79sage: type(E.frobenius())80<type 'function'>81sage: point=E(0,1)82sage: E.frobenius(point)83(0 : 1 + O(13^20) : 1 + O(13^20))84"""85try:86_frob = self._frob87except AttributeError:88K = self.base_field()89p = K.prime()90x = PolynomialRing(K, 'x').gen(0)9192a1, a2, a3, a4, a6 = self.a_invariants()93if a1 != 0 or a2 != 0:94raise NotImplementedError, "Curve must be in weierstrass normal form."9596f = x*x*x + a2*x*x + a4*x + a697h = (f(x**p) - f**p)9899# internal function: I don't know how to doctest it...100def _frob(P):101x0 = P[0]102y0 = P[1]103uN = (1 + h(x0)/y0**(2*p)).sqrt()104yres=y0**p * uN105xres=x0**p106if (yres-y0).valuation() == 0:107yres=-yres108return self.point([xres,yres, K(1)])109110self._frob = _frob111112if P is None:113return _frob114else:115return _frob(P)116117118