Computing method searching 3D perfect Euler bricks (or Euler cuboids)
by Christian Boyer, April-May 2012

This system for 3D perfect Euler brick (a, b, c):

• a² + b² = p²          [system 2]
• a² + c² = q²
• b² + c² = r²
• a² + b² + c² = s²

can be rewritten:

• p² + c² = s²         [system 2']
• q² + b² = s²
• r² + a² = s²
• a² + b² + c² = s²

meaning that s² has at least three different ways to be a sum of two squares. For any primitive brick, all prime factors of s are of the form 4k+1.

Here is a method searching 3D perfect Euler bricks, based on the factorization of s.

Construct a list of primes of the form 4k+1, and their unique ways to be sums of two squares a²+b² (a odd, and b even):
5 = 1²+2², 13 = 3²+2², 17 = 1²+4², 29 = 5²+2², 37 = 1²+6², 41 = 5²+4², ...

Do a loop building s with various factors of primes of the form 4k+1, and on each s:

• Construct all the possible primitive ways for s² to be a sum of two squares, using the list of the prime factors of s, and using the fact that a product (a² + b²)(c² + d²) has only two different primitive ways to be a sum of two squares:
• (ad + bc)² + (ac  bd)²
• (ad  bc)² + (ac + bd)²

and that (a² + b²)² has only one primitive way to be a sum of two squares:

• (a² - b²)² + (2ab)²
• Among this list of primitive ways for s², if three of them (say a1²+b1² = s², a2²+b2² = s², and a3²+b3² = s², with ai odd, and bi even) can produce a1²+b2² +b3² also summing to s², then we have a 3D perfect Euler brick!