Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CM testing for elliptic curves over number fields #35166

Merged
merged 16 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/doc/en/reference/references/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,10 @@ REFERENCES:
and Monographs*. American Mathematical Society,
Providence, RI, 1999.

.. [Cox1989] David A. Cox.
Primes of the form `x^2+ny^2`.
Wiley, 1989.

.. [CK2008] Derek G. Corneil and Richard M. Krueger, *A Unified View
of Graph Searching*, SIAM Jounal on Discrete Mathematics,
22(4), 1259–-1276, 2008.
Expand Down Expand Up @@ -1647,6 +1651,11 @@ REFERENCES:

.. [CrNa2020] \J.E. Cremona and F. Najman, `\QQ`-curves over odd degree number fields, :arxiv:`2004.10054`.

.. [CreSuth2023] \J.E. Cremona and A.V. Sutherland.
*Computing the endomorphism ring of an elliptic curve
over a number field*.
:arxiv:`2301.11169`.

.. [CoCo1] J.H. Conway, H.S.M. Coxeter
*Triangulated polygons and frieze patterns*,
The Mathematical Gazette (1973) 57 p.87-94
Expand Down Expand Up @@ -3699,6 +3708,11 @@ REFERENCES:
.. [KMOY2007] \M. Kashiwara, K. C. Misra, M. Okado, D. Yamada.
*Perfect crystals for* `U_q(D_4^{(3)})`, J. Algebra. **317** (2007).

.. [Klaise2012] Janis Klaise.
*Orders in imaginary quadratic fields of small class number*
University of Warwick Undergraduate Masters thesis, unpublished (2012).
https://warwick.ac.uk/fac/cross_fac/complexity/people/students/dtc/students2013/klaise/janis_klaise_ug_report.pdf

.. [KMR2012] \A. Kleshchev, A. Mathas, and A. Ram, *Universal Specht
modules for cyclotomic Hecke algebras*,
Proc. London Math. Soc. (2012) 105 (6): 1245-1289.
Expand Down Expand Up @@ -5860,6 +5874,12 @@ REFERENCES:
Mathematics of Computation **80** (2011), pp. 477-500.
:arxiv:`0809.3413v3`.

.. [RouSuthZur2022] Jeremy Rouse, Andrew V. Sutherland, David Zureick-Brown.
*`\ell`-adic images of Galois for elliptic curves over `\Q`* (and an appendix with John Voight).
Forum of Mathematics, Sigma , Volume 10 , 2022.
:doi: `10.1017/fms.2022.38`.
:arxiv:`2106.11141`.

.. [SV1970] \H. Schneider and M. Vidyasagar. Cross-positive matrices. SIAM
Journal on Numerical Analysis, 7:508-519, 1970.

Expand Down Expand Up @@ -6177,6 +6197,11 @@ REFERENCES:
.. [Watkins] Mark Watkins, *Hypergeometric motives over Q and their
L-functions*, http://magma.maths.usyd.edu.au/~watkins/papers/known.pdf

.. [Watkins2004] Mark Watkins.
*Class numbers of imaginary quadratic fields*.
Math. Comp. 73 (2004), 907-938.
https://www.ams.org/journals/mcom/2004-73-246/S0025-5718-03-01517-5/

.. [Wat2003] Joel Watson. *Strategy: an introduction to game
theory*. WW Norton, 2002.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ field).
::

sage: w = [-1,-2,..,-200]
sage: v = [D for D in w if is_fundamental_discriminant(D)]
sage: v = [D for D in w if D.is_fundamental_discriminant()]
sage: v
[-3, -4, -7, -8, -11, -15, -19, -20, ..., -195, -199]

Expand Down Expand Up @@ -222,7 +222,7 @@ class number :math:`1`!
::

sage: w = [1..1000]
sage: v = [D for D in w if is_fundamental_discriminant(D)]
sage: v = [D for D in w if D.is_fundamental_discriminant()]
sage: len(v)
302
sage: len([D for D in v if QuadraticField(D,'a').class_number() == 1])
Expand Down
4 changes: 2 additions & 2 deletions src/sage/quadratic_forms/binary_qf.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def has_fundamental_discriminant(self):
sage: Q.has_fundamental_discriminant()
False
"""
return is_fundamental_discriminant(self.discriminant())
return self.discriminant().is_fundamental_discriminant()

def is_primitive(self):
r"""
Expand Down Expand Up @@ -1774,7 +1774,7 @@ def BinaryQF_reduced_representatives(D, primitive_only=False, proper=True):

# For a fundamental discriminant all forms are primitive so we need not check:
if primitive_only:
primitive_only = not is_fundamental_discriminant(D)
primitive_only = not D.is_fundamental_discriminant()

form_list = []

Expand Down
2 changes: 1 addition & 1 deletion src/sage/quadratic_forms/special_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def QuadraticBernoulliNumber(k, d):

Let us create a list of some odd negative fundamental discriminants::

sage: test_set = [d for d in range(-163, -3, 4) if is_fundamental_discriminant(d)]
sage: test_set = [d for d in srange(-163, -3, 4) if d.is_fundamental_discriminant()]

In general, we have `B_{1, \chi_d} = -2 h/w` for odd negative fundamental
discriminants::
Expand Down
72 changes: 70 additions & 2 deletions src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5590,7 +5590,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
- ``proof`` (boolean, default ``True``) -- if ``False`` then
for negative discriminants a faster algorithm is used by
the PARI library which is known to give incorrect results
when the class group has many cyclic factors.
when the class group has many cyclic factors. However the
results are correct for discriminants `D` with `|D|\le 2\cdot10^{10}`.

OUTPUT:

Expand All @@ -5599,7 +5600,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):

.. NOTE::

This is not always equal to the number of classes of
For positive `D`, this is not always equal to the number of classes of
primitive binary quadratic forms of discriminant `D`, which
is equal to the narrow class number. The two notions are
the same when `D<0`, or `D>0` and the fundamental unit of
Expand Down Expand Up @@ -6034,6 +6035,73 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
"""
return self.__pari__().issquarefree()

def is_discriminant(self):
"""
Returns True if this integer is a discriminant.

.. NOTE::

A discriminant is an integer congruent to 0 or 1 modulo 4.

EXAMPLES::

sage: (-1).is_discriminant()
False
sage: (-4).is_discriminant()
True
sage: 100.is_discriminant()
True
sage: 101.is_discriminant()
True

TESTS::

sage: 0.is_discriminant()
True
sage: 1.is_discriminant()
True
sage: len([D for D in srange(-100,100) if D.is_discriminant()])
100
"""
return self%4 in [0,1]

def is_fundamental_discriminant(self):
"""
Returns True if this integer is a fundamental_discriminant.

.. NOTE::

A fundamental discriminant is a discrimimant, not 0 or 1 and not a square multiple of a smaller discriminant.

EXAMPLES::

sage: (-4).is_fundamental_discriminant()
True
sage: (-12).is_fundamental_discriminant()
False
sage: 101.is_fundamental_discriminant()
True

TESTS::

sage: 0.is_fundamental_discriminant()
False
sage: 1.is_fundamental_discriminant()
False
sage: len([D for D in srange(-100,100) if D.is_fundamental_discriminant()])
61

"""
if self in [0,1]:
return False
Dmod4 = self%4
if Dmod4 in [2,3]:
return False
if Dmod4 == 1:
return self.is_squarefree()
d = self//4
return d%4 in [2,3] and d.is_squarefree()

cpdef __pari__(self):
"""
Returns the PARI version of this integer.
Expand Down
11 changes: 5 additions & 6 deletions src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -12188,16 +12188,15 @@ def is_fundamental_discriminant(D):
EXAMPLES::

sage: [D for D in range(-15,15) if is_fundamental_discriminant(D)]
...
DeprecationWarning: is_fundamental_discriminant(D) is deprecated; please use D.is_fundamental_discriminant()
...
[-15, -11, -8, -7, -4, -3, 5, 8, 12, 13]
sage: [D for D in range(-15,15) if not is_square(D) and QuadraticField(D,'a').disc() == D]
[-15, -11, -8, -7, -4, -3, 5, 8, 12, 13]
"""
d = D % 4
if d not in [0, 1]:
return False
return D != 1 and D != 0 and \
(arith.is_squarefree(D) or
(d == 0 and (D // 4) % 4 in [2, 3] and arith.is_squarefree(D // 4)))
deprecation(35147, "is_fundamental_discriminant(D) is deprecated; please use D.is_fundamental_discriminant()")
return Integer(D).is_fundamental_discriminant()


###################
Expand Down
8 changes: 0 additions & 8 deletions src/sage/rings/number_field/number_field_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4676,10 +4676,6 @@ cdef class NumberFieldElement_absolute(NumberFieldElement):
sage: a.absolute_charpoly(algorithm='pari') == a.absolute_charpoly(algorithm='sage')
True
"""
# this hack is necessary because quadratic fields override
# charpoly(), and they don't take the argument 'algorithm'
if algorithm is None:
return self.charpoly(var)
return self.charpoly(var, algorithm)

def absolute_minpoly(self, var='x', algorithm=None):
Expand Down Expand Up @@ -4707,10 +4703,6 @@ cdef class NumberFieldElement_absolute(NumberFieldElement):
sage: b.absolute_minpoly(algorithm='pari') == b.absolute_minpoly(algorithm='sage')
True
"""
# this hack is necessary because quadratic fields override
# minpoly(), and they don't take the argument 'algorithm'
if algorithm is None:
return self.minpoly(var)
return self.minpoly(var, algorithm)

def charpoly(self, var='x', algorithm=None):
Expand Down
35 changes: 28 additions & 7 deletions src/sage/rings/number_field/number_field_element_quadratic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2129,10 +2129,16 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
# D = 1 mod 4
return mpz_fdiv_ui(self.D.value, 4) == 1

def charpoly(self, var='x'):
def charpoly(self, var='x', algorithm=None):
r"""
The characteristic polynomial of this element over `\QQ`.

INPUT:

- ``var`` -- the minimal polynomial is defined over a polynomial ring
in a variable with this name. If not specified this defaults to ``x``
- ``algorithm`` -- for compatibility with general number field elements; ignored

EXAMPLES::

sage: K.<a> = NumberField(x^2-x+13)
Expand All @@ -2147,15 +2153,16 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
R = QQ[var]
return R([self.norm(), -self.trace(), 1])

def minpoly(self, var='x'):
def minpoly(self, var='x', algorithm=None):
r"""
The minimal polynomial of this element over `\QQ`.

INPUT:

- ``var`` -- the minimal polynomial is defined over a polynomial ring
in a variable with this name. If not specified this defaults to
``x``.
- ``var`` -- the minimal polynomial is defined over a polynomial ring
in a variable with this name. If not specified this defaults to ``x``
- ``algorithm`` -- for compatibility with general number field elements: and ignored


EXAMPLES::

Expand Down Expand Up @@ -2651,11 +2658,18 @@ cdef class OrderElement_quadratic(NumberFieldElement_quadratic):
"""
return ZZ(NumberFieldElement_quadratic.trace(self))

def charpoly(self, var='x'):
def charpoly(self, var='x', algorithm=None):
r"""
The characteristic polynomial of this element, which is over `\ZZ`
because this element is an algebraic integer.

INPUT:

- ``var`` -- the minimal polynomial is defined over a polynomial ring
in a variable with this name. If not specified this defaults to ``x``
- ``algorithm`` -- for compatibility with general number field elements; ignored


EXAMPLES::

sage: K.<a> = NumberField(x^2 - 5)
Expand All @@ -2671,10 +2685,17 @@ cdef class OrderElement_quadratic(NumberFieldElement_quadratic):
R = ZZ[var]
return R([self.norm(), -self.trace(), 1])

def minpoly(self, var='x'):
def minpoly(self, var='x', algorithm=None):
r"""
The minimal polynomial of this element over `\ZZ`.

INPUT:

- ``var`` -- the minimal polynomial is defined over a polynomial ring
in a variable with this name. If not specified this defaults to ``x``
- ``algorithm`` -- for compatibility with general number field elements; ignored


EXAMPLES::

sage: K.<a> = NumberField(x^2 + 163)
Expand Down