Pythagorean triples from complex numbers

Disclaimer: all ideas in this text were published elsewhere, see the further reading section below.[br][br]Let's explore the connection between Pythagorean theorem, divisibility, complex numbers and transformations.[br][br]The Pythagorean theorem states that in a right triangle, the sides and hypotenuse satisfy the condition [math]a^2+b^2=c^2[/math]. 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 [math]a^2+b^2=c^2[/math] holds.[br][br]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.[br]Rewrite the theorem as[br][math]c^2-a^2=b^2[/math][br][math](c-a)(c+a)=4d^2[/math][br][math]\frac{c-a}{2}\cdot\frac{c+a}{2}=d^2[/math][br]Any prime dividing both [math]\frac{c-a}2[/math] and [math]\frac{c+a}2[/math] must divide also [math]\frac{c-a}2+\frac{c+a}2=c[/math] and [math]\frac{c+a}2-\frac{c-a}2=a[/math]. Since c and a are coprime, no such prime can exist. So [math]d^2[/math] 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[br][math](c-a)/2=u^2[/math][br][math](c+a)/2=v^2[/math][br][math]c=u^2+v^2[/math][br][math]a=v^2-u^2[/math][br][math]d=uv[/math][br][math]b=2uv[/math]
Gaussian integers
If you've used complex numbers before, the formulas [math]a=v^2-u^2[/math] and [math]b=2uv[/math] may look familiar. Indeed,[br][math](v+ui)^2=(v^2-u^2)+(2uv)i[/math]. This allows us to write the formula for PT in much simpler form[br][math]a+bi=(v+ui)^2[/math] (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.)[br][br]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[br][math](a+bi)(a-bi)=c^2[/math][br]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 [math]a+bi=(v+ui)^2[/math].
Geometric interppretation
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 [math]\rho=\frac{ab}{a+b+c}[/math], therefore if a,b and [math]\rho[/math] are rational, so is c.[br][br]Every rational point (p,q) is an incenter of a right triangle with vertices [math](0,0), (p+q,0), \left(p+q,\frac{2pq}{p-q}\right)[/math] with rational sides.
Further reading
[url=https://kconrad.math.uconn.edu/ross2008/pythagtriple.pdf]Pythagorean triples by Keith Conrad[/url]

Information: Pythagorean triples from complex numbers