In the previous post, we introduced the Weil pairing and Tate pairing on elliptic curves. In this article, we explore some applications of elliptic curves in Diophantine equations.
Problem Zero
In middle school mathematics, we learned that right triangles satisfy the Pythagorean theorem. Let the two legs be and , and the hypotenuse be . The formula is:
So, are there infinitely many right triangles with all three sides being integers?
This is a classic example of a Diophantine equation. Generally, Diophantine equations are equations with one or more variables and integer coefficients, and their solutions are sought only within the integer domain.
The simplest equations we learn are linear Diophantine equations, which take the form:
where are integers, and are unknowns. This equation can be solved using the extended Euclidean algorithm.
Of course, the above problem does not require the use of elliptic curves for analysis (which is why it's called "Problem Zero").
Below is the solution to Problem Zero. Note that:
This was actually noticed in one of my middle school math teacher's classes.
Therefore, there are infinitely many right triangles with all three sides being integers. Let , and simply take , , to satisfy the condition.
For example:
Question 1
In elementary school mathematics, we learned that the area of a right triangle is:
So the question is: can we find a right triangle with area and all side lengths rational? If such a triangle exists, are there infinitely many such right triangles?
This problem is equivalent to solving a Diophantine equation with two conditions:
We are to find its rational solutions. If we try to substitute and with and as before, the equation becomes:
The degree of the equation becomes , which seems more difficult to solve than the previous one. So let's try a different approach:
We observe that:
This is noted in the textbook, and it should be more obvious than the previous one.
Therefore, let . The problem can be transformed into:
As long as we find a solution where are all rational squares, we can find the corresponding that satisfy the conditions.
If , , and are all rational squares, then their product is also a rational square. This leads us to the main character of this problem—the elliptic curve:
We aim to find non-trivial rational points on this curve.
Finding the First Solution
We can first identify three rational points: and . However, the area of the triangle cannot be zero, so this set of solutions is trivial. (Moreover, and are not squares of rational numbers.)
Through a simple search, we can find a non-trivial rational point . Although this point is non-trivial, there is no real number such that , so no such real exists.
But we can use this point to draw a tangent to and find other rational points (essentially performing a point doubling operation on the elliptic curve).
We attempt to draw the tangent to at the point . First, we use implicit differentiation:
Substituting the point gives , so the tangent function is:
Substituting this function into the equation of , we get:
Expanding this yields a constant term of . By Vieta's formulas, (where is the constant term of the cubic equation). Since the tangent touches at , the equation has a double root , so .
With the corresponding , we can compute . Previously, we had:
Therefore:
We observe that are also squares of rational numbers, allowing us to solve for .
In summary, we obtain a solution , which can be verified to satisfy the Pythagorean theorem and yield an area of .
Proving There Are Infinitely Many Solutions
The next question is: are there infinitely many such triples ? The answer is yes, and we can simply repeat this process (though it becomes inconvenient to do by hand):
Since , we have . Combined with , we get .
Thus, we obtain the next triple . We can continue generating other valid triples by drawing tangents in this way. Here is a brief explanation of why this iterative method always ensures that are rational numbers:
We consider a general equation of the form:
with a non-trivial rational point (i.e., ). We prove that by drawing the tangent at this point, the other intersection point with satisfies that are all rational squares:
First, we find the tangent line:
By Vieta's formulas, we have:
Since and are both (a double root), we have , proving that is a rational square, and thus is rational.
Note that:
This was noticed by DeepSeek R1—my attention wasn't sharp enough (
Thus, are also rational squares. As mentioned earlier:
That is, are also rational numbers. Ultimately, we conclude that and are rational.
We can generate in this iterative manner, ensuring that the corresponding are all rational. Therefore, if the elliptic curve corresponding to has a non-trivial rational point, then there are infinitely many right triangles with rational sides and area . Q.E.D.
Question Two
This is a fishing question a classmate gave me in middle school:
I tried it back then and realized that probably less than 5% of people could solve it. Later, my classmate told me those three extremely long answers, and I began to appreciate the charm of some number theory problems:
A seemingly simple problem statement can have incredibly complex solutions and answers.
Transforming into Weierstrass Form
First, this equation is homogeneous, meaning that once we find a solution , then for any , is also a solution.
Following the idea from Problem 1, we should first consider how to transform the given equation:
into the form of an elliptic curve—this is significantly more challenging than Problem 1.
First, attempt to combine the fractions:
Then, we need to express and using linear combinations of to transform the original expression into the long Weierstrass form:
A zero point of can be found through enumeration. We then draw the tangent line to at . First, compute the partial derivatives of :
Substitute to obtain the specific gradient vector , which gives the tangent line .
Set , substitute into , and obtain . Since point satisfies , the multiplicity of the zero point is . According to Reference 6, we need to find a transformation matrix such that:
is an invertible matrix. A simple approach is to take point as another point on , and the third column as , , or .
For example, take as:
Let , , . Transform into :
Let to obtain an integer-coefficient long Weierstrass form:
Divide both sides by , and let , to obtain:
These are the projective and affine forms mentioned at the beginning of Reference 6.
Now, express in terms of :
Then, we can express in terms of :
Similarly, we can compute the inverse transformation (omitting the free variable ):
Finding a Set of Positive Integer Solutions
Attempting a brute-force enumeration to find integer solutions for the new equation, a script can iterate over , yielding the following sets:
Substituting these solutions back into and excluding cases where the denominator of the original expression is zero, the following integer solutions are obtained:
The fifth and sixth rows correspond to the special solutions used in Reference 4.
However, the corresponding values are not all positive integers. Taking the last solution , we attempt to use the tangent method from Problem 1 to find other rational points and then solve back for to determine if they are positive integers.
This process is relatively straightforward, involving a brute-force loop for judgment. To avoid reinventing the wheel, I directly used GPT to write a script leveraging SageMath's elliptic curve library:
E = EllipticCurve(QQ, [1, 69, 0, 1365, 8281]) # [a1, a2, a3, a4, a6]
def compute_abc(x, y):
a = -x-y
b = y
c = -6*x-91
return a, b, c
def is_positive_integer(a, b, c):
return (a > 0 and b > 0 and c > 0)
def find_positive_abc(P, max_iterations):
iteration = 1
while iteration < max_iterations:
try:
Q = (iteration * P)
x, y = Q.xy()
except Exception as e:
print(f"Error in point doubling: {e}. Stopping.")
break
a, b, c = compute_abc(x, y)
if is_positive_integer(a, b, c):
print(f"Found positive integer solution when iteration = {iteration}")
return Q, a, b, c
iteration += 1
print("No positive integer (a, b, c) found within max iterations.")
return None
point = E([-15, 4])
result = find_positive_abc(point, max_iterations=10)
if result:
Q, a, b, c = result
print(f"Solution: (a, b, c) = ({a}, {b}, {c})")
As in Reference 4, when the iteration count iteration=9, the output is:
Multiplying by their least common multiple yields the positive integer solutions:
Question 3
Inspired by the meme in Question 2, a curious individual turned an apparently simpler problem into this seemingly harmless form:
This is the famous "sums of three cubes problem," which seeks integer solutions to the equation:
The problem depicted in the image corresponds to the case where , which was not solved until 2019 by Andrew Booker (Question 2 was solved in 2014, which is also relatively recent). In the following year, Andrew Sutherland collaborated with Booker to solve the Diophantine equation for . With this, all positive integers up to 100 that admit solutions have been found with at least one set of solutions.
Since this equation is not homogeneous, the doubling method from Question 2 is not applicable. The approach described in Andrew's paper involves reducing the time complexity of brute-force enumeration (from down to ), followed by a month of supercomputing (equivalent to 23 core-years of computation) to obtain a solution for 33, with a magnitude on the order of . Therefore, it is impractical to write code for this problem; instead, a general explanation of the idea will suffice.
Algorithm with Complexity
First, consider a simplified version of the problem—the two-cube-sum problem. A relatively straightforward conclusion is that for a prime satisfying:
the integer solutions exist only when or when takes the form . The proof is as follows:
Since and is prime, we have:
First, consider the right-hand condition: only satisfies it, corresponding to .
Next, consider the left-hand condition: let , then the expression becomes (which must also be prime).
We now attempt to generalize to any integer . Let , so we have and . Let , which gives:
This is a standard quadratic equation in . The discriminant must be a perfect square for the solution to be an integer. Let , then we obtain and . It suffices to verify whether and are integers.
Returning to the original three-cube-sum problem, we can move to the right-hand side:
We can then apply the algorithm for the two-cube-sum problem described above. By enumerating and performing prime factorization, we achieve a time complexity of .
Transformation to an Elliptic Curve
Assume , with . Let . Then is a cube root of modulo , and we can solve for:
Here, denotes the sign function of , satisfying and .
Then,
Here, the symbol indicates that the computed value must be a perfect square. Therefore, this is equivalent to:
For a given search range , such as in this problem, we need to enumerate such that is coprime with . For each , we also need to enumerate satisfying . Once we find a solution pair , it can be mapped back to the original solution .
For a specified integer , we can construct the corresponding elliptic curve :
such that the integer points on it correspond exactly to the integer solutions of the above equation. The specific mapping is:
Thus, the problem is transformed into finding integer points on an elliptic curve over .
This algebraic transformation is effective for relatively small . For example, before the year 2000, the values of for which no integer solution had been found included:
Booker used the integer point finding functionality for elliptic curves in the algebraic software Magma and verified that for , among all integer pairs , only yield integer points on . In other words, except for and , none of the other listed values have integer solutions for .
However, the parameter for the elliptic curve is on the order of , and there are such elliptic curves . Therefore, simply transforming the problem into finding integer points on an elliptic curve does not reduce the inherent complexity of the problem. Further optimization is still required.
Further Optimization
Returning to the previous section, in order to find pairs satisfying:
where ( is the same as before, i.e., ), there are two time complexity bottlenecks:
To compute such that , we need the prime factorization of .
The number of possible pairs is .
Apart from using elliptic curves to exclude a portion of integers , the paper primarily employs Montgomery's Batch Inversion Trick for batch computing cubic residues and a space-time trade-off sieve using the Legendre symbol to reduce the number of pairs that need to be traversed.
First, let's discuss batch inversion. Given numbers , we need to compute simultaneously. If done separately using the extended Euclidean algorithm, the time complexity would be . Montgomery's approach is as follows:
Compute . Calculating from to requires only modular multiplications.
Use the extended Euclidean algorithm to compute , with time complexity .
When , compute , then compute .
Let , and perform the same operation for .
Thus, the time complexity is reduced from to .
Returning to bottleneck one, factorize to obtain , then solve each cubic residue .
If , there is only one root, so , which can be computed using fast exponentiation with time complexity .
If :
Let .
Iteratively compute until . A cubic root exists if and only if .
Arbitrarily choose such that has order , then compute . If , then is a cubic root of .
Choose such that , then . The other two roots are and .
Then, use Hensel's lemma to extend to , and use the Chinese Remainder Theorem (CRT) to extend to .
If the modular inverses are stored during batch inversion and is enumerated using "linear combinations" of the primes, the inverses do not need to be recalculated during CRT. This reduces the total time complexity for computing cubic roots for to .
Considering bottleneck two, let:
Select , and compute as the product of all primes in . If is a perfect square, then for any prime (here the parentheses denote the Legendre symbol):
If the residue classes of are precomputed, and those residue classes for which the above equality holds for all primes are selected, the Hasse bound can be used to prove that the number of residue classes does not exceed . Thus, the final complexity is reduced to .
In addition to the reduction in complexity, Andrew mentioned in subsequent work Sums of three cubes that for specific (e.g., ), using the cubic reciprocity law as a sieve reduces the number of residue classes to of the original. This means only values of need to be traversed, significantly reducing the workload.
In terms of implementation, the paper used Intel intrinsics and leveraged supercomputing parallelism (with subtasks) to enumerate . After a month of computation (equivalent to core-years), the paper found the first solution for :