Pythagorean triples from complex numbers

Disclaimer: all ideas in this text were published elsewhere, see the further reading section below. Let's explore the connection between Pythagorean theorem, divisibility, complex numbers and transformations. The Pythagorean theorem states that in a right triangle, the sides and hypotenuse satisfy the condition . For most choices of a and b this gives you irrational values for c. We say that numbers a,b,c form a Pythagorean triple (PT) if they are all integers and holds. It is possible to find formulas that generate all possible PTs., these formulas can be derived using high school math only. The usual approach is this:

Classic proof

Note that if a,b,c form a PT, the numbers ka,kb,kc also form a PT for any integer k. We can therefore focus on coprime numbers a,b,c. Any prime dividing both a and c must also divide b^2 and therefore also bc, so we can assume that a,b,c are pairwise coprime. We can also prove that c must be odd and exactly one of a,b must be even. Let's say b is even and a is odd. We can set b=2d. Rewrite the theorem as Any prime dividing both and must divide also and . Since c and a are coprime, no such prime can exist. So is a product of two coprime numbers, each prime factor of b^2 must divide exactly one of (c-a), (c+a) and since each prime divides b^2 in an even power, we know that (c-a) and (c+a) are both squares. This gives us

Gaussian integers

If you've used complex numbers before, the formulas and may look familiar. Indeed, . This allows us to write the formula for PT in much simpler form (Note that a single equality in complex numbers actually determines both a and b because both real and imaginary part must match. Value of c is determined by a and b.) This brings an obvious question -- is this a coincidence or is there a way to use complex numbers to prove this? Well, there are no coincidences in math. We can also factor the Pythagorean theorem in complex numbers Now the factors are what we call Gaussian integers -- complex numbers whose imaginary and real part are both integers. Luckily for us Gaussian integers can be factored into primes uniquely, just like normal integers. If we want a and b to be coprime, we can show that also makes a+bi and a-bi coprime and therefore all Gaussian primes dividing a+bi must divide it in even power, giving us .

Geometric interpretation

Now we've learned that Pythagorean triples correspond to squares of Gaussian integers. We know that squaring a complex number means doubling the argument (angle) and squaring the absolute value. To keep things simpler, in the visual below we won't bother with squaring the absolute value, we'll just double the angle. That way the resulting triangle won't have integer sides, but they will be rational numbers and can be scaled up to become integers. The labels in the drawing are already scaled up. The construction is simple, all we have to do is reflect one point about a line. You can try dragging point A to obtain all the Pythagorean triples.

Relation to Incenter

Let's consider a right triangle positioned like the one in the visual above: one vertex in origin and one vertex at (b,0) for an integer b. The visual shows that such triangle has rational sides if and only if the slope of its angle bisector (going through the origin) is rational. This can be also proven by elementary means without using complex numbers, knowing that the incircle of a right triangle is has radius , therefore if a,b and are rational, so is c. Every rational point (p,q) is an incenter of a right triangle with vertices with rational sides.