Path: blob/master/sage/schemes/elliptic_curves/sha_tate.py
4128 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 we 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)126127"""128def __init__(self, E):129r"""130The Tate-Shafarevich group associated to an elliptic curve.131132INPUT:133a 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))143True144145"""146self.E = E147self.Emin = E.minimal_model() if not E.is_minimal() else E148149def __cmp__(self,other):150r"""151Compares two Tate-Shafarevich groups by simply comparing the elliptic curves.152153EXAMPLES::154155sage: E = EllipticCurve('37a1')156sage: S = E.sha()157sage: S == S158True159"""160c = cmp(type(self), type(other))161if c:162return c163return cmp(self.E, other.E)164165def __repr__(self):166r"""167String representation of the Tate-Shafarevich group.168169EXAMPLES::170171sage: E = EllipticCurve('11a1')172sage: S = E.sha()173sage: S.__repr__()174'Tate-Shafarevich group for the Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field'175176"""177return "Tate-Shafarevich group for the " + repr(self.E)178179########################################################################180# Functions related to the BSD conjecture.181########################################################################182183def an_numerical(self, prec = None,184use_database=True, proof=None):185r"""186Return the numerical analytic order of `Sha`, which is187a floating point number in all cases.188189INPUT:190191- ``prec`` - integer (default: 53) bits precision -- used192for the L-series computation, period, regulator, etc.193- ``use_database`` - whether the rank and generators should194be looked up in the database if possible. Default is True195- ``proof`` - bool or None (default: None, see proof.[tab] or196sage.structure.proof) proof option passed197onto regulator and rank computation.198199.. note::200See also the an() command, which will return a201provably correct integer when the rank is 0 or 1.202203.. WARNING::204If the curve's generators are not known, computing205them may be very time-consuming. Also, computation of the206L-series derivative will be time-consuming for large rank and207large conductor, and the computation time for this may208increase substantially at greater precision. However, use of209very low precision less than about 10 can cause the underlying210PARI library functions to fail.211212EXAMPLES::213214sage: EllipticCurve('11a').sha().an_numerical()2151.00000000000000216sage: EllipticCurve('37a').sha().an_numerical()2171.00000000000000218sage: EllipticCurve('389a').sha().an_numerical()2191.00000000000000220sage: EllipticCurve('66b3').sha().an_numerical()2214.00000000000000222sage: EllipticCurve('5077a').sha().an_numerical()2231.00000000000000224225A rank 4 curve::226227sage: EllipticCurve([1, -1, 0, -79, 289]).sha().an_numerical() # long time (3s on sage.math, 2011)2281.00000000000000229230A rank 5 curve::231232sage: EllipticCurve([0, 0, 1, -79, 342]).sha().an_numerical(prec=10, proof=False) # long time (22s on sage.math, 2011)2331.0234235See trac #1115::236237sage: sha=EllipticCurve('37a1').sha()238sage: [sha.an_numerical(prec) for prec in xrange(40,100,10)]239[1.0000000000,2401.0000000000000,2411.0000000000000000,2421.0000000000000000000,2431.0000000000000000000000,2441.0000000000000000000000000]245"""246if prec is None:247prec = RealField().precision()248RR = RealField(prec)249prec2 = prec+2250RR2 = RealField(prec2)251try:252an = self.__an_numerical253if an.parent().precision() >= prec:254return RR(an)255else: # cached precision too low256pass257except AttributeError:258pass259# it's critical to switch to the minimal model.260E = self.Emin261r = Integer(E.rank(use_database=use_database, proof=proof))262L = E.lseries().dokchitser(prec=prec2)263Lr= RR2(L.derivative(1,r)) # L.derivative() returns a Complex264Om = RR2(E.period_lattice().omega(prec2))265Reg = E.regulator(use_database=use_database, proof=proof, precision=prec2)266T = E.torsion_order()267cp = E.tamagawa_product()268Sha = RR((Lr*T*T)/(r.factorial()*Om*cp*Reg))269self.__an_numerical = Sha270return Sha271272def an(self, use_database=False, descent_second_limit=12):273r"""274Returns the Birch and Swinnerton-Dyer conjectural order of `Sha`275as a provably correct integer, unless the analytic rank is > 1,276in which case this function returns a numerical value.277278INPUT:279280- ``use_database`` -- bool (default: False); if True, try to use any281databases installed to lookup the analytic order of `Sha`, if282possible. The order of `Sha` is computed if it can't be looked up.283284- ``descent_second_limit`` -- int (default: 12); limit to use on285point searching for the quartic twist in the hard case286287This result is proved correct if the order of vanishing is 0288and the Manin constant is <= 2.289290If the optional parameter ``use_database`` is True (default:291False), this function returns the analytic order of `Sha` as292listed in Cremona's tables, if this curve appears in Cremona's293tables.294295NOTE:296297If you come across the following error::298299sage: E = EllipticCurve([0, 0, 1, -34874, -2506691])300sage: E.sha().an()301Traceback (most recent call last):302...303RuntimeError: Unable to compute the rank, hence generators, with certainty (lower bound=0, generators found=[]). This could be because Sha(E/Q)[2] is nontrivial.304Try increasing descent_second_limit then trying this command again.305306You can increase the ``descent_second_limit`` (in the above example,307set to the default, 12) option to try again::308309sage: E.sha().an(descent_second_limit=16) # long time (2s on sage.math, 2011)3101311312EXAMPLES::313314sage: E = EllipticCurve([0, -1, 1, -10, -20]) # 11A = X_0(11)315sage: E.sha().an()3161317sage: E = EllipticCurve([0, -1, 1, 0, 0]) # X_1(11)318sage: E.sha().an()3191320321sage: EllipticCurve('14a4').sha().an()3221323sage: EllipticCurve('14a4').sha().an(use_database=True) # will be faster if you have large Cremona database installed3241325326The smallest conductor curve with nontrivial `Sha`::327328sage: E = EllipticCurve([1,1,1,-352,-2689]) # 66b3329sage: E.sha().an()3304331332The four optimal quotients with nontrivial `Sha` and conductor <= 1000::333334sage: E = EllipticCurve([0, -1, 1, -929, -10595]) # 571A335sage: E.sha().an()3364337sage: E = EllipticCurve([1, 1, 0, -1154, -15345]) # 681B338sage: E.sha().an()3399340sage: E = EllipticCurve([0, -1, 0, -900, -10098]) # 960D341sage: E.sha().an()3424343sage: E = EllipticCurve([0, 1, 0, -20, -42]) # 960N344sage: E.sha().an()3454346347The smallest conductor curve of rank > 1::348349sage: E = EllipticCurve([0, 1, 1, -2, 0]) # 389A (rank 2)350sage: E.sha().an()3511.00000000000000352353The following are examples that require computation of the Mordell-Weil354group and regulator::355356sage: E = EllipticCurve([0, 0, 1, -1, 0]) # 37A (rank 1)357sage: E.sha().an()3581359360sage: E = EllipticCurve("1610f3")361sage: E.sha().an()3624363364In this case the input curve is not minimal, and if this function didn't365transform it to be minimal, it would give nonsense::366367sage: E = EllipticCurve([0,-432*6^2])368sage: E.sha().an()3691370371See trac #10096: this used to give the wrong result 6.0000372before since the minimal model was not used::373374sage: E = EllipticCurve([1215*1216,0]) # non-minimal model375sage: E.sha().an() # long time (2s on sage.math, 2011)3761.00000000000000377sage: E.minimal_model().sha().an() # long time (1s on sage.math, 2011)3781.00000000000000379"""380if hasattr(self, '__an'):381return self.__an382if use_database:383d = self.Emin.database_curve()384if hasattr(d, 'db_extra'):385self.__an = Integer(round(float(d.db_extra[4])))386return self.__an387388# it's critical to switch to the minimal model.389E = self.Emin390eps = E.root_number()391if eps == 1:392L1_over_omega = E.lseries().L_ratio()393if L1_over_omega == 0: # order of vanishing is at least 2394return self.an_numerical(use_database=use_database)395T = E.torsion_subgroup().order()396Sha = (L1_over_omega * T * T) / Q(E.tamagawa_product())397try:398Sha = Integer(Sha)399except ValueError:400raise RuntimeError, \401"There is a bug in an, since the computed conjectural order of Sha is %s, which is not an integer."%Sha402if not arith.is_square(Sha):403raise RuntimeError, \404"There is a bug in an, since the computed conjectural order of Sha is %s, which is not a square."%Sha405E.__an = Sha406self.__an = Sha407return Sha408409else: # rank > 0 (Not provably correct)410L1, error_bound = E.lseries().deriv_at1(10*sqrt(E.conductor()) + 10)411if abs(L1) < error_bound:412s = self.an_numerical()413E.__an = s414self.__an = s415return s416417regulator = E.regulator(use_database=use_database, descent_second_limit=descent_second_limit)418T = E.torsion_subgroup().order()419omega = E.period_lattice().omega()420Sha = Integer(round ( (L1 * T * T) / (E.tamagawa_product() * regulator * omega) ))421try:422Sha = Integer(Sha)423except ValueError:424raise RuntimeError, \425"There is a bug in an, since the computed conjectural order of Sha is %s, which is not an integer."%Sha426if not arith.is_square(Sha):427raise RuntimeError, \428"There is a bug in an, since the computed conjectural order of Sha is %s, which is not a square."%Sha429E.__an = Sha430self.__an = Sha431return Sha432433def an_padic(self, p, prec=0, use_twists=True):434r"""435Returns the conjectural order of `Sha(E/\QQ)`,436according to the `p`-adic analogue of the Birch437and Swinnerton-Dyer conjecture as formulated438in [MTT] and [BP].439440REFERENCES:441442- [MTT] B. Mazur, J. Tate, and J. Teitelbaum,443On `p`-adic analogues of the conjectures of Birch and444Swinnerton-Dyer, Inventiones mathematicae 84, (1986), 1-48.445446- [BP] Dominique Bernardi and Bernadette Perrin-Riou,447Variante `p`-adique de la conjecture de Birch et448Swinnerton-Dyer (le cas supersingulier), C. R. Acad. Sci. Paris,449Ser I. Math, 317 (1993), no 3, 227-232.450451- [SW] William Stein and Christian Wuthrich, Computations About Tate-Shafarevich Groups452using Iwasawa theory, preprint 2009.453454455INPUT:456457- ``p`` - a prime > 3458459- ``prec`` (optional) - the precision used in the computation of the `p`-adic L-Series460461- ``use_twists`` (default = True) - If true the algorithm may change462to a quadratic twist with minimal conductor to do the modular463symbol computations rather than using the modular symbols of the464curve itself. If False it forces the computation using the465modular symbols of the curve itself.466467OUTPUT: `p`-adic number - that conjecturally equals `\# Sha(E/\QQ)`.468469If prec is set to zero (default) then the precision is set so that470at least the first `p`-adic digit of conjectural `\# Sha(E/\QQ)` is471determined.472473EXAMPLES:474475Good ordinary examples::476477sage: EllipticCurve('11a1').sha().an_padic(5) # rank 04781 + O(5^2)479sage: EllipticCurve('43a1').sha().an_padic(5) # rank 14801 + O(5)481sage: EllipticCurve('389a1').sha().an_padic(5,4) # rank 2, long time (2s on sage.math, 2011)4821 + O(5^3)483sage: EllipticCurve('858k2').sha().an_padic(7) # rank 0, non trivial sha, long time (10s on sage.math, 2011)4847^2 + O(7^6)485sage: EllipticCurve('300b2').sha().an_padic(3) # 9 elements in sha, long time (2s on sage.math, 2011)4863^2 + O(3^6)487sage: EllipticCurve('300b2').sha().an_padic(7, prec=6) # long time4882 + 7 + O(7^8)489490Exceptional cases::491492sage: EllipticCurve('11a1').sha().an_padic(11) # rank 04931 + O(11^2)494sage: EllipticCurve('130a1').sha().an_padic(5) # rank 14951 + O(5)496497Non-split, but rank 0 case (trac #7331)::498499sage: EllipticCurve('270b1').sha().an_padic(5) # rank 0, long time (2s on sage.math, 2011)5001 + O(5^2)501502The output has the correct sign::503504sage: EllipticCurve('123a1').sha().an_padic(41) # rank 1, long time (3s on sage.math, 2011)5051 + O(41)506507Supersingular cases::508509sage: EllipticCurve('34a1').sha().an_padic(5) # rank 05101 + O(5^2)511sage: EllipticCurve('53a1').sha().an_padic(5) # rank 1, long time (11s on sage.math, 2011)5121 + O(5)513514Cases that use a twist to a lower conductor::515516sage: EllipticCurve('99a1').sha().an_padic(5)5171 + O(5)518sage: EllipticCurve('240d3').sha().an_padic(5) # sha has 4 elements here5194 + O(5)520sage: EllipticCurve('448c5').sha().an_padic(7,prec=4, use_twists=False) # long time (2s on sage.math, 2011)5212 + 7 + O(7^6)522sage: EllipticCurve([-19,34]).sha().an_padic(5) # see trac 6455, long time (4s on sage.math, 2011)5231 + O(5)524"""525try:526return self.__an_padic[(p,prec)]527except AttributeError:528self.__an_padic = {}529except KeyError:530pass531532E = self.Emin533tam = E.tamagawa_product()534tors = E.torsion_order()**2535reg = E.padic_regulator(p)536# todo : here we should cache the rank computation537r = E.rank()538539540if use_twists and p > 2:541Et, D = E.minimal_quadratic_twist()542# trac 6455 : we have to assure that the twist back is allowed543D = ZZ(D)544if D % p == 0:545D = D/p546for ell in D.prime_divisors():547if ell % 2 == 1:548if Et.conductor() % ell**2 == 0:549D = D/ell550ve = valuation(D,2)551de = (D/2**ve).abs()552if de % 4 == 3:553de = -de554Et = E.quadratic_twist(de)555# now check individually if we can twist by -1 or 2 or -2556Nmin = Et.conductor()557Dmax = de558for DD in [-4*de,8*de,-8*de]:559Et = E.quadratic_twist(DD)560if Et.conductor() < Nmin and valuation(Et.conductor(),2) <= valuation(DD,2):561Nmin = Et.conductor()562Dmax = DD563D = Dmax564Et = E.quadratic_twist(D)565lp = Et.padic_lseries(p)566else :567lp = E.padic_lseries(p)568D = 1569570if r == 0 and D == 1:571# short cut for rank 0 curves, we do not572# to compute the p-adic L-function, the leading573# term will be the L-value divided by the Neron574# period.575ms = E.modular_symbol(sign=+1, normalize='L_ratio')576lstar = ms(0)/E.real_components()577bsd = tam/tors578if prec == 0:579prec = valuation(lstar/bsd, p)580shan = Qp(p,prec=prec+2)(lstar/bsd)581582583elif E.is_ordinary(p):584K = reg.parent()585lg = log(K(1+p))586587if (E.is_good(p) or E.ap(p) == -1):588if not E.is_good(p):589eps = 2590else:591eps = (1-arith.kronecker_symbol(D,p)/lp.alpha())**2592# according to the p-adic BSD this should be equal to the leading term of the p-adic L-series divided by sha:593bsdp = tam * reg * eps/tors/lg**r594else:595r += 1 # exceptional zero596eq = E.tate_curve(p)597Li = eq.L_invariant()598599# according to the p-adic BSD (Mazur-Tate-Teitelbaum)600# this should be equal to the leading term of the p-adic L-series divided by sha:601bsdp = tam * reg * Li/tors/lg**r602603604v = bsdp.valuation()605if v > 0:606verbose("the prime is irregular.")607608# determine how much prec we need to prove at least the triviality of609# the p-primary part of Sha610611if prec == 0:612n = max(v,2)613bounds = lp._prec_bounds(n,r+1)614while bounds[r] <= v:615n += 1616bounds = lp._prec_bounds(n,r+1)617verbose("set precision to %s"%n)618else:619n = max(2,prec)620621not_yet_enough_prec = True622while not_yet_enough_prec:623lps = lp.series(n,quadratic_twist=D,prec=r+1)624lstar = lps[r]625if (lstar != 0) or (prec != 0):626not_yet_enough_prec = False627else:628n += 1629verbose("increased precision to %s"%n)630631shan = lstar/bsdp632633elif E.is_supersingular(p):634K = reg[0].parent()635lg = log(K(1+p))636637638# according to the p-adic BSD this should be equal to the leading term of the D_p - valued639# L-series :640bsdp = tam /tors/lg**r * reg641# note this is an element in Q_p^2642643verbose("the algebraic leading terms : %s"%bsdp)644645v = [bsdp[0].valuation(),bsdp[1].valuation()]646647if prec == 0:648n = max(min(v)+2,3)649else:650n = max(3,prec)651652verbose("...computing the p-adic L-series")653not_yet_enough_prec = True654while not_yet_enough_prec:655lps = lp.Dp_valued_series(n,quadratic_twist=D,prec=r+1)656lstar = [lps[0][r],lps[1][r]]657verbose("the leading terms : %s"%lstar)658if (lstar[0] != 0 or lstar[1] != 0) or ( prec != 0):659not_yet_enough_prec = False660else:661n += 1662verbose("increased precision to %s"%n)663664verbose("...putting things together")665if bsdp[0] != 0:666shan0 = lstar[0]/bsdp[0]667else:668shan0 = 0 # this should actually never happen669if bsdp[1] != 0:670shan1 = lstar[1]/bsdp[1]671else:672shan1 = 0 # this should conjecturally only happen when the rank is 0673verbose("the two values for Sha : %s"%[shan0,shan1])674675# check consistency (the first two are only here to avoid a bug in the p-adic L-series676# (namely the coefficients of zero-relative precision are treated as zero)677if shan0 != 0 and shan1 != 0 and shan0 - shan1 != 0:678raise RuntimeError, "There must be a bug in the supersingular routines for the p-adic BSD."679680#take the better681if shan1 == 0 or shan0.precision_relative() > shan1.precision_relative():682shan = shan0683else:684shan = shan1685686else:687raise ValueError, "The curve has to have semi-stable reduction at p."688689self.__an_padic[(p,prec)] = shan690return shan691692693def p_primary_bound(self, p):694r"""695Returns a provable upper bound for the order of `Sha(E)(p)`. In particular,696if this algorithm does not fail, then it proves that the `p`-primary697part of `Sha` is finite.698699INPUT: ``p`` -- a prime > 2700701OUTPUT: integer -- power of `p` that bounds the order of `Sha(E)(p)` from above702703The result is a proven upper bound on the order of `Sha(E)(p)`.704So in particular it proves it finiteness even if the rank of705the curve is larger than 1. Note also that this bound is sharp706if one assumes the main conjecture of Iwasawa theory of707elliptic curves (and this is known in certain cases).708709Currently the algorithm is only implemented when certain conditions are verified.710711- The mod `p` Galois representation must be surjective.712- The reduction at `p` is not allowed to be additive.713- If the reduction at `p` is non-split multiplicative, then the rank has to be 0.714- If `p=3` then the reduction at 3 must be good ordinary or split multiplicative and the rank must be 0.715716717EXAMPLES::718719sage: e = EllipticCurve('11a3')720sage: e.sha().p_primary_bound(3)7210722sage: e.sha().p_primary_bound(7)7230724sage: e.sha().p_primary_bound(11)7250726sage: e.sha().p_primary_bound(13)7270728729sage: e = EllipticCurve('389a1')730sage: e.sha().p_primary_bound(5)7310732sage: e.sha().p_primary_bound(7)7330734sage: e.sha().p_primary_bound(11)7350736sage: e.sha().p_primary_bound(13)7370738739sage: e = EllipticCurve('858k2')740sage: e.sha().p_primary_bound(3) # long time (10s on sage.math, 2011)7410742743# checks for trac 6406744sage: e.sha().p_primary_bound(7)745Traceback (most recent call last):746...747ValueError: 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.748sage: e.sha().an_padic(7) # long time (depends on "e.sha().p_primary_bound(3)" above)7497^2 + O(7^6)750751sage: e = EllipticCurve('11a3')752sage: e.sha().p_primary_bound(5)753Traceback (most recent call last):754...755ValueError: 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.756sage: e.sha().an_padic(5)7571 + O(5^2)758759"""760p = Integer(p)761E = self.Emin762if E.is_ordinary(p) or E.is_good(p):763su = E.galois_representation().is_surjective(p)764if not su :765raise 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."766shan = self.an_padic(p,prec = 0,use_twists=True)767if shan == 0:768raise RuntimeError, "There is a bug in an_padic."769S = shan.valuation()770else:771raise ValueError, "The curve has to have semi-stable reduction at p."772773return S774775def two_selmer_bound(self):776r"""777This returns the 2-rank, i.e. the `\GF{2}`-dimension778of the 2-torsion part of `Sha`, provided we can determine the779rank of `E`.780781EXAMPLES::782783sage: sh = EllipticCurve('571a1').sha()784sage: sh.two_selmer_bound()7852786sage: sh.an()7874788789sage: sh = EllipticCurve('66a1').sha()790sage: sh.two_selmer_bound()7910792sage: sh.an()7931794795sage: sh = EllipticCurve('960d1').sha()796sage: sh.two_selmer_bound()7972798sage: sh.an()7994800"""801E = self.Emin802S = E.selmer_rank()803r = E.rank()804t = E.two_torsion_rank()805b = S - r - t806if b < 0 :807b = 0808return b809810def bound_kolyvagin(self, D=0, regulator=None,811ignore_nonsurj_hypothesis=False):812r"""813Given a fundamental discriminant `D \neq -3,-4` that satisfies the814Heegner hypothesis for `E`, return a list of primes so that815Kolyvagin's theorem (as in Gross's paper) implies that any816prime divisor of `Sha` is in this list.817818INPUT:819820- ``D`` - (optional) a fundamental discriminant < -4 that satisfies the821Heegner hypothesis for `E`; if not given, use the first such `D`822- ``regulator`` -- (optional) regulator of `E(K)`; if not given, will823be computed (which could take a long time)824- ``ignore_nonsurj_hypothesis`` (optional: default False) --825If True, then gives the bound coming from Heegner point826index, but without any hypothesis on surjectivity827of the mod-`p` representation.828829OUTPUT:830831- list - a list of primes such that if `p` divides `Sha(E/K)`, then832`p` is in this list, unless `E/K` has complex multiplication or833analytic rank greater than 2 (in which case we return 0).834835- index - the odd part of the index of the Heegner point in the full836group of `K`-rational points on E. (If `E` has CM, returns 0.)837838REMARKS:8398401) We do not have to assume that the Manin constant is 1841(or a power of 2). If the Manin constant were842divisible by a prime, that prime would get included in843the list of bad primes.8448452) We assume the Gross-Zagier theorem is True under the846hypothesis that `gcd(N,D) = 1`, instead of the stronger847hypothesis `gcd(2\cdot N,D)=1` that is in the original848Gross-Zagier paper. That Gross-Zagier is true when849`gcd(N,D)=1` is"well-known" to the experts, but doesn't850seem to written up well in the literature.8518523) Correctness of the computation is guaranteed using853interval arithmetic, under the assumption that the854regulator, square root, and period lattice are855computed to precision at least `10^{-10}`, i.e., they are856correct up to addition or a real number with absolute857value less than `10^{-10}`.858859EXAMPLES::860861sage: E = EllipticCurve('37a')862sage: E.sha().bound_kolyvagin()863([2], 1)864sage: E = EllipticCurve('141a')865sage: E.sha().an()8661867sage: E.sha().bound_kolyvagin()868([2, 7], 49)869870We get no information when the curve has rank 2.::871872sage: E = EllipticCurve('389a')873sage: E.sha().bound_kolyvagin()874(0, 0)875sage: E = EllipticCurve('681b')876sage: E.sha().an()8779878sage: E.sha().bound_kolyvagin()879([2, 3], 9)880881"""882E = self.Emin883if E.has_cm():884return 0, 0885886if D == 0:887D = -5888while not E.satisfies_heegner_hypothesis(D):889D -= 1890891if not E.satisfies_heegner_hypothesis(D):892raise ArithmeticError, "Discriminant (=%s) must be a fundamental discriminant that satisfies the Heegner hypothesis."%D893if D == -3 or D == -4:894raise ArithmeticError, "Discriminant (=%s) must not be -3 or -4."%D895eps = E.root_number()896L1_vanishes = E.lseries().L1_vanishes()897if eps == 1 and L1_vanishes:898return 0, 0 # rank even hence >= 2, so Kolyvagin gives nothing.899alpha = sqrt(abs(D))/(2*E.period_lattice().complex_area())900F = E.quadratic_twist(D)901k_E = 2*sqrt(E.conductor()) + 10902k_F = 2*sqrt(F.conductor()) + 10903#k_E = 2904#k_F = 2905906MIN_ERR = 1e-10 # we assume that regulator and907# discriminant, etc., computed to this accuracy.908tries = 0909while True:910tries += 1911if tries >= 6:912raise RuntimeError, "Too many precision increases in bound_kolyvagin"913if eps == 1: # E has even rank914verbose("Conductor of twist = %s"%F.conductor())915LF1, err_F = F.lseries().deriv_at1(k_F)916LE1, err_E = E.lseries().at1(k_E)917err_F = max(err_F, MIN_ERR)918err_E = max(err_E, MIN_ERR)919if regulator != None:920hZ = regulator/2921else:922hZ = F.regulator(use_database=True)/2923#print alpha * LE1 * LF1 / hZ924I = RIF(alpha) * RIF(LE1-err_E,LE1+err_E) * RIF(LF1-err_F,LF1+err_F) / hZ925#print I926927else: # E has odd rank928929if regulator != None:930hZ = regulator/2931else:932hZ = E.regulator(use_database=True)/2933LE1, err_E = E.lseries().deriv_at1(k_E)934LF1, err_F = F.lseries().at1(k_F)935err_F = max(err_F, MIN_ERR)936err_E = max(err_E, MIN_ERR)937#I = alpha * LE1 * LF1 / hZ938939I = RIF(alpha) * RIF(LE1-err_E,LE1+err_E) * RIF(LF1-err_F,LF1+err_F) / hZ940941verbose('interval = %s'%I)942t, n = I.is_int()943if t:944break945elif I.absolute_diameter() < 1:946raise RuntimeError, "Problem in bound_kolyvagin; square of index is not an integer -- D=%s, I=%s."%(D,I)947verbose("Doubling bounds")948k_E *= 2949k_F *= 2950# end while951952# We include 2 since Kolyvagin (in Gross) says nothing there953if n == 0: return 0, 0 # no bound954F = factor(n)955B = [2]956for p, e in factor(n):957if p > 2:958if e%2 != 0:959raise 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)960B.append(p)961else:962n /= 2**e # replace n by its odd part963if not ignore_nonsurj_hypothesis:964for p in E.galois_representation().non_surjective():965B.append(p)966B = list(set([int(x) for x in B]))967B.sort()968return B, n969970971def bound_kato(self):972r"""973Returns a list `p` of primes such that the theorems of Kato's [Ka]974and others (e.g., as explained in a paper/thesis of Grigor975Grigorov [Gri]) imply that if `p` divides the order of `Sha(E/\QQ)` then `p` is in976the list.977978If `L(E,1) = 0`, then this function gives no information, so979it returns False.980981THEOREM (Kato): Suppose `L(E,1) \neq 0` and `p \neq 2, 3` is a prime such that982983- `E` does not have additive reduction at `p`,984- the mod-`p` representation is surjective.985986Then `{ord}_p(\#Sha(E))` divides `{ord}_p(L(E,1)\cdot\#E(\QQ)_{tor}^2/(\Omega_E \cdot \prod c_q))`.987988EXAMPLES::989990sage: E = EllipticCurve([0, -1, 1, -10, -20]) # 11A = X_0(11)991sage: E.sha().bound_kato()992[2, 3, 5]993sage: E = EllipticCurve([0, -1, 1, 0, 0]) # X_1(11)994sage: E.sha().bound_kato()995[2, 3, 5]996sage: E = EllipticCurve([1,1,1,-352,-2689]) # 66B3997sage: E.sha().bound_kato()998[2, 3]9991000For the following curve one really has that 25 divides the order of `Sha` (by Grigorov-Stein paper [GS])::10011002sage: E = EllipticCurve([1, -1, 0, -332311, -73733731]) # 1058D11003sage: E.sha().bound_kato() # long time (about 1 second)1004[2, 3, 5, 23]1005sage: E.galois_representation().non_surjective() # long time (about 1 second)1006[]10071008For this one, `Sha` is divisible by 7::10091010sage: E = EllipticCurve([0, 0, 0, -4062871, -3152083138]) # 3364C11011sage: E.sha().bound_kato() # long time (< 10 seconds)1012[2, 3, 7, 29]10131014No information about curves of rank > 0::10151016sage: E = EllipticCurve([0, 0, 1, -1, 0]) # 37A (rank 1)1017sage: E.sha().bound_kato()1018False10191020REFERENCES:10211022- [Ka] Kayuza Kato, `p`-adic Hodge theory and values of zeta functions of modular1023forms, Cohomologies `p`-adiques et applications arithmetiques III,1024Asterisque vol 295, SMF, Paris, 2004.10251026- [Gri]10271028- [GS]10291030"""1031E = self.Emin1032if E.has_cm():1033return False1034if E.lseries().L1_vanishes():1035return False1036B = [2, 3]1037for p in E.galois_representation().non_surjective():1038if p > 3:1039B.append(p)1040N = E.conductor()1041for p in E.conductor().prime_divisors():1042if E.has_additive_reduction(p) and p not in B:1043B.append(p)10441045# The only other p that might divide B are those that divide1046# the integer 2*#E(Q)_tor^2 * L(E,1)/omega. So we compute1047# that to sufficient precision to determine it. Note that1048# we have to assume the Manin constant is <=2 in order to provably1049# compute L(E,1)/omega.1050for p, n in factor(self.an()):1051if n >= 2: # use parity of Sha1052B.append(int(p))1053B = list(set(B))1054B.sort()1055return B10561057def bound(self):1058r"""1059Compute a provably correct bound on the order of the Tate-Shafarevich1060group of this curve. The bound is a either False (no bound) or a list1061``B`` of primes such that any divisor of `Sha` is in this list.10621063EXAMPLES::10641065sage: EllipticCurve('37a').sha().bound()1066([2], 1)1067"""1068if self.Emin.lseries().L1_vanishes():1069B = self.bound_kolyvagin()1070else:1071B = self.bound_kato()1072return B1073107410751076