本文整理汇总了Python中sage.rings.all.Integer.class_number方法的典型用法代码示例。如果您正苦于以下问题:Python Integer.class_number方法的具体用法?Python Integer.class_number怎么用?Python Integer.class_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.all.Integer
的用法示例。
在下文中一共展示了Integer.class_number方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: discriminants_with_bounded_class_number
# 需要导入模块: from sage.rings.all import Integer [as 别名]
# 或者: from sage.rings.all.Integer import class_number [as 别名]
def discriminants_with_bounded_class_number(hmax, B=None, proof=None):
"""
Return dictionary with keys class numbers `h\le hmax` and values the
list of all pairs `(D, f)`, with `D<0` a fundamental discriminant such
that `Df^2` has class number `h`. If the optional bound `B` is given,
return only those pairs with fundamental `|D| \le B`, though `f` can
still be arbitrarily large.
INPUT:
- ``hmax`` -- integer
- `B` -- integer or None; if None returns all pairs
- ``proof`` -- this code calls the PARI function ``qfbclassno``, so it
could give wrong answers when ``proof``==``False``. The default is
whatever ``proof.number_field()`` is. If ``proof==False`` and `B` is
``None``, at least the number of discriminants is correct, since it
is double checked with Watkins's table.
OUTPUT:
- dictionary
In case `B` is not given, we use Mark Watkins's: "Class numbers of
imaginary quadratic fields" to compute a `B` that captures all `h`
up to `hmax` (only available for `hmax\le100`).
EXAMPLES::
sage: v = sage.schemes.elliptic_curves.cm.discriminants_with_bounded_class_number(3)
sage: list(v)
[1, 2, 3]
sage: v[1]
[(-3, 3), (-3, 2), (-3, 1), (-4, 2), (-4, 1), (-7, 2), (-7, 1), (-8, 1), (-11, 1), (-19, 1), (-43, 1), (-67, 1), (-163, 1)]
sage: v[2]
[(-3, 7), (-3, 5), (-3, 4), (-4, 5), (-4, 4), (-4, 3), (-7, 4), (-8, 3), (-8, 2), (-11, 3), (-15, 2), (-15, 1), (-20, 1), (-24, 1), (-35, 1), (-40, 1), (-51, 1), (-52, 1), (-88, 1), (-91, 1), (-115, 1), (-123, 1), (-148, 1), (-187, 1), (-232, 1), (-235, 1), (-267, 1), (-403, 1), (-427, 1)]
sage: v[3]
[(-3, 9), (-3, 6), (-11, 2), (-19, 2), (-23, 2), (-23, 1), (-31, 2), (-31, 1), (-43, 2), (-59, 1), (-67, 2), (-83, 1), (-107, 1), (-139, 1), (-163, 2), (-211, 1), (-283, 1), (-307, 1), (-331, 1), (-379, 1), (-499, 1), (-547, 1), (-643, 1), (-883, 1), (-907, 1)]
sage: v = sage.schemes.elliptic_curves.cm.discriminants_with_bounded_class_number(8, proof=False)
sage: [len(v[h]) for h in v]
[13, 29, 25, 84, 29, 101, 38, 208]
Find all class numbers for discriminant up to 50::
sage: sage.schemes.elliptic_curves.cm.discriminants_with_bounded_class_number(hmax=5, B=50)
{1: [(-3, 3), (-3, 2), (-3, 1), (-4, 2), (-4, 1), (-7, 2), (-7, 1), (-8, 1), (-11, 1), (-19, 1), (-43, 1)], 2: [(-3, 7), (-3, 5), (-3, 4), (-4, 5), (-4, 4), (-4, 3), (-7, 4), (-8, 3), (-8, 2), (-11, 3), (-15, 2), (-15, 1), (-20, 1), (-24, 1), (-35, 1), (-40, 1)], 3: [(-3, 9), (-3, 6), (-11, 2), (-19, 2), (-23, 2), (-23, 1), (-31, 2), (-31, 1), (-43, 2)], 4: [(-3, 13), (-3, 11), (-3, 8), (-4, 10), (-4, 8), (-4, 7), (-4, 6), (-7, 8), (-7, 6), (-7, 3), (-8, 6), (-8, 4), (-11, 5), (-15, 4), (-19, 5), (-19, 3), (-20, 3), (-20, 2), (-24, 2), (-35, 3), (-39, 2), (-39, 1), (-40, 2), (-43, 3)], 5: [(-47, 2), (-47, 1)]}
"""
# imports that are needed only for this function
from sage.structure.proof.proof import get_flag
import math
from sage.misc.functional import round
# deal with input defaults and type checking
proof = get_flag(proof, 'number_field')
hmax = Integer(hmax)
# T stores the output
T = {}
# Easy case -- instead of giving error, give meaningful output
if hmax < 1:
return T
if B is None:
# Determine how far we have to go by applying Watkins's theorem.
v = [largest_fundamental_disc_with_class_number(h) for h in range(1, hmax+1)]
B = max([b for b,_ in v])
fund_count = [0] + [cnt for _,cnt in v]
else:
# Nothing to do -- set to None so we can use this later to know not
# to do a double check about how many we find.
fund_count = None
B = Integer(B)
if B <= 2:
# This is an easy special case, since there are no fundamental discriminants
# this small.
return T
# This lower bound gets used in an inner loop below.
from math import log
def lb(f):
"""Lower bound on euler_phi."""
# 1.79 > e^gamma = 1.7810724...
if f <= 1: return 0 # don't do log(log(1)) = log(0)
return f/(1.79*log(log(f)) + 3.0/log(log(f)))
for D in range(-B, -2):
D = Integer(D)
if is_fundamental_discriminant(D):
h_D = D.class_number(proof)
# For each fundamental discriminant D, loop through the f's such
# that h(D*f^2) could possibly be <= hmax. As explained to me by Cremona,
# we have h(D*f^2) >= (1/c)*h(D)*phi_D(f) >= (1/c)*h(D)*euler_phi(f), where
# phi_D(f) is like euler_phi(f) but the factor (1-1/p) is replaced
# by a factor of (1-kr(D,p)*p), where kr(D/p) is the Kronecker symbol.
# The factor c is 1 unless D=-4 and f>1 (when c=2) or D=-3 and f>1 (when c=3).
# Since (1-1/p) <= 1 and (1-1/p) <= (1+1/p), we see that
# euler_phi(f) <= phi_D(f).
#
# We have the following analytic lower bound on euler_phi:
#.........这里部分代码省略.........