Ticket #6455: trac_6455.patch

File trac_6455.patch, 3.4 KB (added by wuthrich, 10 years ago)
  • sage/schemes/elliptic_curves/sha_tate.py

    # HG changeset patch
    # User Chris Wuthrich <christian.wuthrich@gmail.com>
    # Date 1248212024 -3600
    # Node ID 4a4636b71907f37f27dc75c67032453551a5e02f
    # Parent  92883ef75c3cbc86e49ec584b0975972a76969a4
    trac 6455 : bug when twisting in an_padic
    
    diff -r 92883ef75c3c -r 4a4636b71907 sage/schemes/elliptic_curves/sha_tate.py
    a b  
    3535    Integer,
    3636    RealField,
    3737    RationalField,
    38     RIF)
     38    RIF,
     39    ZZ)
    3940from sage.misc.functional import log
    4041from math import sqrt
    4142from sage.misc.all import verbose
    4243import sage.rings.arith as arith
    4344
    4445factor = arith.factor
     46valuation = arith.valuation
    4547Q = RationalField()
    4648
    4749class Sha(SageObject):
     
    372374            4 + O(5)
    373375            sage: EllipticCurve('448c5').sha().an_padic(7,prec=4)  # long time
    374376            2 + 7 + O(7^3)
     377            sage: E = EllipticCurve([-19,34]) # trac 6455
     378            sage: E.sha().an_padic(5)
     379            1 + O(5)
    375380
    376381        """
    377382        try:
     
    391396        # todo : here we should catch the rank computation
    392397        r = self.E.rank()
    393398     
    394         if use_twists :
     399        if use_twists and p > 2:
    395400            Et, D = self.E.minimal_quadratic_twist()
    396             # We cannot use a non-trivial twist of the same conductor!
    397             # e.g. the minimal quadratic twist of '300b2' is '300a2'
    398             # (since that comes earlier in the database)
    399             if Et.conductor() == self.E.conductor():
    400                 Et = self.E
    401                 D = 1
     401            # trac 6455 : we have to assure that the twist back is allowed
     402            D = ZZ(D)
     403            if D % p == 0:
     404                D = D/p
     405            for ell in D.prime_divisors():
     406                if ell % 2 == 1:
     407                    if Et.conductor() % ell**2 == 0:
     408                        D = D/ell
     409            ve = valuation(D,2)
     410            de = (D/2**ve).abs()
     411            if de % 4 == 3:
     412                de = -de
     413            Et = self.E.quadratic_twist(de)
     414            # now check individually if we can twist by -1 or 2 or -2
     415            Nmin = Et.conductor()
     416            Dmax = de
     417            for DD in [-4*de,8*de,-8*de]:
     418                Et = self.E.quadratic_twist(DD)
     419                if Et.conductor() < Nmin and valuation(Et.conductor(),2) <= valuation(DD,2):
     420                    Nmin = Et.conductor()
     421                    Dmax = DD
     422            D = Dmax
     423            Et = self.E.quadratic_twist(D)
    402424            lp = Et.padic_lseries(p)
    403425        else :
    404426            lp = self.E.padic_lseries(p)
     
    556578            Traceback (most recent call last):
    557579            ...           
    558580            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.
     581            sage: e.sha().an_padic(7)  # long time
     582            7^2 + O(7^3)         
    559583
    560584            sage: e = EllipticCurve('11a3')
    561585            sage: e.sha().p_primary_bound(5)
    562586            Traceback (most recent call last):
    563587            ...           
    564588            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.
     589            sage: e.sha().an_padic(5)
     590            1 + O(5^2)
    565591
    566592        """
    567593