Path: blob/master/src/sage/schemes/elliptic_curves/sha_tate.py
8820 views
# -*- coding: utf-8 -*-1r"""2Tate-Shafarevich group34If `E` is an elliptic curve over a global field `K`, the Tate-Shafarevich group5is the subgroup of elements in `H^1(K,E)` which map to zero under every global-to-local6restriction map `H^1(K,E) \to H^1(K_v,E)`, one for each place `v`7of `K`.89The group is usually denoted by the Russian letter Sha (Ш), in this document it will be denoted by `Sha`.1011`Sha` is known to be an abelian torsion group. It is conjectured that the Tate-Shafarevich group is finite for any elliptic curve over a global field. But it is not known in general.1213A theorem of Kolyvagin and Gross-Zagier using Heegner points shows that if the L-series of an elliptic curve `E/\QQ` does not14vanish at 1 or has a simple zero there, then `Sha` is finite.1516A theorem of Kato, together with theorems from Iwasawa theory, allow for certain primes `p` to show that the `p`-primary part of `Sha` is finite and gives an effective upper bound for it.1718The (`p`-adic) conjecture of Birch and Swinnerton-Dyer predicts the order of `Sha` from the leading term of the (`p`-adic) L-series of the elliptic curve.1920Sage can compute a few things about `Sha`. The commands ``an``,21``an_numerical`` and ``an_padic`` compute the conjectural order of `Sha`22as a real or `p`-adic number. With ``p_primary_bound`` one can find an23upper bound of the size of the `p`-primary part of `Sha`. Finally, if24the analytic rank is at most 1, then ``bound_kato`` and25``bound_kolyvagin`` find all primes for which the theorems of Kato26and Kolyvagin respectively do not prove the triviality the `p`-primary27part of `Sha`.2829EXAMPLES::3031sage: E = EllipticCurve('11a1')32sage: S = E.sha()33sage: S.bound_kato()34[2, 3, 5]35sage: S.bound_kolyvagin()36([2, 5], 1)37sage: S.an_padic(7,3)381 + O(7^5)39sage: S.an()40141sage: S.an_numerical()421.000000000000004344sage: E = EllipticCurve('389a')45sage: S = E.sha(); S46Tate-Shafarevich group for the Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field47sage: S.an_numerical()481.0000000000000049sage: S.p_primary_bound(5)50051sage: S.an_padic(5)521 + O(5)53sage: S.an_padic(5,prec=4) # long time (2s on sage.math, 2011)541 + O(5^3)555657AUTHORS:5859- William Stein (2007) -- initial version6061- Chris Wuthrich (April 2009) -- reformat docstrings6263"""64#*****************************************************************************65# Copyright (C) 2007 William Stein <[email protected]>66#67# Distributed under the terms of the GNU General Public License (GPL)68# as published by the Free Software Foundation; either version 2 of69# the License, or (at your option) any later version.70# http://www.gnu.org/licenses/71#*****************************************************************************7273from sage.structure.sage_object import SageObject74from sage.rings.all import (75Integer,76RealField,77RationalField,78RIF,79ZZ)80from sage.misc.functional import log81from math import sqrt82from sage.misc.all import verbose83import sage.rings.arith as arith84from sage.rings.padics.factory import Qp8586factor = arith.factor87valuation = arith.valuation88Q = RationalField()8990class Sha(SageObject):91r"""92The Tate-Shafarevich group associated to an elliptic curve.9394If `E` is an elliptic curve over a global field `K`, the Tate-Shafarevich group95is the subgroup of elements in `H^1(K,E)` which map to zero under every global-to-local96restriction map `H^1(K,E) \to H^1(K_v,E)`, one for each place `v`97of `K`.9899EXAMPLES::100101sage: E = EllipticCurve('571a1')102sage: E._set_gens([])103sage: S = E.sha()104sage: S.bound_kato()105[2, 3]106sage: S.bound_kolyvagin()107([2], 1)108sage: S.an_padic(7,3)1094 + O(7^5)110sage: S.an()1114112sage: S.an_numerical()1134.00000000000000114115sage: E = EllipticCurve('389a')116sage: S = E.sha(); S117Tate-Shafarevich group for the Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field118sage: S.an_numerical()1191.00000000000000120sage: S.p_primary_bound(5) # long time1210122sage: S.an_padic(5) # long time1231 + O(5)124sage: S.an_padic(5,prec=4) # long time1251 + O(5^3)126"""127def __init__(self, E):128r"""129The Tate-Shafarevich group associated to an elliptic curve.130131INPUT:132133- E -- an elliptic curve over `\QQ`134135EXAMPLES::136137sage: E = EllipticCurve('11a1')138sage: S = E.sha()139sage: S140Tate-Shafarevich group for the Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field141142sage: S == loads(dumps(S))143True144"""145self.E = E146self.Emin = E.minimal_model() if not E.is_minimal() else E147148def __cmp__(self,other):149r"""150Compares two Tate-Shafarevich groups by simply comparing the elliptic curves.151152EXAMPLES::153154sage: E = EllipticCurve('37a1')155sage: S = E.sha()156sage: S == S157True158"""159c = cmp(type(self), type(other))160if c:161return c162return cmp(self.E, other.E)163164def __repr__(self):165r"""166String representation of the Tate-Shafarevich group.167168EXAMPLES::169170sage: E = EllipticCurve('11a1')171sage: S = E.sha()172sage: S.__repr__()173'Tate-Shafarevich group for the Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field'174175"""176return "Tate-Shafarevich group for the " + repr(self.E)177178########################################################################179# Functions related to the BSD conjecture.180########################################################################181182def an_numerical(self, prec = None,183use_database=True, proof=None):184r"""185Return the numerical analytic order of `Sha`, which is186a floating point number in all cases.187188INPUT:189190- ``prec`` - integer (default: 53) bits precision -- used191for the L-series computation, period, regulator, etc.192- ``use_database`` - whether the rank and generators should193be looked up in the database if possible. Default is ``True``194- ``proof`` - bool or ``None`` (default: ``None``, see proof.[tab] or195sage.structure.proof) proof option passed196onto regulator and rank computation.197198.. note::199200See also the :meth:`an` command, which will return a201provably correct integer when the rank is 0 or 1.202203.. WARNING::204205If the curve's generators are not known, computing206them may be very time-consuming. Also, computation of the207L-series derivative will be time-consuming for large rank and208large conductor, and the computation time for this may209increase substantially at greater precision. However, use of210very low precision less than about 10 can cause the underlying211PARI library functions to fail.212213EXAMPLES::214215sage: EllipticCurve('11a').sha().an_numerical()2161.00000000000000217sage: EllipticCurve('37a').sha().an_numerical()2181.00000000000000219sage: EllipticCurve('389a').sha().an_numerical()2201.00000000000000221sage: EllipticCurve('66b3').sha().an_numerical()2224.00000000000000223sage: EllipticCurve('5077a').sha().an_numerical()2241.00000000000000225226A rank 4 curve::227228sage: EllipticCurve([1, -1, 0, -79, 289]).sha().an_numerical() # long time (3s on sage.math, 2011)2291.00000000000000230231A rank 5 curve::232233sage: EllipticCurve([0, 0, 1, -79, 342]).sha().an_numerical(prec=10, proof=False) # long time (22s on sage.math, 2011)2341.0235236See :trac:`1115`::237238sage: sha=EllipticCurve('37a1').sha()239sage: [sha.an_numerical(prec) for prec in xrange(40,100,10)] # long time (3s on sage.math, 2013)240[1.0000000000,2411.0000000000000,2421.0000000000000000,2431.0000000000000000000,2441.0000000000000000000000,2451.0000000000000000000000000]246"""247if prec is None:248prec = RealField().precision()249RR = RealField(prec)250prec2 = prec+2251RR2 = RealField(prec2)252try:253an = self.__an_numerical254if an.parent().precision() >= prec:255return RR(an)256else: # cached precision too low257pass258except AttributeError:259pass260# it's critical to switch to the minimal model.261E = self.Emin262r = Integer(E.rank(use_database=use_database, proof=proof))263L = E.lseries().dokchitser(prec=prec2)264Lr= RR2(L.derivative(1,r)) # L.derivative() returns a Complex265Om = RR2(E.period_lattice().omega(prec2))266Reg = E.regulator(use_database=use_database, proof=proof, precision=prec2)267T = E.torsion_order()268cp = E.tamagawa_product()269Sha = RR((Lr*T*T)/(r.factorial()*Om*cp*Reg))270self.__an_numerical = Sha271return Sha272273def an(self, use_database=False, descent_second_limit=12):274r"""275Returns the Birch and Swinnerton-Dyer conjectural order of `Sha`276as a provably correct integer, unless the analytic rank is > 1,277in which case this function returns a numerical value.278279INPUT:280281- ``use_database`` -- bool (default: ``False``); if ``True``, try to use any282databases installed to lookup the analytic order of `Sha`, if283possible. The order of `Sha` is computed if it cannot be looked up.284285- ``descent_second_limit`` -- int (default: 12); limit to use on286point searching for the quartic twist in the hard case287288This result is proved correct if the order of vanishing is 0289and the Manin constant is <= 2.290291If the optional parameter ``use_database`` is ``True`` (default:292``False``), this function returns the analytic order of `Sha` as293listed in Cremona's tables, if this curve appears in Cremona's294tables.295296NOTE:297298If you come across the following error::299300sage: E = EllipticCurve([0, 0, 1, -34874, -2506691])301sage: E.sha().an()302Traceback (most recent call last):303...304RuntimeError: Unable to compute the rank, hence generators, with certainty (lower bound=0, generators found=[]). This could be because Sha(E/Q)[2] is nontrivial.305Try increasing descent_second_limit then trying this command again.306307You can increase the ``descent_second_limit`` (in the above example,308set to the default, 12) option to try again::309310sage: E.sha().an(descent_second_limit=16) # long time (2s on sage.math, 2011)3111312313EXAMPLES::314315sage: E = EllipticCurve([0, -1, 1, -10, -20]) # 11A = X_0(11)316sage: E.sha().an()3171318sage: E = EllipticCurve([0, -1, 1, 0, 0]) # X_1(11)319sage: E.sha().an()3201321322sage: EllipticCurve('14a4').sha().an()3231324sage: EllipticCurve('14a4').sha().an(use_database=True) # will be faster if you have large Cremona database installed3251326327The smallest conductor curve with nontrivial `Sha`::328329sage: E = EllipticCurve([1,1,1,-352,-2689]) # 66b3330sage: E.sha().an()3314332333The four optimal quotients with nontrivial `Sha` and conductor <= 1000::334335sage: E = EllipticCurve([0, -1, 1, -929, -10595]) # 571A336sage: E.sha().an()3374338sage: E = EllipticCurve([1, 1, 0, -1154, -15345]) # 681B339sage: E.sha().an()3409341sage: E = EllipticCurve([0, -1, 0, -900, -10098]) # 960D342sage: E.sha().an()3434344sage: E = EllipticCurve([0, 1, 0, -20, -42]) # 960N345sage: E.sha().an()3464347348The smallest conductor curve of rank > 1::349350sage: E = EllipticCurve([0, 1, 1, -2, 0]) # 389A (rank 2)351sage: E.sha().an()3521.00000000000000353354The following are examples that require computation of the Mordell-Weil355group and regulator::356357sage: E = EllipticCurve([0, 0, 1, -1, 0]) # 37A (rank 1)358sage: E.sha().an()3591360361sage: E = EllipticCurve("1610f3")362sage: E.sha().an()3634364365In this case the input curve is not minimal, and if this function did not366transform it to be minimal, it would give nonsense::367368sage: E = EllipticCurve([0,-432*6^2])369sage: E.sha().an()3701371372See :trac:`10096`: this used to give the wrong result 6.0000373before since the minimal model was not used::374375sage: E = EllipticCurve([1215*1216,0]) # non-minimal model376sage: E.sha().an() # long time (2s on sage.math, 2011)3771.00000000000000378sage: E.minimal_model().sha().an() # long time (1s on sage.math, 2011)3791.00000000000000380"""381if hasattr(self, '__an'):382return self.__an383if use_database:384d = self.Emin.database_curve()385if hasattr(d, 'db_extra'):386self.__an = Integer(round(float(d.db_extra[4])))387return self.__an388389# it's critical to switch to the minimal model.390E = self.Emin391eps = E.root_number()392if eps == 1:393L1_over_omega = E.lseries().L_ratio()394if L1_over_omega == 0: # order of vanishing is at least 2395return self.an_numerical(use_database=use_database)396T = E.torsion_subgroup().order()397Sha = (L1_over_omega * T * T) / Q(E.tamagawa_product())398try:399Sha = Integer(Sha)400except ValueError:401raise RuntimeError("There is a bug in an, since the computed conjectural order of Sha is %s, which is not an integer."%Sha)402if not arith.is_square(Sha):403raise RuntimeError("There is a bug in an, since the computed conjectural order of Sha is %s, which is not a square."%Sha)404E.__an = Sha405self.__an = Sha406return Sha407408else: # rank > 0 (Not provably correct)409L1, error_bound = E.lseries().deriv_at1(10*sqrt(E.conductor()) + 10)410if abs(L1) < error_bound:411s = self.an_numerical()412E.__an = s413self.__an = s414return s415416regulator = E.regulator(use_database=use_database, descent_second_limit=descent_second_limit)417T = E.torsion_subgroup().order()418omega = E.period_lattice().omega()419Sha = Integer(round ( (L1 * T * T) / (E.tamagawa_product() * regulator * omega) ))420try:421Sha = Integer(Sha)422except ValueError:423raise RuntimeError("There is a bug in an, since the computed conjectural order of Sha is %s, which is not an integer."%Sha)424if not arith.is_square(Sha):425raise RuntimeError("There is a bug in an, since the computed conjectural order of Sha is %s, which is not a square."%Sha)426E.__an = Sha427self.__an = Sha428return Sha429430def an_padic(self, p, prec=0, use_twists=True):431r"""432Returns the conjectural order of `Sha(E/\QQ)`,433according to the `p`-adic analogue of the Birch434and Swinnerton-Dyer conjecture as formulated435in [MTT]_ and [BP]_.436437REFERENCES:438439.. [MTT] B. Mazur, J. Tate, and J. Teitelbaum, On `p`-adic440analogues of the conjectures of Birch and Swinnerton-Dyer,441Inventiones mathematicae 84, (1986), 1-48.442443.. [BP] Dominique Bernardi and Bernadette Perrin-Riou,444Variante `p`-adique de la conjecture de Birch et445Swinnerton-Dyer (le cas supersingulier),446C. R. Acad. Sci. Paris, Ser I. Math, 317 (1993), no 3,447227-232.448449.. [SW] William Stein and Christian Wuthrich, Computations450About Tate-Shafarevich Groups using Iwasawa theory,451preprint 2009.452453INPUT:454455- ``p`` - a prime > 3456457- ``prec`` (optional) - the precision used in the computation of the `p`-adic L-Series458459- ``use_twists`` (default = ``True``) - If ``True`` the algorithm may change460to a quadratic twist with minimal conductor to do the modular461symbol computations rather than using the modular symbols of the462curve itself. If ``False`` it forces the computation using the463modular symbols of the curve itself.464465OUTPUT: `p`-adic number - that conjecturally equals `\# Sha(E/\QQ)`.466467If ``prec`` is set to zero (default) then the precision is set so that468at least the first `p`-adic digit of conjectural `\# Sha(E/\QQ)` is469determined.470471EXAMPLES:472473Good ordinary examples::474475sage: EllipticCurve('11a1').sha().an_padic(5) # rank 04761 + O(5^2)477sage: EllipticCurve('43a1').sha().an_padic(5) # rank 14781 + O(5)479sage: EllipticCurve('389a1').sha().an_padic(5,4) # rank 2, long time (2s on sage.math, 2011)4801 + O(5^3)481sage: EllipticCurve('858k2').sha().an_padic(7) # rank 0, non trivial sha, long time (10s on sage.math, 2011)482Traceback (most recent call last): # 32-bit (see ticket :trac: `112111`)483... # 32-bit484OverflowError: Python int too large to convert to C long # 32-bit4857^2 + O(7^6) # 64-bit486sage: EllipticCurve('300b2').sha().an_padic(3) # 9 elements in sha, long time (2s on sage.math, 2011)4873^2 + O(3^6)488sage: EllipticCurve('300b2').sha().an_padic(7, prec=6) # long time4892 + 7 + O(7^8)490491Exceptional cases::492493sage: EllipticCurve('11a1').sha().an_padic(11) # rank 04941 + O(11^2)495sage: EllipticCurve('130a1').sha().an_padic(5) # rank 14961 + O(5)497498Non-split, but rank 0 case (:trac:`7331`)::499500sage: EllipticCurve('270b1').sha().an_padic(5) # rank 0, long time (2s on sage.math, 2011)5011 + O(5^2)502503The output has the correct sign::504505sage: EllipticCurve('123a1').sha().an_padic(41) # rank 1, long time (3s on sage.math, 2011)5061 + O(41)507508Supersingular cases::509510sage: EllipticCurve('34a1').sha().an_padic(5) # rank 05111 + O(5^2)512sage: EllipticCurve('53a1').sha().an_padic(5) # rank 1, long time (11s on sage.math, 2011)5131 + O(5)514515Cases that use a twist to a lower conductor::516517sage: EllipticCurve('99a1').sha().an_padic(5)5181 + O(5)519sage: EllipticCurve('240d3').sha().an_padic(5) # sha has 4 elements here5204 + O(5)521sage: EllipticCurve('448c5').sha().an_padic(7,prec=4, use_twists=False) # long time (2s on sage.math, 2011)5222 + 7 + O(7^6)523sage: EllipticCurve([-19,34]).sha().an_padic(5) # see :trac: `6455`, long time (4s on sage.math, 2011)5241 + O(5)525"""526try:527return self.__an_padic[(p,prec)]528except AttributeError:529self.__an_padic = {}530except KeyError:531pass532533E = self.Emin534tam = E.tamagawa_product()535tors = E.torsion_order()**2536reg = E.padic_regulator(p)537# todo : here we should cache the rank computation538r = E.rank()539540541if use_twists and p > 2:542Et, D = E.minimal_quadratic_twist()543# trac 6455 : we have to assure that the twist back is allowed544D = ZZ(D)545if D % p == 0:546D = D/p547for ell in D.prime_divisors():548if ell % 2 == 1:549if Et.conductor() % ell**2 == 0:550D = D/ell551ve = valuation(D,2)552de = (D/2**ve).abs()553if de % 4 == 3:554de = -de555Et = E.quadratic_twist(de)556# now check individually if we can twist by -1 or 2 or -2557Nmin = Et.conductor()558Dmax = de559for DD in [-4*de,8*de,-8*de]:560Et = E.quadratic_twist(DD)561if Et.conductor() < Nmin and valuation(Et.conductor(),2) <= valuation(DD,2):562Nmin = Et.conductor()563Dmax = DD564D = Dmax565Et = E.quadratic_twist(D)566lp = Et.padic_lseries(p)567else :568lp = E.padic_lseries(p)569D = 1570571if r == 0 and D == 1:572# short cut for rank 0 curves, we do not573# to compute the p-adic L-function, the leading574# term will be the L-value divided by the Neron575# period.576ms = E.modular_symbol(sign=+1, normalize='L_ratio')577lstar = ms(0)/E.real_components()578bsd = tam/tors579if prec == 0:580prec = valuation(lstar/bsd, p)581shan = Qp(p,prec=prec+2)(lstar/bsd)582583584elif E.is_ordinary(p):585K = reg.parent()586lg = log(K(1+p))587588if (E.is_good(p) or E.ap(p) == -1):589if not E.is_good(p):590eps = 2591else:592eps = (1-arith.kronecker_symbol(D,p)/lp.alpha())**2593# according to the p-adic BSD this should be equal to the leading term of the p-adic L-series divided by sha:594bsdp = tam * reg * eps/tors/lg**r595else:596r += 1 # exceptional zero597eq = E.tate_curve(p)598Li = eq.L_invariant()599600# according to the p-adic BSD (Mazur-Tate-Teitelbaum)601# this should be equal to the leading term of the p-adic L-series divided by sha:602bsdp = tam * reg * Li/tors/lg**r603604605v = bsdp.valuation()606if v > 0:607verbose("the prime is irregular.")608609# determine how much prec we need to prove at least the triviality of610# the p-primary part of Sha611612if prec == 0:613n = max(v,2)614bounds = lp._prec_bounds(n,r+1)615while bounds[r] <= v:616n += 1617bounds = lp._prec_bounds(n,r+1)618verbose("set precision to %s"%n)619else:620n = max(2,prec)621622not_yet_enough_prec = True623while not_yet_enough_prec:624lps = lp.series(n,quadratic_twist=D,prec=r+1)625lstar = lps[r]626if (lstar != 0) or (prec != 0):627not_yet_enough_prec = False628else:629n += 1630verbose("increased precision to %s"%n)631632shan = lstar/bsdp633634elif E.is_supersingular(p):635K = reg[0].parent()636lg = log(K(1+p))637638639# according to the p-adic BSD this should be equal to the leading term of the D_p - valued640# L-series :641bsdp = tam /tors/lg**r * reg642# note this is an element in Q_p^2643644verbose("the algebraic leading terms : %s"%bsdp)645646v = [bsdp[0].valuation(),bsdp[1].valuation()]647648if prec == 0:649n = max(min(v)+2,3)650else:651n = max(3,prec)652653verbose("...computing the p-adic L-series")654not_yet_enough_prec = True655while not_yet_enough_prec:656lps = lp.Dp_valued_series(n,quadratic_twist=D,prec=r+1)657lstar = [lps[0][r],lps[1][r]]658verbose("the leading terms : %s"%lstar)659if (lstar[0] != 0 or lstar[1] != 0) or ( prec != 0):660not_yet_enough_prec = False661else:662n += 1663verbose("increased precision to %s"%n)664665verbose("...putting things together")666if bsdp[0] != 0:667shan0 = lstar[0]/bsdp[0]668else:669shan0 = 0 # this should actually never happen670if bsdp[1] != 0:671shan1 = lstar[1]/bsdp[1]672else:673shan1 = 0 # this should conjecturally only happen when the rank is 0674verbose("the two values for Sha : %s"%[shan0,shan1])675676# check consistency (the first two are only here to avoid a bug in the p-adic L-series677# (namely the coefficients of zero-relative precision are treated as zero)678if shan0 != 0 and shan1 != 0 and shan0 - shan1 != 0:679raise RuntimeError("There must be a bug in the supersingular routines for the p-adic BSD.")680681#take the better682if shan1 == 0 or shan0.precision_relative() > shan1.precision_relative():683shan = shan0684else:685shan = shan1686687else:688raise ValueError("The curve has to have semi-stable reduction at p.")689690self.__an_padic[(p,prec)] = shan691return shan692693694def p_primary_bound(self, p):695r"""696Returns a provable upper bound for the order of `Sha(E)(p)`. In particular,697if this algorithm does not fail, then it proves that the `p`-primary698part of `Sha` is finite.699700INPUT: ``p`` -- a prime > 2701702OUTPUT: integer -- power of `p` that bounds the order of `Sha(E)(p)` from above703704The result is a proven upper bound on the order of `Sha(E)(p)`.705So in particular it proves it finiteness even if the rank of706the curve is larger than 1. Note also that this bound is sharp707if one assumes the main conjecture of Iwasawa theory of708elliptic curves (and this is known in certain cases).709710Currently the algorithm is only implemented when certain conditions are verified.711712- The mod `p` Galois representation must be surjective.713- The reduction at `p` is not allowed to be additive.714- If the reduction at `p` is non-split multiplicative, then the rank has to be 0.715- If `p=3` then the reduction at 3 must be good ordinary or split multiplicative and the rank must be 0.716717718EXAMPLES::719720sage: e = EllipticCurve('11a3')721sage: e.sha().p_primary_bound(3)7220723sage: e.sha().p_primary_bound(7)7240725sage: e.sha().p_primary_bound(11)7260727sage: e.sha().p_primary_bound(13)7280729730sage: e = EllipticCurve('389a1')731sage: e.sha().p_primary_bound(5)7320733sage: e.sha().p_primary_bound(7)7340735sage: e.sha().p_primary_bound(11)7360737sage: e.sha().p_primary_bound(13)7380739740sage: e = EllipticCurve('858k2')741sage: e.sha().p_primary_bound(3) # long time (10s on sage.math, 2011)742Traceback (most recent call last): # 32-bit (see :trac: `11211`)743... # 32-bit744OverflowError: Python int too large to convert to C long # 32-bit7450 # 64-bit746747Some checks for :trac:`6406`::748749sage: e.sha().p_primary_bound(7)750Traceback (most recent call last):751...752ValueError: The mod-p Galois representation is not surjective. Current knowledge about Euler systems does not provide an upper bound in this case. Try an_padic for a conjectural bound.753754sage: e.sha().an_padic(7) # long time (depends on "e.sha().p_primary_bound(3)" above)755Traceback (most recent call last): # 32-bit756... # 32-bit757OverflowError: Python int too large to convert to C long # 32-bit7587^2 + O(7^6) # 64-bit759760sage: e = EllipticCurve('11a3')761sage: e.sha().p_primary_bound(5)762Traceback (most recent call last):763...764ValueError: The mod-p Galois representation is not surjective. Current knowledge about Euler systems does not provide an upper bound in this case. Try an_padic for a conjectural bound.765sage: e.sha().an_padic(5)7661 + O(5^2)767"""768p = Integer(p)769E = self.Emin770if E.is_ordinary(p) or E.is_good(p):771su = E.galois_representation().is_surjective(p)772if not su :773raise ValueError("The mod-p Galois representation is not surjective. Current knowledge about Euler systems does not provide an upper bound in this case. Try an_padic for a conjectural bound.")774shan = self.an_padic(p,prec = 0,use_twists=True)775if shan == 0:776raise RuntimeError("There is a bug in an_padic.")777S = shan.valuation()778else:779raise ValueError("The curve has to have semi-stable reduction at p.")780781return S782783def two_selmer_bound(self):784r"""785This returns the 2-rank, i.e. the `\GF{2}`-dimension786of the 2-torsion part of `Sha`, provided we can determine the787rank of `E`.788789EXAMPLES::790791sage: sh = EllipticCurve('571a1').sha()792sage: sh.two_selmer_bound()7932794sage: sh.an()7954796797sage: sh = EllipticCurve('66a1').sha()798sage: sh.two_selmer_bound()7990800sage: sh.an()8011802803sage: sh = EllipticCurve('960d1').sha()804sage: sh.two_selmer_bound()8052806sage: sh.an()8074808"""809E = self.Emin810S = E.selmer_rank()811r = E.rank()812t = E.two_torsion_rank()813b = S - r - t814if b < 0 :815b = 0816return b817818def bound_kolyvagin(self, D=0, regulator=None,819ignore_nonsurj_hypothesis=False):820r"""821Given a fundamental discriminant `D \neq -3,-4` that satisfies the822Heegner hypothesis for `E`, return a list of primes so that823Kolyvagin's theorem (as in Gross's paper) implies that any824prime divisor of `Sha` is in this list.825826INPUT:827828- ``D`` - (optional) a fundamental discriminant < -4 that satisfies the829Heegner hypothesis for `E`; if not given, use the first such `D`830- ``regulator`` -- (optional) regulator of `E(K)`; if not given, will831be computed (which could take a long time)832- ``ignore_nonsurj_hypothesis`` (optional: default ``False``) --833If ``True``, then gives the bound coming from Heegner point834index, but without any hypothesis on surjectivity835of the mod-`p` representation.836837OUTPUT:838839- list - a list of primes such that if `p` divides `Sha(E/K)`, then840`p` is in this list, unless `E/K` has complex multiplication or841analytic rank greater than 2 (in which case we return 0).842843- index - the odd part of the index of the Heegner point in the full844group of `K`-rational points on E. (If `E` has CM, returns 0.)845846REMARKS:8478481) We do not have to assume that the Manin constant is 1849(or a power of 2). If the Manin constant were850divisible by a prime, that prime would get included in851the list of bad primes.8528532) We assume the Gross-Zagier theorem is true under the854hypothesis that `gcd(N,D) = 1`, instead of the stronger855hypothesis `gcd(2\cdot N,D)=1` that is in the original856Gross-Zagier paper. That Gross-Zagier is true when857`gcd(N,D)=1` is "well-known" to the experts, but does not858seem to written up well in the literature.8598603) Correctness of the computation is guaranteed using861interval arithmetic, under the assumption that the862regulator, square root, and period lattice are863computed to precision at least `10^{-10}`, i.e., they are864correct up to addition or a real number with absolute865value less than `10^{-10}`.866867EXAMPLES::868869sage: E = EllipticCurve('37a')870sage: E.sha().bound_kolyvagin()871([2], 1)872sage: E = EllipticCurve('141a')873sage: E.sha().an()8741875sage: E.sha().bound_kolyvagin()876([2, 7], 49)877878We get no information when the curve has rank 2.::879880sage: E = EllipticCurve('389a')881sage: E.sha().bound_kolyvagin()882(0, 0)883sage: E = EllipticCurve('681b')884sage: E.sha().an()8859886sage: E.sha().bound_kolyvagin()887([2, 3], 9)888"""889E = self.Emin890if E.has_cm():891return 0, 0892893if D == 0:894D = -5895while not E.satisfies_heegner_hypothesis(D):896D -= 1897898if not E.satisfies_heegner_hypothesis(D):899raise ArithmeticError("Discriminant (=%s) must be a fundamental discriminant that satisfies the Heegner hypothesis."%D)900if D == -3 or D == -4:901raise ArithmeticError("Discriminant (=%s) must not be -3 or -4."%D)902eps = E.root_number()903L1_vanishes = E.lseries().L1_vanishes()904if eps == 1 and L1_vanishes:905return 0, 0 # rank even hence >= 2, so Kolyvagin gives nothing.906alpha = sqrt(abs(D))/(2*E.period_lattice().complex_area())907F = E.quadratic_twist(D)908k_E = 2*sqrt(E.conductor()) + 10909k_F = 2*sqrt(F.conductor()) + 10910#k_E = 2911#k_F = 2912913MIN_ERR = 1e-10 # we assume that regulator and914# discriminant, etc., computed to this accuracy.915tries = 0916while True:917tries += 1918if tries >= 6:919raise RuntimeError("Too many precision increases in bound_kolyvagin")920if eps == 1: # E has even rank921verbose("Conductor of twist = %s"%F.conductor())922LF1, err_F = F.lseries().deriv_at1(k_F)923LE1, err_E = E.lseries().at1(k_E)924err_F = max(err_F, MIN_ERR)925err_E = max(err_E, MIN_ERR)926if regulator != None:927hZ = regulator/2928else:929hZ = F.regulator(use_database=True)/2930#print alpha * LE1 * LF1 / hZ931I = RIF(alpha) * RIF(LE1-err_E,LE1+err_E) * RIF(LF1-err_F,LF1+err_F) / hZ932#print I933934else: # E has odd rank935936if regulator != None:937hZ = regulator/2938else:939hZ = E.regulator(use_database=True)/2940LE1, err_E = E.lseries().deriv_at1(k_E)941LF1, err_F = F.lseries().at1(k_F)942err_F = max(err_F, MIN_ERR)943err_E = max(err_E, MIN_ERR)944#I = alpha * LE1 * LF1 / hZ945946I = RIF(alpha) * RIF(LE1-err_E,LE1+err_E) * RIF(LF1-err_F,LF1+err_F) / hZ947948verbose('interval = %s'%I)949t, n = I.is_int()950if t:951break952elif I.absolute_diameter() < 1:953raise RuntimeError("Problem in bound_kolyvagin; square of index is not an integer -- D=%s, I=%s."%(D,I))954verbose("Doubling bounds")955k_E *= 2956k_F *= 2957# end while958959# We include 2 since Kolyvagin (in Gross) says nothing there960if n == 0: return 0, 0 # no bound961F = factor(n)962B = [2]963for p, e in factor(n):964if p > 2:965if e%2 != 0:966raise RuntimeError("Problem in bound_kolyvagin; square of index is not a perfect square! D=%s, I=%s, n=%s, e=%s."%(D,I,n,e))967B.append(p)968else:969n /= 2**e # replace n by its odd part970if not ignore_nonsurj_hypothesis:971for p in E.galois_representation().non_surjective():972B.append(p)973B = list(set([int(x) for x in B]))974B.sort()975return B, n976977978def bound_kato(self):979r"""980Returns a list `p` of primes such that the theorems of Kato's [Ka]_981and others (e.g., as explained in a paper/thesis of Grigor982Grigorov [Gri]_) imply that if `p` divides the order of `Sha(E/\QQ)` then `p` is in983the list.984985If `L(E,1) = 0`, then this function gives no information, so986it returns ``False``.987988THEOREM (Kato): Suppose `L(E,1) \neq 0` and `p \neq 2, 3` is a prime such that989990- `E` does not have additive reduction at `p`,991- the mod-`p` representation is surjective.992993Then `{ord}_p(\#Sha(E))` divides `{ord}_p(L(E,1)\cdot\#E(\QQ)_{tor}^2/(\Omega_E \cdot \prod c_q))`.994995EXAMPLES::996997sage: E = EllipticCurve([0, -1, 1, -10, -20]) # 11A = X_0(11)998sage: E.sha().bound_kato()999[2, 3, 5]1000sage: E = EllipticCurve([0, -1, 1, 0, 0]) # X_1(11)1001sage: E.sha().bound_kato()1002[2, 3, 5]1003sage: E = EllipticCurve([1,1,1,-352,-2689]) # 66B31004sage: E.sha().bound_kato()1005[2, 3]10061007For the following curve one really has that 25 divides the order of `Sha` (by Grigorov-Stein paper [GS]_)::10081009sage: E = EllipticCurve([1, -1, 0, -332311, -73733731]) # 1058D11010sage: E.sha().bound_kato() # long time (about 1 second)1011[2, 3, 5, 23]1012sage: E.galois_representation().non_surjective() # long time (about 1 second)1013[]10141015For this one, `Sha` is divisible by 7::10161017sage: E = EllipticCurve([0, 0, 0, -4062871, -3152083138]) # 3364C11018sage: E.sha().bound_kato() # long time (< 10 seconds)1019[2, 3, 7, 29]10201021No information about curves of rank > 0::10221023sage: E = EllipticCurve([0, 0, 1, -1, 0]) # 37A (rank 1)1024sage: E.sha().bound_kato()1025False10261027REFERENCES:10281029.. [Ka] Kayuza Kato, `p`-adic Hodge theory and values of zeta1030functions of modular forms, Cohomologies `p`-adiques et1031applications arithmétiques III, Astérisque vol 295, SMF,1032Paris, 2004.10331034.. [Gri]10351036.. [GS]1037"""1038E = self.Emin1039if E.has_cm():1040return False1041if E.lseries().L1_vanishes():1042return False1043B = [2, 3]1044for p in E.galois_representation().non_surjective():1045if p > 3:1046B.append(p)1047for p in E.conductor().prime_divisors():1048if E.has_additive_reduction(p) and p not in B:1049B.append(p)10501051# The only other p that might divide B are those that divide1052# the integer 2*#E(Q)_tor^2 * L(E,1)/omega. So we compute1053# that to sufficient precision to determine it. Note that1054# we have to assume the Manin constant is <=2 in order to provably1055# compute L(E,1)/omega.1056for p, n in factor(self.an()):1057if n >= 2: # use parity of Sha1058B.append(int(p))1059B = list(set(B))1060B.sort()1061return B10621063def bound(self):1064r"""1065Compute a provably correct bound on the order of the Tate-Shafarevich1066group of this curve. The bound is either ``False`` (no bound) or a list1067``B`` of primes such that any divisor of `Sha` is in this list.10681069EXAMPLES::10701071sage: EllipticCurve('37a').sha().bound()1072([2], 1)1073"""1074if self.Emin.lseries().L1_vanishes():1075B = self.bound_kolyvagin()1076else:1077B = self.bound_kato()1078return B1079108010811082