Congruent Numbers Part II

Using Elliptic Curves to Compute the Triangles

The method of my first post is too slow to find the side lengths for a triangle of area , which has many digits:

In the 1984 book by Koblitz, Introduction to Elliptic Curves and Modular Forms, computation of the side lengths for is credited to the mathematician Don Zagier. Now, however, it can be computed quickly by anyone with access to the SageMath system. The Python code given below computes the values for in less than one minute on my Mac laptop.

Put the code in the next section into a file called (say) congruent.py, fire up SageMath, and then type load(‘congruent.py’) followed by print_range(157, 157, 13). This produces the answer in about 15 seconds.

This post has three parts: I derive equations that produce triangle side lengths for congruent numbers; I give Python code that implements the equations; and I present two tables of congruent numbers. The first table is for , and is a variant of the web table. The second is an incomplete table for constructed using the Python code.

The equations

Exhaustive search is too slow to find the sides of the triangle with area ; finding them requires a new idea. That idea is to reduce the search to a problem in elliptic curves (the same idea used to prove Fermat’s Last Theorem!).

An elliptic curve is the next level of complexity after a quadratic curve. A quadratic curve is ; an elliptic curve is . For the congruent number problem, Koblitz’s book Introduction to Elliptic Curves and Modular Forms shows the connection between a congruent and the elliptic curve . I summarize it here.

The connection involves adding points. For a conic section like a circle each point can be represented by , and two points , with angles , can be added to get a third point with angle . In a formula

with a similar formula for . So the formula for is a rational function of , where is our special addition, not vector addition. In the same way, two points on an elliptic curve can be added, and there is a formula for the sum. If and then the formula for (I don’t need ) is

If is a point of

this simplifies to

In that equation , and are rational numbers. I need a formula in terms of their numerators and denominators. So write

(1)

Then

Next, use Koblitz page 47, which says that if is the sum of a point on with itself, then you get rational sides with area for sides , with

so

Or since ,

This gives an algorithm that can find the sides’ lengths for area , and is fast enough to work for . Use SageMath to find a point on . Next use equation (1) to define , , , and the equation after that to get and . And use the equations directly above to get the side lengths and .

Python code for SageMath

Here is the code that implements the algorithm of the previous section.

The table through 1000

Here is a table with the side lengths of congruent numbers. Like the web tables, it gives and rather than the side lengths , , but I give and in factored form. In addition it differs from the web table at , , , and . The changes at and give fractions with a smaller denominator. The change at fixes the glitch wherein both and are both odd.

The change at adds a second solution with the same denominator. I remarked before that there are multiple values of , (or equivalently , , ) for each , and that I would pick the one with the smallest . This doesn’t always select a unique triangle. For example has both and , both with . Other such examples are

An incomplete table for 1000 to 2000

One of the motivations for writing the code in this posting was to try computing the side lengths for . Of the 358 square-free congruent numbers between 1000 and 2000, the code was able to find sides for all but 50. I’d be thrilled to hear about more sophisticated algorithms that can compute these missing entries. Here are the entries I was able to compute, also available as a separate file.