Ticket #12356: trac_12356-cm-review.patch

File trac_12356-cm-review.patch, 5.3 KB (added by was, 10 years ago)

change a line and the commit message

  • sage/schemes/elliptic_curves/cm.py

    # HG changeset patch
    # User John Cremona <john.cremona@gmail.com>
    # Date 1328869759 0
    # Node ID 4094653631fb28f68ba8e005b15676a26371a89f
    # Parent  e3d436f1dfe7a0e5c3cc948d6bd28a459630ee15
    Trac #12356: fix Sphinx issues and one incorrect bound
    
    diff --git a/sage/schemes/elliptic_curves/cm.py b/sage/schemes/elliptic_curves/cm.py
    a b  
    55
    66- ``hilbert_class_polynomial``
    77- ``cm_j_invariants``
     8- ``cm_orders``
     9- ``discriminants_with_bounded_class_number``
    810- ``cm_j_invariants_and_orders``
     11- ``largest_fundamental_disc_with_class_number``
    912
    1013AUTHORS:
    1114
    1215- Robert Bradshaw
    1316- John Cremona
    1417- William Stein
     18
    1519"""
    1620
    1721#*****************************************************************************
     
    155159
    156160    INPUT:
    157161   
    158     - ``K`` -- a number field (currently only implemented for `K` of degree at most 2)
    159     - `proof` -- (default: proof.number_field())
     162    - ``K`` -- a number field
     163    - ``proof`` -- (default: proof.number_field())
    160164
    161165    OUTPUT:
    162166   
     
    194198
    195199    INPUT:
    196200
    197     - ``K`` -- a number field (currently only implemented for `K` of degree at most 2)
    198     - `proof` -- (default: proof.number_field())
     201    - ``K`` -- a number field
     202    - ``proof`` -- (default: proof.number_field())
    199203
    200204    OUTPUT:
    201205
     
    245249    INPUT:
    246250
    247251    - `h` -- positive integer
    248     - `proof` -- (default: proof.number_field())
     252    - ``proof`` -- (default: proof.number_field())
    249253
    250254    OUTPUT:
    251255
     
    322326def largest_fundamental_disc_with_class_number(h):
    323327    """
    324328    Return largest absolute value of any fundamental discriminant with
    325     class number h, and the number of fundamental discriminants with
     329    class number `h`, and the number of fundamental discriminants with
    326330    that class number.  This is known for `h` up to 100, by work of Mark
    327331    Watkins.
    328332
     
    361365
    362366def discriminants_with_bounded_class_number(hmax, B=None, proof=None):
    363367    """
    364     Return dictionary with keys class numbers h<=hmax and values the
    365     list of all pairs (D, f), with D<0 a fundamental discriminant such
    366     that D*f^2 has class number h.  If the optional bound B is given,
    367     return only those pairs with fundamental |D| <= B, though f can
     368    Return dictionary with keys class numbers `h\le hmax` and values the
     369    list of all pairs `(D, f)`, with `D<0` a fundamental discriminant such
     370    that `Df^2` has class number `h`.  If the optional bound `B` is given,
     371    return only those pairs with fundamental `|D| \le B`, though `f` can
    368372    still be arbitrarily large.
    369373
    370374    INPUT:
     375
    371376    - ``hmax`` -- integer
    372377    - `B` -- integer or None; if None returns all pairs
    373     - ``proof -- this code calls the PARI function qfbclassno, so it
    374       could give wrong answers when proof==False.  The default is
    375       whatever proof.number_field() is.  If proof==False and B is
    376       None, at least the number of discriminants is correct, since it
     378    - ``proof`` -- this code calls the PARI function ``qfbclassno``, so it
     379      could give wrong answers when ``proof``==``False``.  The default is
     380      whatever ``proof.number_field()`` is.  If ``proof==False`` and `B` is
     381      ``None``, at least the number of discriminants is correct, since it
    377382      is double checked with Watkins's table.
    378383
    379384    OUTPUT:
     385
    380386    - dictionary
    381387
    382     In case B is not given, we use Mark Watkins's: "Class numbers of
    383     imaginary quadratic fields" to compute a B that captures all h
    384     up to hmax.
     388    In case `B` is not given, we use Mark Watkins's: "Class numbers of
     389    imaginary quadratic fields" to compute a `B` that captures all `h`
     390    up to `hmax` (only available for `hmax\le100`).
    385391
    386392    EXAMPLES::
    387393
     
    461467            h_D = classno(D)
    462468            # For each fundamental discrimant D, loop through the f's such
    463469            # that h(D*f^2) could possibly be <= hmax.  As explained to me by Cremona,
    464             # we have h(D*f^2) >= h(D)*phi_D(f) >= h(D)*euler_phi(f), where
     470            # we have h(D*f^2) >= (1/c)*h(D)*phi_D(f) >= (1/c)*h(D)*euler_phi(f), where
    465471            # phi_D(f) is like euler_phi(f) but the factor (1-1/p) is replaced
    466472            # by a factor of (1-kr(D,p)*p), where kr(D/p) is the Kronecker symbol.
     473            # The factor c is 1 unless D=-4 and f>1 (when c=2) or D=-3 and f>1 (when c=3).
    467474            # Since (1-1/p) <= 1 and (1-1/p) <= (1+1/p), we see that
    468475            #     euler_phi(f) <= phi_D(f).
    469476            #
     
    482489            #   lb(n) = n/(exp(euler_gamma)*log(log(n)) + 3/log(log(n)))
    483490            #   plot(lb, (n, 1, 10^4), color='red') + plot(lambda x: euler_phi(int(x)), 1, 10^4).show()
    484491            #
    485             # So we consider f=1,2,..., until the first f with lb(f)*h_D > h_max.
     492            # So we consider f=1,2,..., until the first f with lb(f)*h_D > c*h_max.
    486493            # (Note that lb(f) is <= 0 for f=1,2, so nothing special is needed there.)
    487494            #
    488495            # TODO: Maybe we could do better using a bound for for phi_D(f).
    489496            #
    490497            f = 1
    491             while lb(f)*h_D <= hmax:
     498            chmax=hmax
     499            if D==-3:
     500                chmax*=3
     501            else:
     502                if D==-4:
     503                    chmax*=2
     504            while lb(f)*h_D <= chmax:
    492505                if f == 1:
    493506                    h = h_D
    494507                else: