Very nice!
Here's how I attacked this problem. Warning: I used some very advanced math.
This problem is ancient, it's called the
Congruent number problem. It goes all the way back to Diophantus, but Fibonacci was the first to study the problem in a way that would give the solution.
The idea is to reduce it to
elliptic curves. The key insight is to look at half the hypotenuse. If a, b, c denote rational sides of a right triangle of area n, then (c/2)^2+n and (c/2)^2-n are also rational squares. To see this, simply substitute c^2=a^2+b^2.
That means we can find a rational triangle of area n whenever three rational squares are in an arithmetic progression of ratio n. To solve this, it's easier to work in projective space, where you have four coordinates (x,y,z,w) that collapse into (x/w,y/w,z/w).
It turns out that the solutions to the problem correspond to the intersection of two quadrics in projective space, which reduces to an elliptic curve. Since I am lazy, I simply copied the parametrization from Wikipedia. If we define
x=n(a+c)/b, y = 2n^2(a+c)/b^2
Then x and y satisfy y^2 = x^3-n^2x. To go from x and y to a, b, c we use:
a=(x^2-n^2)/y, b=2nx/y, c=(x^2+n^2)/y
Awesome, so our question reduces to: Does the curve y^2 = x^3 - 36x have infinitely many rational points?
The laziest way to check that it does is to look at Cremona's
database.
How to understand that data? Well, it turns out that elliptic curves have a nice
operation that you can use to generate more points in the curve from other ones. This gives the curve the structure of a group.
LMFDB gives us the Mordell-Weil structure (the name is because of Mordell's theorem, that says the group is finitely generated), which is Z/2 x Z/2 x Z
The Z part shows it's infinite. What if we did not have the database? Well, there are quite a few theorems we can use to narrow down its structure. There are height computations, Nagell-Lutz, reduction mod p, Mazur's theorem. I can elaborate if people want, but what's important to notice is that if we start with a rational point in the curve and keep adding it to itself, if the values are all different for a long period, then we can be sure there are infinitely many of them.
LMFDB gives us the point (-3,9), which corresponds to our friend, the (3,4,5) triangle. From the previous discussion, if we keep adding this point to itself we'll generate all triangles of area 6. I implemented this in Python:
Language: Python
from fractions import Fraction as F
n = 6
a=F(-n*n,1)
maxn = 6
def extract(x,y):
p = abs((x*x-n*n)/y)
q = abs(2*n*x/y)
r = abs((x*x+n*n)/y)
print('({p},{q},{r})'.format(p=p,q=q,r=r))
xb=F(-3,1)
yb=F(9,1)
extract(xb,yb)
s = (3*xb*xb+a)/(2*yb)
x = s*s-2*xb
y = s*(xb-x)-yb
extract(x,y)
for i in range(maxn):
s = (y-yb)/(x-xb)
nx = s*s-x-xb
y = s*(xb-nx)-yb
x = nx
extract(x,y)
Looking at the digits, they grow extremely fast:
(3,4,5)
(7/10,120/7,1201/70)
(4653/851,3404/1551,7776485/1319901)
(1437599/168140,2017680/1437599,2094350404801/241717895860)
(3122541453/2129555051,8518220204/1040847151,18428872963986767525/2216541307731009701)
(43690772126393/20528380655970,246340567871640/43690772126393,5405257799550679424342410801/896900801363839325090016210)
(13932152355102290403/884619602260392601,3538478409041570404/4644050785034096801,64777297161660083702224674830494320965/4108218358333926731621213541698169401)
(4156118808548967941769601/1012483946084073924047720,12149807353008887088572640/4156118808548967941769601,21205995309366331267522543206350800799677728019201/4208003571673898812953630313884276610165569359720)
Now, Fractal, I am curious. Did you find the transformation by unwrapping the elliptic curve from the point doubling operation or managed to derive it in a more intuitive way?