Distributed search for a perfect cuboid
Distributed search for a perfect cuboid
Alexander Belogourov
Abstract
If a perfect cuboid exists, its body diagonal exceeds 253 .
Introduction
When I was 10-year-old young boy I read the book ”Tic-Tac-Toe” [1], Rus-
sian translation of ”Wheels, life and other mathematical amusements” book of
a brilliant American science popularizer Martin Gardner. I was particularly im-
pressed by the problem of a perfect cuboid fascinatingly described by him. I was
surprised that it has not been solved yet, while there are many known almost
suitable solutions. 30 years have passed since then but the idea of finding the
perfect cuboid still does not leave me.
So let’s start from well-known for dedicated definitions, properties, equations
and notations just to be on the same wavelength.
A perfect cuboid (also called a perfect Euler brick, a perfect box) is a rect-
angular cuboid whose 3 edges, 3 face diagonals and the body diagonal all have
integer lengths. The existence of a perfect cuboid is one of unsolved problems in
mathematics. The definition of a perfect cuboid in geometric terms is equivalent
to a solution to the following system of Diophantine equations:
a2 + b2 = d2
a2 + c2 = e2
(1)
b2 + c2 = f 2
a2 + b2 + c2 = g 2
A primitive perfect cuboid is a perfect cuboid whose edge lengths are rela-
tively prime.
1
Some facts are known about properties that must be satisfied by a primitive
perfect cuboid, if one exists, based on modular arithmetic [2]:
One edge, two face diagonals and the body diagonal must be odd, one edge
and the remaining face diagonal must be divisible by 4, and the remaining
edge must be divisible by 16.
Two edges must have length divisible by 3 and at least one of those edges
must have length divisible by 9.
Most computer attempts to find a perfect cuboid were directed to attack the
problem from the side of known edges (smallest or odd). Exhaustive computer
searches show that, if a perfect cuboid exists, as of May 2017 [3],
In 1992 Ivan Korec [4] proposed to change the direction of attack from
edges to the body diagonal. He used PASCAL, a software not designed for
high–precision integers, so he reported that the body diagonal of a perfect
cuboid must exceed 8 billion. In 2006 Terry Raines [5] wrote his own UBA-
SIC program and raised Korec’s lower bound from 8 billion to 120 billion. In
2017 we wrote C (pure C, not C++) program based on Korec’s ideas, and prob-
ably got rid of previous programs bottlenecks and therefore tens of thousands
times more efficient, which allowed to raise the lower bound to 250 , more than
1 quadrillion.
2
Background
all degrees of primes of the form 4k + 3 must be even for n has Girard
representations;
p1 = a2 + b2
p2 = c2 + d2
3
, the general formula for expressing a product of the sum of two squares in
Girard representation form is the following:
Note, in general case pairs (a, b) and (c, d) can produce 2 different pairs of Girard
representations: (ac + bd, |bc − ad|) and (|ac − bd|, bc + ad), if ac + bd ̸= bc + ad.
Otherwise only 1 unique pair is produced.
Lemma 4: The body diagonal of a primitive perfect cuboid cannot be a
prime number.
Let’s return to Diophantine equations:
a2 + b2 = d2
a2 + c2 = e2
b2 + c2 = f 2
a2 + b2 + c2 = g 2
Edges a, b, c must be different, so the square of the body diagonal g 2 must have
at least 3 different Girard representations:
g 2 = a2 + f 2
g 2 = b2 + e2
g 2 = c2 + d2
Algorithmic Approach
The program searches for a perfect cuboid in a given by lower and higher
bounds range for the body diagonal g among the numbers of the form 4k + 1.
Q
Giving a certain number g first we should check whether it is a product pi of
prime divisors pi ≡ 1 (mod 4). The existence of just one divisor pi ≡ 3 (mod 4)
leads to exclusion of g from the subset of candidates for the body diagonal of a
perfect cuboid.
After the sieving (and, actually, the factorization) we got only right candi-
dates. In general they take ∼4% of numbers from the range, or ∼16% if we take
4
into account the fact that we move through the range with step 4. After that it
does batch decomposition of factors of numbers-candidates into the sum of two
squares and per each candidate the following routine is proceeded:
search for a perfect cuboid with the body diagonal g based on all known
representations of g 2
5
If a is a quadratic nonresidue modulo p then a(p−1)/2 ≡ −1 (mod p) so we
can take z ≡ a(p−1)/4 (mod p) (and that is easily computed by modular expo-
nentiation). How does one find quadratic nonresidues? In fact, exactly half of
the numbers 1, ..., p − 1 have the desired property. We do not know a deter-
ministic process for finding such a number, but they appear to be distributed
randomly so we can just try numbers at random until we find one and each
trial has a 50% chance of success. Even if we are trying 1000 digit numbers it
is unlikely that we will not find a solution before the 5000th trial, so for com-
putational purposes, it is probably worth keeping a list of the first 6542 primes.
It is precisely so many primes under 216 = 65536.
Compute the greatest common divisor of p and z + i using the Euclidean
algorithm for the Gaussian integers. The answer will be x+yi where x2 +y 2 = p.
√
1. set x ← p, y ← p mod z, s ← [ p].
Girard representations of g 2
Given g = pa1 1 pa2 2 · · · pann , where pi are distinct primes and pi ≡ 1 (mod 4).
How many distinct primes g can have as its factors? It’s not difficult to prove
that 11 is the largest amount of different prime factors of the form p = 4k + 1
for numbers g ≡ 1 (mod 4) under 263 . For instance 8418894903232764925 =
52 · 13 · 172 · 29 · 37 · 41 · 53 · 61 · 73 · 89 · 97 has 11 different factors. Numbers
64379784554132908252 and 84188949032327649252 have the largest amount of
Girard representations among g 2 for numbers g ≡ 1 (mod 4) under 263 . Ac-
cording to Dirihlet’s formula: [((4 + 1)(4 + 1)(2 + 1)(2 + 1)(2 + 1)(2 + 1)(2 +
1)(2 + 1)(2 + 1)(2 + 1)(2 + 1) + 1)/2] = 246038.
Probably we have to turn aside and explain why 263 was chosen as a higher
limit for investigated numbers. The reason is very simple: as we know, most
of modern computer CPUs are built on x86 64 architecture, the 64-bit version
of the x86 instruction set, so 64-bit integer arithmetic and logical operations
are their primary architecture features and they can operate directly on 64-bit
integers. C compiler gcc supports also unsigned 128 bit integers. As we will see
below, we shall perform square root computing of the sum of two squares, so
263 was chosen to prevent owerflow of 128 bit integers. In fact 263 should be
enough for our purposes. With the current program speed they will need more
6
than 1 million years on single CPU core to reach 263 . Ok, now let’s return to
Girard representations.
Since we know the amount of factors of g and their unique and only one
Girard representation, we will apply the following routine to construct all Girard
representations of g 2 :
5. compute and store not only pairs (x, y) from g 2 = x2 + y 2 , but also values
of x2 and y 2 : (x, x2 , y, y 2 ).
Almost-perfect cuboids
Forasmuch we had known the results of previous searches and did not expect
to find a perfect cuboid in ranges at least up to 5 · 1013 , we decided to search
not only a perfect cuboid, but also so-called almost-perfect cuboids.
An almost-perfect cuboid has one of the 7 lengths irrational, the other 6
lengths are rational. We had known about 3 types of almost-perfect cuboids,
called Body, Edge and Face cuboids.
Body cuboids have irrational body diagonal and therefore were not achiev-
able for our application because of chosen direction of attack.
For the Edge cuboid, one of the edges a, b, c is irrational. The Face cuboid
has just one of the face diagonals d, e, f irrational. We had found that Edge and
Face are completely achievable for the program. And, it is important, the search
completely discovers them. It means any primitive Face and Edge cuboid, like
a perfect cuboid, must have the body diagonal as a product of primes of the
7
form 4k + 1. We found who is engaged in such kind of research, he was Randall
L. Rathbun. As of May 2017 he published [7] 155,151 found by him cuboids
with the smallest integer edge under 157,000,000,000. We compared his results
with our own and found they are absolutely identical in ranges where they are
comparable.
After that Randall inspired us to add also additional, more specific type
of almost-perfect cuboids: a cuboid with irrational Gaussian edge. We found
that we also can add such type of cuboids without affecting the performance
of the program, but unfortunately their search will not exhaustive. For in-
√
stance [(a, b, c), (d, e, f ), g] = [( −426400, 108, 725), (644i, 315, 733), 333] is not
achievable for our program. In response we noticed that Randall’s cuboid ta-
ble is incomplete too, since we found a way to generate new ones cuboids with
some lengthes in complex numbers from known one. For instance, Face cuboid
√
[(a, b, c), (d, e, f ), g] = [(104, 153, 672), (185, 680, 474993), 697] can produce at
least 11 new different cuboids:
√
[(104i, 185, 680), (153, 672, 496625), 697]
√
[(697, 153i, 672i), (680, 185, i 474993), 104]
√
[(185, 680, 697i), ( 496625, 672i, 153i), 104]
√
[(697, 104i, 672i), ( 474993, 185, 680i), 153]
√
[(672, 680i, 185), (104i, 697, i 428175), 153]
√
[(697, 104i, 153i), ( 474993, 680, 185i), 672]
√
[(153, 185i, 680), (104i, 697, 428175), 672]
√
[(104, 680i, 697), (672i, 496625, 153), 185]
√
[(672i, 680, 153), (104, i 428175, 697), 185]
√
[(185i, 104, 697), (153i, 672, 496625), 680]
√
[(153i, 185, 672), (104, 428175, 697), 680]
If we take into account the fact that we can multiply all lengthes of 12 above
cuboids on the imaginary unit and get 12 new different cuboids:
√
[(104i, 153i, 672i), (185i, 680i, 474993), 697i]
8
√
[(104, 185i, 680i), (153i, 672i, i 496625), 697i]
√
[(697i, 153, 672), (680i, 185i, 474993), 104i]
√
[(185i, 680i, 697), (i 496625, 672, 153), 104i]
√
[(697i, 104, 672), (i 474993, 185i, 680), 153i]
√
[(672i, 680, 185i), (104, 697i, 428175), 153i]
√
[(697i, 104, 153), (i 474993, 680i, 185), 672i]
√
[(153i, 185, 680i), (104, 697i, i 428175), 672i]
√
[(104i, 680, 697i), (672, i 496625, 153i), 185i]
√
[(672, 680i, 153i), (104i, 428175, 697i), 185i]
√
[(185, 104i, 697i), (153, 672i, i 496625), 680i]
√
[(153, 185i, 672i), (104i, i 428175, 697i), 680i]
All 24 cuboids are different, it’s obvious and also it is not difficult to prove
that they can not be produced by some other almost-perfect cuboid in real
numbers, because for all of them max integer part from all rational lengthes
is equal to 697. All cases are obtained combinatorially and do not produce
additional integer parts of lengthes, so even if, let’s imagine, some other almost-
perfect cuboid has the body diagonal equal to 697, it has different from this
cuboid lengthes.
Note, the combinatorial method for obtaining cuboids nevertheless gener-
√ √
ates 2 new under square root expressions: 428175 and 496625. Until the
opposite is proven we assumed that these radicands can turn out to be a full
squares, so potentially almost-perfect cuboid can produce so-called Perfect Com-
plex cuboids.
We found that for cuboids in complex numbers their ability to produce new
derivative cuboids does not depend on what is irrational side, an edge or a face
diagonal, but whether cuboid contains face diagonals in complex numbers. That
is why we had decided to change Randall’s notation of almost-perfect cuboids
in complex numbers and called them:
9
Imaginary cuboid — cuboid whose only edge(s) is(are) complex num-
ber(s), such as:
√
[(a, b, c), (d, e, f ), g] = [(i 3344, 60, 63), (16, 25, 87), 65].
Twilight cuboid — cuboid whose only edge(s) and face diagonal(s) are
complex numbers, such as:
√
[(a, b, c), (d, e, f ), g] = [(60i, 3344, 65), (16i, 25, 87), 63].
The existence of any Face cuboid entails the existence of two different
Imaginary cuboids or maybe Perfect Complex cuboid(s) if under root ex-
pression is a full square. For example:
√
Face cuboid [(104, 153, 672), (185, 680, 474993), 697] entails:
√
1. Imaginary cuboid [(104i, 185, 680), (153, 672, 496625), 697]
√
2. Imaginary cuboid [(153i, 185, 672), (104, 428175, 697), 680]
The existence of any Body, Edge, Face or Imaginary cuboid entails the
existence of tree different Twilight cuboids. For example:
√
Face cuboid [(104, 153, 672), (185, 680, 474993), 697] entails:
√
1. Twilight cuboid [(153i, 104i, 697), (185i, 680, 474993), 672]
√
2. Twilight cuboid [(672i, 104i, 697), (680i, 185, 474993), 153]
√
3. Twilight cuboid [(672i, 153i, 697), (i 474993, 185, 680), 104]
10
2. Perfect Complex cuboid [(Ai, Ci, G), (Ei, F, D), B]
3. Perfect Complex cuboid [(Bi, Ai, G), (Di, E, F ), C]
4. Perfect Midnight cuboid [(Ai, Bi, Ci), (Di, Ei, F i), Gi]
5. Perfect Midnight cuboid [(B, C, Gi), (F, Ei, Di), Ai]
6. Perfect Midnight cuboid [(A, C, Gi), (E, F i, Di), Bi]
7. Perfect Midnight cuboid [(B, A, Gi), (D, Ei, F i), Ci]
We decided do not search for Midnight cuboids because of they always have
their ”sunny brother”, so we focused on cuboids with the body diagonal in real
numbers.
All these discoveries pushed us to the idea of systematizing what cases pro-
duce what cuboids. The question is: if we know 5 numbers, 5 lengthes of some
cuboid, what roles they can play in this cuboids? Under the role we mean an
edge, a face diagonal or a body diagonal. An additional condition was applied
to the research for giving austerity: these 5 lengthes should not allow arbitrary
choice of the missing 2, the missing 2 should be unequivocally defined from 5
known.
Let we know 5 lengthes: s < t < u < v < w, which are related by equations
s2 + t2 = w2
u2 + v 2 = w2
We discovered that there are only 20 cases which lead to some type of
cuboids:
11
a b c d e f g
E/F P s v p l u t w
T C -s -p w -u t l v
T C -v -p w -t u l s
T C -v -s w -l u t p
I C -p u t s v m w
T C -u p w -s v m t
T C -t p w -v s m u
T C -w u t -v -s m p
E/F P s u r k v t w
T C -u -s w -k v t r
T C -s -r w -v t k u
T C -u -r w -t v k s
I C -r v t s u n w
T C -v r w -s u n t
T C -t r w -u s n v
T C -w v t -u -s n r
I C -s u v p r w t
T C -u s t -p r w v
T C -v s t -r p w u
T C -t u v -r -p w s
, where
a, b, c, d, e, f, g are 7 sought lengthes related by Diophantine equations (1);
P, E, F, C, I, T are designations of Perfect, Edge, Face, Perfect Complex,
Imaginary and Twilight cuboids;
√ √ √
k= s2 + u2 m= t2 + u2 p= u2 − s2
√ √ √
l= s2 + v 2 n= t2 + v 2 r = v 2 − s2
Note, as much as we will compute such square roots a lot of times (or, at
least, under root expression), it is very reasonable to keep computed squares of
Girard representations on a par with representation itself.
sign ”-” means multiplication on the imaginary unit. For instance: ”-s”
√ √ √
means s −1, ”-k” means k −1 = i s2 + u2 .
12
How to read this table.
Every row contains 5 given known values and 2 values (coloured red), which
need to be calculated additionally.
For instance:
a b c d e f g
T C -u s t -p r w v
means:
√
a ← u −1
b←s
c←t
√ √
d ← p −1 = i u2 − s2
√
e ← r = v 2 − s2
f ←w
g←v
13
As expected a perfect cuboid had not been found, but we had discovered:
All Imaginary and Twilight cuboids were derivated from Face cuboids in 2:1
and 9:1 ratios respectively. We should declaim that these 6,665 Face cuboids are
not a complete set of Face cuboids with body diagonal from the range 250 − 251 .
For a sake of program acceleration we refused most of almost-perfect cuboids
checks (including Face cuboids), but found it possible to save the findings of
some specific views of them without significant impact on the application per-
formance... as well as for fun. It’s always better to know the program finds at
least something than to get an empty result from each workunit.
We prolonged the search further and covered the range 251 (2, 251, 799, 813, 685, 248)−
53
2 (9, 007, 199, 254, 740, 992) in almost 9 months and had discovered a total of
208’896 different cuboids:
14
If a perfect cuboid exists, its body diagonal exceeds 253 .
October 16, 2018, the 3rd Batch was completed. Totally we had spent
227.66 CPU Years and had contributed 172,304,137,008 GFlops (172.3 quintil-
lion floating-point operations).
After that we decided to suspend the project for application code review to
be sure our efforts were not in vain.
Honestly, very unlikely a perfect cuboid exists at all, so we rather expect the
result of further project progress would become the only short abstract: ”If a
perfect cuboid exists, its body diagonal exceeds N”. The only question is how
high this N will.
Acknowledgments
We would like to thank all of them, who helped us to develop, enhance and
optimize the program. The program absorbed ideas of many-many people. Not
necessary all their ideas remain to the end, some of them were replaced by later
even more brilliant ideas, but nonetheless, thank to:
yoyo@home admin for all his efforts to launch and support Perfect Cuboid
sub-project;
@fwjmath for idea of in-memory primes table creation, for square check
optimization, for many-many minor fixes and enhancements;
15
References
[1] Martin Gardner, ”Tic-Tac-Toe” — M.: Mir (1988)
[4] Ivan Korec: Lower bounds for perfect rational cuboids, Mathematica Slo-
vaca, (1992) 565-582
[7] Randall L. Rathbun, The Integer Cuboid Table (v2), 4 Sep 2017
16