# Cremona’s tables of elliptic curves¶

Sage includes John Cremona’s tables of elliptic curves in an easy-to-use format. An instance of the class CremonaDatabase() gives access to the database.

If the optional full CremonaDatabase is not installed, a mini-version is included by default with Sage. It contains Weierstrass equations, rank, and torsion for curves up to conductor 10000.

The large database includes all curves in John Cremona’s tables. It also includes data related to the BSD conjecture and modular degrees for all of these curves, and generators for the Mordell-Weil groups. To install it type the following in Sage:

!sage -i database_cremona_ellcurve


Both the mini and full versions of John Cremona’s tables are stored in SAGE_SHARE/cremona as SQLite databases. The mini version has the layout:

CREATE TABLE t_class(conductor INTEGER, class TEXT PRIMARY KEY, rank INTEGER);
CREATE TABLE t_curve(class TEXT, curve TEXT PRIMARY KEY, eqn TEXT UNIQUE, tors INTEGER);
CREATE INDEX i_t_class_conductor ON t_class(conductor);
CREATE INDEX i_t_curve_class ON t_curve(class);


while the full version has the layout:

CREATE TABLE t_class(conductor INTEGER, class TEXT PRIMARY KEY, rank INTEGER, L REAL, deg INTEGER);
CREATE TABLE t_curve(class TEXT, curve TEXT PRIMARY KEY, eqn TEXT UNIQUE, gens TEXT, tors INTEGER, cp INTEGER, om REAL, reg REAL, sha);
CREATE INDEX i_t_class_conductor ON t_class(conductor);
CREATE INDEX i_t_curve_class ON t_curve(class);


Initializes the Cremona database with name name. If name is None it instead initializes large Cremona database (named ‘cremona’), if available or default mini Cremona database (named ‘cremona mini’).

If the Cremona database in question is in the format of the mini database, you must set mini=True, otherwise it must be set to False.

If you would like other components of Sage to use this database, mark set_global=True.

TESTS:

sage: c = CremonaDatabase()
True
sage: isinstance(c, sage.databases.cremona.LargeCremonaDatabase)  # optional - database_cremona_ellcurve
True


Verify that trac ticket #12341 has been resolved:

sage: c = CremonaDatabase('should not exist',mini=True)
Traceback (most recent call last):
...
ValueError: Desired database (='should not exist') does not exist
sage: c = CremonaDatabase('should not exist',mini=False)
Traceback (most recent call last):
...
ValueError: Desired database (='should not exist') does not exist
sage: from sage.env import SAGE_SHARE
sage: os.path.isfile(os.path.join(SAGE_SHARE,'cremona','should_not_exist.db'))
False


The Cremona database of elliptic curves.

EXAMPLES:

sage: c = CremonaDatabase('cremona')  # optional - database_cremona_ellcurve
sage: c.allcurves(11)                 # optional - database_cremona_ellcurve
{'a1': [[0, -1, 1, -10, -20], 0, 5], 'a3': [[0, -1, 1, 0, 0], 0, 5],
'a2': [[0, -1, 1, -7820, -263580], 0, 1]}

allbsd(N)

Return the allbsd table for conductor N. The entries are:

[id, tamagawa_product, Omega_E, L, Reg_E, Sha_an(E)]


where id is the isogeny class (letter) followed by a number, e.g., b3, and L is $$L^r(E,1)/r!$$, where E has rank r.

INPUT:

• N - int, the conductor

OUTPUT: dict containing the allbsd table for each isogeny class in conductor N

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.allbsd(12)            # optional - database_cremona_ellcurve
{}
sage: c.allbsd(19)['a3']      # optional - database_cremona_ellcurve
[1, 4.07927920046493, 0.453253244496104, 1.0, 1]
sage: c.allbsd(12001)['a1']   # optional - database_cremona_ellcurve
[2, 3.27608135248722, 1.54910143090506, 0.236425971187952, 1.0]

allgens(N)

Return the allgens table for conductor N.

INPUT:

• N - int, the conductor

OUTPUT:

• dict - id:[points, ...], ...

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.allgens(12)            # optional - database_cremona_ellcurve
{}
sage: c.allgens(1001)['a1']    # optional - database_cremona_ellcurve
[[61, 181, 1]]
sage: c.allgens(12001)['a1']   # optional - database_cremona_ellcurve
[[7, 2, 1]]

degphi(N)

Return the degphi table for conductor N.

INPUT:

• N - int, the conductor

OUTPUT:

• dict - id:degphi, ...

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.degphi(11)            # optional - database_cremona_ellcurve
{'a1': 1}
sage: c.degphi(12001)['c1']   # optional - database_cremona_ellcurve
1640


Bases: sage.databases.sql_db.SQLDatabase

The Cremona database of elliptic curves.

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.allcurves(11)
{'a1': [[0, -1, 1, -10, -20], 0, 5],
'a2': [[0, -1, 1, -7820, -263580], 0, 1],
'a3': [[0, -1, 1, 0, 0], 0, 5]}

allcurves(N)

Returns the allcurves table of curves of conductor N.

INPUT:

• N - int, the conductor

OUTPUT:

• dict - id:[ainvs, rank, tor], ...

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.allcurves(11)['a3']
[[0, -1, 1, 0, 0], 0, 5]
sage: c.allcurves(12)
{}
sage: c.allcurves(12001)['a1']   # optional - database_cremona_ellcurve
[[1, 0, 0, -101, 382], 1, 1]

coefficients_and_data(label)

Return the Weierstrass coefficients and other data for the curve with given label.

EXAMPLES:

sage: c, d = CremonaDatabase().coefficients_and_data('144b1')
sage: c
[0, 0, 0, 6, 7]
sage: d['conductor']
144
sage: d['cremona_label']
'144b1'
sage: d['rank']
0
sage: d['torsion_order']
2

conductor_range()

Return the range of conductors that are covered by the database.

OUTPUT: tuple of ints (N1,N2+1) where N1 is the smallest and N2 the largest conductor for which the database is complete.

EXAMPLES:

sage: c = CremonaDatabase('cremona mini')
sage: c.conductor_range()
(1, 10000)

curves(N)

Returns the curves table of all optimal curves of conductor N.

INPUT:

• N - int, the conductor

OUTPUT:

• dict - id:[ainvs, rank, tor], ...

EXAMPLES:

Optimal curves of conductor 37:

sage: CremonaDatabase().curves(37)
{'a1': [[0, 0, 1, -1, 0], 1, 1], 'b1': [[0, 1, 1, -23, -50], 0, 3]}


Note the ‘h3’, which is the unique case in the tables where the optimal curve doesn’t have label ending in 1:

sage: list(sorted(CremonaDatabase().curves(990).keys()))
['a1', 'b1', 'c1', 'd1', 'e1', 'f1', 'g1', 'h3', 'i1', 'j1', 'k1', 'l1']


TESTS:

sage: c = CremonaDatabase()
sage: c.curves(12001)['a1']   # optional - database_cremona_ellcurve
[[1, 0, 0, -101, 382], 1, 1]

data_from_coefficients(ainvs)

Return elliptic curve data for the curve with given Weierstrass coefficients.

EXAMPLES:

sage: d = CremonaDatabase().data_from_coefficients([1, -1, 1, 31, 128])
sage: d['conductor']
1953
sage: d['cremona_label']
'1953c1'
sage: d['rank']
1
sage: d['torsion_order']
2

elliptic_curve(label)

Return an elliptic curve with given label with some data about it from the database pre-filled in.

INPUT:

• label - str (Cremona or LMFDB label)

OUTPUT:

Note

For more details on LMFDB labels see parse_lmfdb_label().

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.elliptic_curve('11a1')
Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field
sage: c.elliptic_curve('12001a1')    # optional - database_cremona_ellcurve
Elliptic Curve defined by y^2 + x*y = x^3 - 101*x + 382 over Rational Field
sage: c.elliptic_curve('48c1')
Traceback (most recent call last):
...
ValueError: There is no elliptic curve with label 48c1 in the database


You can also use LMFDB labels:

sage: c.elliptic_curve('462.f3')
Elliptic Curve defined by y^2 + x*y = x^3 - 363*x + 1305 over Rational Field

elliptic_curve_from_ainvs(ainvs)

Returns the elliptic curve in the database of with minimal ainvs, if it exists, or raises a RuntimeError exception otherwise.

INPUT:

• ainvs - list (5-tuple of int’s); the minimal Weierstrass model for an elliptic curve

OUTPUT: EllipticCurve

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.elliptic_curve_from_ainvs([0, -1, 1, -10, -20])
Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field
sage: c.elliptic_curve_from_ainvs([1, 0, 0, -101, 382])  # optional - database_cremona_ellcurve
Elliptic Curve defined by y^2 + x*y = x^3 - 101*x + 382 over Rational Field


Old (pre-2006) Cremona labels are also allowed:

sage: c.elliptic_curve('9450KKKK1')
Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 5*x + 7 over Rational Field


Make sure trac ticket #12565 is fixed:

sage: c.elliptic_curve('10a1')
Traceback (most recent call last):
...
ValueError: There is no elliptic curve with label 10a1 in the database

isogeny_class(label)

Returns the isogeny class of elliptic curves that are isogenous to the curve with given Cremona label.

INPUT:

• label - string

OUTPUT:

• list - list of EllipticCurve objects.

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.isogeny_class('11a1')
[Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field,
Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field,
Elliptic Curve defined by y^2 + y = x^3 - x^2 over Rational Field]
sage: c.isogeny_class('12001a1')   # optional - database_cremona_ellcurve
[Elliptic Curve defined by y^2 + x*y = x^3 - 101*x + 382 over Rational Field]

isogeny_classes(conductor)

Return the allcurves data (ainvariants, rank and torsion) for the elliptic curves in the database of given conductor as a list of lists, one for each isogeny class. The curve with number 1 is always listed first.

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.isogeny_classes(11)
[[[[0, -1, 1, -10, -20], 0, 5],
[[0, -1, 1, -7820, -263580], 0, 1],
[[0, -1, 1, 0, 0], 0, 5]]]
sage: c.isogeny_classes(12001)   # optional - database_cremona_ellcurve
[[[[1, 0, 0, -101, 382], 1, 1]],
[[[0, 0, 1, -247, 1494], 1, 1]],
[[[0, 0, 1, -4, -18], 1, 1]],
[[[0, 1, 1, -10, 18], 1, 1]]]

iter(conductors)

Return an iterator through all curves in the database with given conductors.

INPUT:

• conductors - list or generator of ints

OUTPUT: generator that iterates over EllipticCurve objects.

EXAMPLES:

sage: [e.cremona_label() for e in CremonaDatabase().iter([11..15])]
['11a1', '11a2', '11a3', '14a1', '14a2', '14a3', '14a4', '14a5',
'14a6', '15a1', '15a2', '15a3', '15a4', '15a5', '15a6', '15a7', '15a8']

iter_optimal(conductors)

Return an iterator through all optimal curves in the database with given conductors.

INPUT:

• conductors - list or generator of ints

OUTPUT:

generator that iterates over EllipticCurve objects.

EXAMPLES:

We list optimal curves with conductor up to 20:

sage: [e.cremona_label() for e in CremonaDatabase().iter_optimal([11..20])]
['11a1', '14a1', '15a1', '17a1', '19a1', '20a1']


Note the unfortunate 990h3 special case:

sage: [e.cremona_label() for e in CremonaDatabase().iter_optimal([990])]
['990a1', '990b1', '990c1', '990d1', '990e1', '990f1', '990g1', '990h3', '990i1', '990j1', '990k1', '990l1']

largest_conductor()

The largest conductor for which the database is complete.

OUTPUT:

• int - largest conductor

EXAMPLES:

sage: c = CremonaDatabase('cremona mini')
sage: c.largest_conductor()
9999

list(conductors)

Returns a list of all curves with given conductors.

INPUT:

• conductors - list or generator of ints

OUTPUT:

• list of EllipticCurve objects.

EXAMPLES:

sage: CremonaDatabase().list([37])
[Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field,
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 23*x - 50 over Rational Field,
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 1873*x - 31833 over Rational Field,
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 3*x + 1 over Rational Field]

list_optimal(conductors)

Returns a list of all optimal curves with given conductors.

INPUT:

• conductors - list or generator of ints

list of EllipticCurve objects.

OUTPUT:

list of EllipticCurve objects.

EXAMPLES:

sage: CremonaDatabase().list_optimal([37])
[Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field,
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 23*x - 50 over Rational Field]

number_of_curves(N=0, i=0)

Returns the number of curves stored in the database with conductor N. If N = 0, returns the total number of curves in the database.

If i is nonzero, returns the number of curves in the i-th isogeny class. If i is a Cremona letter code, e.g., ‘a’ or ‘bc’, it is converted to the corresponding number.

INPUT:

• N - int
• i - int or str

OUTPUT: int

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.number_of_curves(11)
3
sage: c.number_of_curves(37)
4
sage: c.number_of_curves(990)
42
sage: num = c.number_of_curves()

number_of_isogeny_classes(N=0)

Returns the number of isogeny classes of curves in the database of conductor N. If N is 0, return the total number of isogeny classes of curves in the database.

INPUT:

• N - int

OUTPUT: int

EXAMPLES:

sage: c = CremonaDatabase()
sage: c.number_of_isogeny_classes(11)
1
sage: c.number_of_isogeny_classes(37)
2
sage: num = c.number_of_isogeny_classes()

random()

Returns a random curve from the database.

EXAMPLES:

sage: CremonaDatabase().random() # random -- depends on database installed
Elliptic Curve defined by y^2 + x*y  = x^3 - x^2 - 224*x + 3072 over Rational Field

smallest_conductor()

The smallest conductor for which the database is complete: always 1.

OUTPUT:

• int - smallest conductor

Note

This always returns the integer 1, since that is the smallest conductor for which the database is complete, although there are no elliptic curves of conductor 1. The smallest conductor of a curve in the database is 11.

EXAMPLES:

sage: CremonaDatabase().smallest_conductor()
1

sage.databases.cremona.build(name, data_tgz, largest_conductor=0, mini=False, decompress=True)

Build the CremonaDatabase with given name from scratch using the data_tgz tarball.

... note:

For data up to level 350000, this function takes about
3m40s.  The resulting database occupies 426MB disk space.


To create the large Cremona database from Cremona’s data_tgz tarball, obtainable from http://homepages.warwick.ac.uk/staff/J.E.Cremona/ftp/data/, run the following command:

sage: d = sage.databases.cremona.build('cremona','ecdata.tgz')   # not tested

sage.databases.cremona.class_to_int(k)

Converts class id string into an integer. Note that this is the inverse of cremona_letter_code.

EXAMPLES:

sage: import sage.databases.cremona as cremona
sage: cremona.class_to_int('ba')
26
sage: cremona.class_to_int('cremona')
821863562
sage: cremona.cremona_letter_code(821863562)
'cremona'

sage.databases.cremona.cmp_code(key1, key2)

Comparison function for curve id strings.

Note

Not the same as standard lexicographic order!

EXAMPLES:

sage: import sage.databases.cremona as cremona
sage: cremona.cmp_code('ba1','z1')
1


By contrast:

sage: cmp('ba1','z1')
-1

sage.databases.cremona.cremona_letter_code(n)

Returns the Cremona letter code corresponding to an integer. For example, 0 - a 25 - z 26 - ba 51 - bz 52 - ca 53 - cb etc.

Note

This is just the base 26 representation of n, where a=0, b=1, ..., z=25. This extends the old Cremona notation (counting from 0) for the first 26 classes, and is different for classes above 26.

INPUT:

• n (int) – a non-negative integer

OUTPUT: str

EXAMPLES:

sage: from sage.databases.cremona import cremona_letter_code
sage: cremona_letter_code(0)
'a'
sage: cremona_letter_code(26)
'ba'
sage: cremona_letter_code(27)
'bb'
sage: cremona_letter_code(521)
'ub'
sage: cremona_letter_code(53)
'cb'
sage: cremona_letter_code(2005)
'czd'


TESTS:

sage: cremona_letter_code(QQ)
Traceback (most recent call last):
...
ValueError: Cremona letter codes are only defined for non-negative integers
sage: cremona_letter_code(x)
Traceback (most recent call last):
...
ValueError: Cremona letter codes are only defined for non-negative integers
sage: cremona_letter_code(-1)
Traceback (most recent call last):
...
ValueError: Cremona letter codes are only defined for non-negative integers
sage: cremona_letter_code(3.14159)
Traceback (most recent call last):
...
ValueError: Cremona letter codes are only defined for non-negative integers

sage.databases.cremona.cremona_to_lmfdb(cremona_label, CDB=None)

Converts a Cremona label into an LMFDB label.

See parse_lmfdb_label() for an explanation of LMFDB labels.

INPUT:

• cremona_label – a string, the Cremona label of a curve. This can be the label of a curve (e.g. ‘990j1’) or of an isogeny class (e.g. ‘990j’)
• CDB – the Cremona database in which to look up the isogeny classes of the same conductor.

OUTPUT:

• lmfdb_label – a string, the corresponding LMFDB label.

EXAMPLES:

sage: from sage.databases.cremona import cremona_to_lmfdb, lmfdb_to_cremona
sage: cremona_to_lmfdb('990j1')
'990.h3'
sage: lmfdb_to_cremona('990.h3')
'990j1'


TESTS:

sage: for label in ['5077a1','66a3','102b','420c2']:
...       assert(lmfdb_to_cremona(cremona_to_lmfdb(label)) == label)
sage: for label in ['438.c2','306.b','462.f3']:
...       assert(cremona_to_lmfdb(lmfdb_to_cremona(label)) == label)

sage.databases.cremona.is_optimal_id(id)

Returns true if the Cremona id refers to an optimal curve, and false otherwise. The curve is optimal if the id, which is of the form [letter code][number] has number 1.

Note

990h3 is the optimal curve in that class, so doesn’t obey this rule.

INPUT:

• id - str of form letter code followed by an integer, e.g., a3, bb5, etc.

OUTPUT: bool

EXAMPLES:

sage: from sage.databases.cremona import is_optimal_id
sage: is_optimal_id('b1')
True
sage: is_optimal_id('bb1')
True
sage: is_optimal_id('c1')
True
sage: is_optimal_id('c2')
False

sage.databases.cremona.lmfdb_to_cremona(lmfdb_label, CDB=None)

Converts an LMFDB labe into a Cremona label.

See parse_lmfdb_label() for an explanation of LMFDB labels.

INPUT:

• lmfdb_label – a string, the LMFDB label of a curve. This can be the label of a curve (e.g. ‘990.j1’) or of an isogeny class (e.g. ‘990.j’)
• CDB – the Cremona database in which to look up the isogeny classes of the same conductor.

OUTPUT:

• cremona_label – a string, the corresponding Cremona label.

EXAMPLES:

sage: from sage.databases.cremona import cremona_to_lmfdb, lmfdb_to_cremona
sage: lmfdb_to_cremona('990.h3')
'990j1'
sage: cremona_to_lmfdb('990j1')
'990.h3'

sage.databases.cremona.old_cremona_letter_code(n)

Returns the old Cremona letter code corresponding to an integer. integer.

For example:

1  --> A
26 --> Z
27 --> AA
52 --> ZZ
53 --> AAA
etc.


INPUT:

• n - int

OUTPUT: str

EXAMPLES:

sage: from sage.databases.cremona import old_cremona_letter_code
sage: old_cremona_letter_code(1)
'A'
sage: old_cremona_letter_code(26)
'Z'
sage: old_cremona_letter_code(27)
'AA'
sage: old_cremona_letter_code(521)
'AAAAAAAAAAAAAAAAAAAAA'
sage: old_cremona_letter_code(53)
'AAA'
sage: old_cremona_letter_code(2005)
'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'

sage.databases.cremona.parse_cremona_label(label)

Given a Cremona label that defines an elliptic curve, e.g., 11a1 or 37b3, parse the label and return the conductor, isogeny class label, and number.

For this function, the curve number may be omitted, in which case it defaults to 1. If the curve number and isogeny class are both omitted (label is just a string representing a conductor), then the isogeny class defaults to ‘a’ and the number to 1. Valid labels consist of one or more digits, followed by zero or more letters (either all in upper case for an old Cremona label, or all in lower case), followed by zero or more digits.

INPUT:

• label - str

OUTPUT:

• int - the conductor
• str - the isogeny class label
• int - the number

EXAMPLES:

sage: from sage.databases.cremona import parse_cremona_label
sage: parse_cremona_label('37a2')
(37, 'a', 2)
sage: parse_cremona_label('37b1')
(37, 'b', 1)
sage: parse_cremona_label('10bb2')
(10, 'bb', 2)
sage: parse_cremona_label('11a')
(11, 'a', 1)
sage: parse_cremona_label('11')
(11, 'a', 1)


Valid old Cremona labels are allowed:

sage: parse_cremona_label('17CCCC')
(17, 'dc', 1)
sage: parse_cremona_label('5AB2')
Traceback (most recent call last):
...
ValueError: 5AB2 is not a valid Cremona label


TESTS:

sage: from sage.databases.cremona import parse_cremona_label
sage: parse_cremona_label('x11')
Traceback (most recent call last):
...
ValueError: x11 is not a valid Cremona label

sage.databases.cremona.parse_lmfdb_label(label)

Given an LMFDB label that defines an elliptic curve, e.g., 11.a1 or 37.b3, parse the label and return the conductor, isogeny class label, and number.

The LMFDB label (named after the L-functions and modular forms database), is determined by the following two orders:

• Isogeny classes with the same conductor are ordered lexicographically by the coefficients in the q-expansion of the associated modular form.
• Curves within the same isogeny class are ordered lexicographically by the a-invariants of the minimal model.

The format is <conductor>.<iso><curve>, where the isogeny class is encoded using the same base-26 encoding into letters used in Cremona’s labels. For example, 990.h3 is the same as Cremona’s 990j1

For this function, the curve number may be omitted, in which case it defaults to 1. If the curve number and isogeny class are both omitted (label is just a string representing a conductor), then the isogeny class defaults to ‘a’ and the number to 1.

INPUT:

• label - str

OUTPUT:

• int - the conductor
• str - the isogeny class label
• int - the number

EXAMPLES:

sage: from sage.databases.cremona import parse_lmfdb_label
sage: parse_lmfdb_label('37.a2')
(37, 'a', 2)
sage: parse_lmfdb_label('37.b')
(37, 'b', 1)
sage: parse_lmfdb_label('10.bb2')
(10, 'bb', 2)

sage.databases.cremona.split_code(key)

Splits class+curve id string into its two parts.

EXAMPLES:

sage: import sage.databases.cremona as cremona
sage: cremona.split_code('ba2')
('ba', '2')


Databases

#### Next topic

The Stein-Watkins table of elliptic curves