One of the oldest problems in the theory of Diophantine equations is to find right triangles with integer side lengths, or equivalently, triples of positive integers (abc) such that \(a^2 + b^2 = c^2\), which are called Pythagorean triples. Examples were known to the Babylonians around 1800 BCE. Taking positive integers \(m>n\) and \(\tau \), all such triples can be determined from the formula

$$\begin{aligned} a= \tau (m^2-n^2), \quad b = 2\tau mn, \quad c=\tau \left( m^2+n^2\right) , \end{aligned}$$
(1)

which was given by Euclid, but without the arbitrary scale factor \(\tau \). A primitive Pythagorean triple is one for which \(\gcd (a,b,c)=1\), and (up to switching a and b) all primitive triples are obtained from (1) by taking \(\tau =1\) and mn coprime with at least one of them even.

The formula (1) can be derived directly from simple congruences modulo 2 and 4, but another way to obtain it is to consider rational points on an algebraic curve, namely the unit circle

$$\begin{aligned} x^2+y^2=1,\; \textrm{where}\; x=\frac{a}{c}, \; y=\frac{b}{c}. \end{aligned}$$

For any rational point \((x,y)\in {{\mathbb {Q}}}^2\) on this circle distinct from the point \((-1,0)\), we form the chord joining them, given by the line \(y=t(x+1)\) with slope t. Hence we obtain the rational parametrization of the circle

$$\begin{aligned} x=\frac{1-t^2}{1+t^2}, \quad y =\frac{2t}{1+t^2}\,, \end{aligned}$$
(2)

related to the usual trigonometric parametrization \(x=\cos \theta \), \(y=\sin \theta \) by the “t-substitution” of integral calculus, that is, \(t=\tan {\theta }/{2}\), and formula (1) follows by taking rational \(t={n}/{m}\) with \(0<t<1\).

Heron Triangles and Unicorns

For a triangle with sides (abc) and semiperimeter s, the area formula

$$\begin{aligned} \Delta =\sqrt{s(s-a)(s-b)(s-c)}, \quad s=\frac{a+b+c}{2}\,, \end{aligned}$$
(3)

is attributed to Heron of Alexandria. If the side lengths of a triangle are integers and the area \(\Delta \) is also an integer, then it is called a Heron triangle. Allowing the freedom to rescale all the sides by the same factor, it is convenient to define a triangle to be Heron whenever the side lengths and the area are all rational numbers.

Trivially, every right triangle given by a Pythagorean triple is Heron. More generally, dropping a perpendicular from any vertex of a Heron triangle splits it into a pair of right triangles with the same height, either joined back to back or overlapping each other, and it is not hard to see that both triangles must have rational sides, so that (up to rescaling) the Heron triangle is built from a pair of Pythagorean triples. This construction can be used to derive a parametric formula for Heron triangles,

$$\begin{aligned} a=\frac{p^2+r^2}{p}, \quad b=\frac{q^2+r^2}{q}, \quad c=\frac{ (p+q) \vert r^2-pq\vert }{pq}\,, \end{aligned}$$
(4)

with \(\Delta =rc\), for arbitrary positive rational numbers pqr such that \(r^2\ne pq\), which was known to Brahmagupta in the seventh century CE [4].

For a particular example, taking \(p=3,q=4,r=6\) in (4) leads to the Heron triangle with \(a=15\), \(b=13\), \(c=14\) and area \(\Delta =84\), which can be built out of the Pythagorean triangles (5, 12, 13) and (9, 12, 15) by placing them back to back along the altitude \(2r=12\), as in Figure 1. (This choice of parameters is not unique: for instance, by ordering the sides differently as \((a,b,c)=(15,14,13)\) instead of (15, 13, 14), one can obtain the same Heron triangle from \(p={147}/{13}\), \(q={126}/{13}\), \(r={84}/{13}\).)

Figure 1:
figure 1

The (15, 13, 14) Heron triangle from the two Pythagorean triples (9, 12, 15) and (5, 12, 13).

A systematic method for enumerating Heron triangles with integer sides was given by Hermann Schubert [12]. In Schubert’s scheme, (15, 13, 14) is the first example of a Heron triangle with integer sides that is not right or isosceles. However, if we combine the same two Pythagorean triples by overlapping the triangles (rather than arranging them back to back as in the figure), then we get the (15, 13, 4) Heron triangle with the smaller area \(\Delta =24\), which nevertheless appears farther down in Schubert’s list.

The unicorns in our story are perfect triangles: triangles that have three integer sides, three integer medians, and integer area. Does a perfect triangle exist, or equivalently, is there a Heron triangle with three rational medians? It is generally believed that there is no such thing, all the “proofs” in the literature having proven to be incorrect. The problem remains open [8]. The rest of our discussion is devoted to seeing how close we can get to perfection.

Hereinafter, the medians bisecting sides abc will be denoted respectively by \(k,\ell ,m\), which leads to the relations

$$\begin{aligned} k^2&=\frac{1}{4}\left( 2b^2+2c^2-a^2\right) \,, \\ \ell ^2&=\frac{1}{4}\left( 2c^2+2a^2-b^2\right) \,, \\ m^2&=\frac{1}{4}\left( 2a^2+2b^2-c^2\right) \,. \end{aligned}$$

We label the angles adjacent to the median k as in Figure 2, and our first step toward the elusive perfect triangle will be to consider the requirement that just this median be rational.

Figure 2:
figure 2

A triangle with one labeled median.

Heron Triangles with One Rational Median

From a construction of parallelograms with rational sides, area, and diagonals, Schubert was led to the case of Heron triangles with one rational median, and he went on to present an argument that such triangles could not have a second rational median, which a fortiori would rule out the existence of perfect triangles. However, as pointed out by Leonard Eugene Dickson [4], his argument contained an oversight that rendered it insufficient. That flaw notwithstanding, an identity of Schubert’s for Heron triangles with one rational median is crucial for what follows.

If we write \(\textbf{b},\textbf{c},\textbf{k}\) for the vectors corresponding to the lengths bck, directed outward from the top vertex in Figure 2, and \(\textbf{a}= \textbf{b}-\textbf{c}=2(\textbf{k}-\textbf{c})=2(\textbf{b}-\textbf{k})\), then the dot product \((\textbf{b}-\textbf{c})\cdot \textbf{k}= \textbf{a}\cdot \textbf{k}\) gives \(bk\cos {\alpha }-ck\cos {\beta }=ak\cos {\gamma }\), while the area of the triangle is \(\Delta =\vert \textbf{b}\times \textbf{k}\vert =\vert \textbf{c}\times \textbf{k}\vert =\tfrac{1}{2}\vert \textbf{a}\times \textbf{k}\vert \), which gives \(\Delta = bk\sin {\alpha }=ck\sin {\beta }=\frac{1}{2}ak\sin {\gamma }\). Combining these relations produces the identity

$$\begin{aligned} 2\cot {\gamma }= \cot {\alpha }-\cot {\beta }. \end{aligned}$$
(5)

Given three angles \({\alpha },{\beta },{\gamma }\) in the interval \((0,\pi )\) subject to \({\alpha }+{\beta }<\pi \), it is convenient to take

$$\begin{aligned} M=\cot \frac{{\alpha }}{2}, \quad P=\cot \frac{{\beta }}{2}, \quad X=\cot \frac{{\gamma }}{2} \end{aligned}$$
(6)

as parameters, and then by standard trigonometric identities (equivalent to the “t-substitution” in (2) above), the identity (5) becomes a rational relation between these three quantities, namely

$$\begin{aligned} M-\frac{1}{M}=P-\frac{1}{P}+ 2\left( X-\frac{1}{X}\right) . \end{aligned}$$
(7)

This gives the equation of a surface in three-space with coordinates (MPX), which can be rewritten as the vanishing of a polynomial:

$$ 2MP(X^2-1)+MX(P^2-1)-PX(M^2-1)=0. $$

We shall refer to it as the Schubert surface.

From the half-angle identity \(\cot ({\alpha }/2)=\sin {\alpha }/(1-\cos {\alpha })\), we have \(M=\Delta /(bk-\textbf{b}\cdot \textbf{k})\). Using the analogous expressions for P and X together with dot product relations, we can express these Schubert parameters in terms of the area, side lengths, and median by the formulas

$$\begin{aligned} \begin{aligned} M&=\frac{4\Delta }{4bk+a^2-3b^2-c^2}\,, \\ P&=\frac{4\Delta }{4ck+a^2-b^2-3c^2}\,, \\ X&=\frac{4\Delta }{2ak-b^2+c^2}\,. \end{aligned} \end{aligned}$$
(8)

The ratios of the side lengths are given in terms of the Schubert parameters by

$$\begin{aligned} \frac{a}{c}=\frac{2(X+X^{-1})}{P+P^{-1}}, \quad \frac{b}{c}=\frac{M+M^{-1}}{P+P^{-1}}\,. \end{aligned}$$
(9)

Formulas (8) show that every Heron triangle with a rational median k produces a rational point on the Schubert surface (7), with positive coordinates \((M,P,X)\in {{\mathbb {Q}}}^3\). How about the converse: does every rational point on this surface correspond to a Heron triangle with (at least) one rational median? In fact, using certain discrete symmetries of the surface (sending (MPX) to \((M^{-1},P^{-1},X^{-1})\) or replacing one of the Schubert parameters by its negative reciprocal), we can begin with any triple of nonzero values \((M,P,X)\in {{\mathbb {Q}}}^3\) satisfying (7) and turn it into a valid positive triple. Then the side lengths (abc) are determined by (MPX) using the rational expressions (9), up to an arbitrary choice of scale; after fixing the scale, any pair of equations (8) allow the rational numbers k and \(\Delta \) to be recovered.

Triangles with Two Rational Medians

In striving to get closer to perfection, another possible direction for our first step is to drop the requirement that the area \(\Delta \) be rational and just consider triangles with rational sides (abc) and two rational medians \(k,\ell \). In his PhD thesis [1], Ralph H. Buchholz obtained a rational parametrization of all such triangles, given by the formulas

$$\begin{aligned} \begin{aligned} a&= \tau (-2\theta ^2\phi -\theta \phi ^2+2\theta \phi -\phi ^2+\theta +1)\,, \\ b&= \tau (\theta ^2\phi +2\theta \phi ^2-\theta ^2+2\theta \phi -\phi +1)\,, \\ c&= \tau (\theta ^2\phi -\theta \phi ^2+\theta ^2+2\theta \phi +\phi ^2+\theta -\phi )\,, \end{aligned} \end{aligned}$$
(10)

where \(\theta ,\phi \) are rational numbers subject to constraints ensuring positivity of the side lengths, namely,

$$\begin{aligned} 0<\theta<1, \quad 0<\phi <1, \quad \phi +2\theta >1\,, \end{aligned}$$
(11)

and the positive parameter \(\tau \in {{\mathbb {Q}}}\) allows for an arbitrary choice of scale. Conversely, the parameters \((\theta ,\phi )\in {{\mathbb {Q}}}^2\) can be written as rational functions of the side lengths and two medians, given by

$$\begin{aligned} \theta = \frac{c-a\pm 2\ell }{2s}, \quad \phi = \frac{b-c\pm 2k}{2s}\,, \end{aligned}$$
(12)

where \(s=(a+b+c)/2\) is the semiperimeter, as before.

Note that in (12), there are two independent choices of ± signs, and hence four different pairs \((\theta ,\phi )\) associated with the same rational triangle with two rational medians.

Intermezzo: Somos-5 Sequences

Before we continue our quest for the perfect triangle, we must recall some beautiful observations made by Michael Somos [13]. The saga of Somos sequences attracted widespread attention due to Mathematical Intelligencer articles by David Gale [7], and they provided inspiration for the study of the Laurent phenomenon and its development in Fomin and Zelevinksy’s theory of cluster algebras [5, 6], which has been one of the hottest topics in algebra for almost twenty-five years.

A recurrence relation of Somos type is a homogeneous quadratic recurrence of a particular form. Here we focus on the example of Somos-5 sequences, which are recurrence relations of order 5 given by

$$\begin{aligned} S_{n+5}S_n = S_{n+4}S_{n+1}+S_{n+3}S_{n+2} \,, \end{aligned}$$
(13)

for \(n>4\). Somos noticed that if all five initial values are equal to 1, then the resulting Somos-5 sequenceFootnote 1 begins

$$\begin{aligned} 1, 1, 1, 1, 1, 2, 3, 5, 11, 37, 83, 274, 1217, 6161, 22833, 165713 \end{aligned}$$
(14)

and consists entirely of integers. This seems very surprising, because at each iteration of (13), one must divide the right-hand side by \(S_n\) to obtain the new term \(S_{n+5}\). The Laurent property provides one explanation for the integrality of the Somos-5 sequence: if the initial values \(S_j\), \(1\le j\le 5\), for the recurrence are considered variables, then each iterate turns out to be a polynomial in these quantities and their reciprocals with integer coefficients: \(S_n ={{\mathcal {P}}}_n (S_{1}^{\pm 1}, S_{2}^{\pm 1},S_{3}^{\pm 1},S_{4}^{\pm 1},S_{5}^{\pm 1})\) (that is, a Laurent polynomial). On substituting \(S_1=S_2=S_3=S_4=S_5=1\) into each polynomial \({{\mathcal {P}}}_n\), the integer sequence (14) results.

Another completely different way to understand Somos-5 sequences relies on a connection with integrable maps, which are discrete analogues of exactly solvable systems in Hamiltonian mechanics. To see this connection, note that the recurrence (13) has three independent scaling symmetries: rescaling even/odd index terms separately, so \(S_{2j}\rightarrow A_+S_{2j}\), \(S_{2j+1}\rightarrow A_-S_{2j+1}\), and rescaling \(S_n\rightarrow B^nS_n\) for any n, where \(A_+,A_-,B\) are arbitrary nonzero constants. Moreover, we can form a sequence of ratios that is left invariant by these scaling symmetries and find that it satisfies a recurrence of second order:

$$\begin{aligned} u_n = \frac{S_{n-2}S_{n+1}}{S_{n-1}S_{n}} \implies u_{n+1} u_{n-1} = 1+\frac{1}{u_{n}}\,. \end{aligned}$$
(15)

By considering \((U,V)=(u_n,u_{n+1})\) as a point in the plane, we see that each shift \(n\mapsto n+1\) of the discrete “time” in (15) is equivalent to an iteration of a birational transformation (a rational map with a rational inverse)

$$\begin{aligned} \varphi : \left( \begin{array}{c} U \\ V \end{array} \right) \mapsto \left( \begin{array}{c} V \\ U^{-1}(1+ V^{-1}) \end{array} \right) \,. \end{aligned}$$
(16)

The transformation (16) is an example of a Quispel–Roberts–Thompson (QRT) map: such maps have arisen in various physical contexts, including statistical mechanics, nonlinear waves (solitons), and quantum field theory [11]. In a suitable regime, the iterates of the map appear like a stroboscopic view of a mechanical system with one degree of freedom. More precisely, the transformation \(\varphi \) is area-preserving (symplectic): it preserves the logarithmic area element \((UV)^{-1}\,\textrm{d}U\,\textrm{d}V\) in the plane, and it obeys conservation of energy, where “energy” in this case is the rational function

$$\begin{aligned} {\tilde{J}}= U+V+\frac{1}{U}+\frac{1}{V}+\frac{1}{UV}\,. \end{aligned}$$
(17)

The level sets of this function are plane curves \({\tilde{J}}=\text {constant}\), and each orbit of \(\varphi \) lies on a fixed level set. The behavior is especially regular in the positive quadrant \(U>0\), \(V>0\), where each orbit densely fills a compact oval (see Figure 3, where three hundred points are plotted on each orbit).

Figure 3:
figure 3

Some orbits of the map (16) in the positive quadrant.

We shall see that in relation to Heron triangles with two rational medians, two different integer sequences appear, namely the pair of Somos-5 sequences given by

$$\begin{aligned} \begin{aligned} (S_n)&: 1,1,1,2,3,5,11,37,83,274,\ldots \,, \\ (T_n)&: 0,1,-1,1,1,-7,8,-1,-57,391,\ldots \,, \end{aligned} \end{aligned}$$
(18)

where the terms above are listed starting from the index \(n=0\). The first one, \((S_n)\), is just the original Somos-5 sequence (14), but indexed differently: it corresponds to the orbit of the map \(\varphi \) through the point (1, 1), while the second sequence, \((T_n)\), corresponds to the orbit through the point \((-1,7)\). It is easily verified that both of these orbits lie on the same level curve \({\tilde{J}}=5\) of the function (17),

$$\begin{aligned} U^2V+UV^2 +U+V-5UV+1=0, \end{aligned}$$
(19)

a plane cubic curve (total degree 3) that is also biquadratic (quadratic in both U and V). The first orbit corresponds to the oval shown in red in Figure 3, whereas the second orbit lies outside the positive quadrant, moving around the three unbounded components of this curve, which can be seen in Figure 4.

Figure 4:
figure 4

The curve (19) in the (UV)-plane.

Heron Triangles with Two Rational Medians

Buchholz found the first example of a Heron triangle with two rational medians: the (73, 51, 26) triangle with area 420 and \(k={35}/{2}\), \(\ell ={97}/{2}\), which had been overlooked by Schubert in his work on parallelograms. After joining forces, Buchholz and Randall Rathbun conducted a systematic search for such triangles, using the following algorithm based on (10): fix the scale \(\tau =1\), enumerate pairs of rational numbers \((\theta ,\phi )\), and for each pair use Heron’s formula (3) to check whether the area \(\Delta \) is rational [2]. The first few triangles obtained from this search are shown in Table 1, where each triangle is represented by positive integers (abc) with \(\gcd (a,b,c)=1\). Their initial investigations suggested that there should be an infinite family of such triangles (rows labeled with a positive integer n), together with an unknown number of sporadic triangles that do not fit into this family (rows labeled with asterisks).

Table 1: The smallest Heron triangles with two rational medians.

Heron triangles with two rational medians are associated with two different triples of Schubert parameters, \((M_a,P_a,X_a)\), \((M_b,P_b,X_b)\), each corresponding to a particular set of angles \({\alpha },{\beta },{\gamma }\) adjacent respectively to one of the medians \(k,\ell \). These triples provide two different rational points on the Schubert surface (7), coupled by two constraints coming from the ratios of side lengths, as in (9). Remarkably, by considering the patterns of prime factors appearing in these rational numbers, Buchholz and Rathbun found conjectural formulas for a subset of these parameter triples in terms of the two Somos sequences (18), such as

$$\begin{aligned} M_a= -\frac{S_{n+1}S_{n+2}^2T_n}{S_nT_{n+1}T_{n+2}^2}, \quad M_b=\frac{S_{n+1}S_{n+4}T_{n+1}T_{n+4}}{S_{n+2}S_{n+3}T_{n+2}T_{n+3}}\,, \end{aligned}$$
(20)

and analogous expressions for the other elements of each triple. When for successive integers \(n=1,2,3,\ldots \), they plotted the corresponding pairs \((\theta ,\phi )\) found from (12) with a fixed choice of ± signs, they found them to lie on one of five algebraic curves \({{\mathcal {C}}}_j\), \(1\le j\le 5\), isomorphic to one another and repeating in a pattern with period 7, the simplest-looking curve being the biquadratic cubic

$$\begin{aligned} {{\mathcal {C}}}_4: \theta ^2\phi -\theta \phi ^2+\theta \phi +2\theta -2\phi -1=0\,. \end{aligned}$$
(21)

It was pointed out by Elkies (see [2]) that the sequences (18) can be written using theta functions associated with the elliptic curve given by the equation

$$\begin{aligned} E({{\mathbb {Q}}}): y^2+xy=x^3+x^2-2x\,, \end{aligned}$$
(22)

which has infinitely many rational pointsFootnote 2 and is isomorphic (birationally equivalent) to \({{\mathcal {C}}}_4\). Indirectly, this led to a proof that every rational point \((\theta ,\phi )\) on the genus-one curve \({{\mathcal {C}}}_4\) given by (21), subject to the constraints (11), corresponds to a Heron triangle with two rational medians [3].

Table 2: Prime factors of the semiperimeter, reduced side lengths, and area in the infinite family.

However, until very recently, (20) and the explicit expressions for the other Schubert parameters remained conjectural. The key to progress in [9] was to observe the elegant factorization pattern in the quantities appearing under the square root in Heron’s formula, namely the semiperimeter s and the reduced side lengths \(s-a\), \(s-b\), \(s-c\) (see Table 2). It turns out that (up to an overall sign) each of these four quantities is given by a specific product of terms from the two Somos-5 sequences, leading to the following result.

Theorem 1.

For every integer \(n\ge 1\), the terms in the pair of Somos-5 sequences \((S_n)\) and \((T_n)\) in (18) provide a Heron triangle with two rational medians having integer side lengths given by

$$\begin{aligned} a&= \left| S_{n+1}S_{n+2}^3S_{n+3}T_{n+2}+S_n^2S_{n+1}T_{n+3}T_{n+4}^2\right| \,, \\ b&= \left| S_n^2S_{n+1}T_{n+3}T_{n+4}^2-T_{n+1}T_{n+2}^3T_{n+3}S_{n+2}\right| \,, \\ c&= \left| T_{n+1}T_{n+2}^3T_{n+3}S_{n+2}-S_{n+1}S_{n+2}^3S_{n+3}T_{n+2}\right| \,, \end{aligned}$$

with \(\gcd (a,b,c)=1\), rational median lengths

$$\begin{aligned} k&= { \frac{1}{2} } \left| S_{n+4}T_{n+4}(T_{n}T_{n+1}^2T_{n+2}-S_{n}S_{n+1}^2S_{n+2})\right| \,, \\ \ell&= { \frac{1}{2} } \left| S_nT_n(T_{n+2}T_{n+3}^2T_{n+4}-S_{n+2}S_{n+3}^2S_{n+4})\right| \,, \end{aligned}$$

and integer area

$$\begin{aligned} \Delta = \left| S_nS_{n+1}S_{n+2}^2S_{n+3}S_{n+4}T_nT_{n+1}T_{n+2}^2T_{n+3}T_{n+4}\right| \,. \end{aligned}$$
Table 3: Prime factors of the semiperimeter, reduced side lengths, and area in the sporadic cases.

The curve (19) is birationally equivalent to the curve \({{\mathcal {C}}}_4\) in (21), hence also to the curve (22). Its set of rational points is the union of two orbits of the map (16): the orbit associated with the sequence \((S_n)\) lying on the oval in the positive quadrant in Figure 4, and the orbit associated with \((T_n)\), which jumps around the other three quadrants in a pattern that repeats with period 7. Thus these two Somos-5 sequences completely encode the structure of this infinite family of Heron triangles with two rational medians. It would be natural to wonder whether any of the triangles in this family can have a third rational median m, but it has been proven that such is not the case [10].

Still, this leaves some big challenges to the reader: so far, only four sporadic triangles have been found that do not belong to the infinite family! The prime factorization of each semiperimeter and the reduced lengths in Table 3 give tantalizing hints of further structure. Can you extend the search to find more sporadic examples and fit them into one or more new infinite families encoded by Somos (or other) sequences? Or can you show that these four are the only sporadic triangles, thereby proving that unicorns do not exist?