This question is from a non-mathematician (a programmer...) so please excuse any poor terminology.
I was writing some test data for some (X, Y, Z) coordinate to magnitude conversions.
As you know, the magnitude of a (X, Y, Z) vector is given by Pythagoras:
mag = Sqrt(X^2 + Y^2 + Z^2)
I wanted to simplify things to avoid rounding problems, so I wrote a very simple program to search for solutions for X, Y and Z where the sum of their squares was itself a perfect square.
I noticed the following solutions:
1, 2, 2
2, 3, 6
3, 4, 12
4, 5, 20
5, 6, 30
6, 7, 42
These are clearly all of the form (N-1, N, N(N-1)).
I assume this is a well-known thing, but I was unable to find any proof or discussion by googling (probably because I don't know what to search for).
Is it true that (X^2 + Y^2 + Z^2) is always a perfect square for all N where X=N-1, Y=N and Z=N(N-1)?
Yes. It is easy to verify $(n^2-n+1)^2$