Ah, that edit is much better :) I got the formulas when I was working on a problem for the Putnam math competition. I showed that a problem was equivalent to stating that every integer greater than 2 was part of a Pythagorean triple, which was much easier to show than the original problem. Then I worked at creating the function. My original proof is not at all elegant, but it went like this:
Let a,b,c be natural numbers greater than 2 that satisfy a2+b2=c2. We know a≠b since that would imply 2a2=c2^^ → sqrt(2)=c/a which is not true since sqrt(2) is irrational. so let a<b<c. We know that the difference (b+1)2-b2 is 2b+1, which is odd, so if we can get a2=2b+1, then we have a2+b2=(b+1)2, so we know c=b+1. If we are given a, then b=(a2-1)/2, which works when a is odd.
So now, for all odd values of a, we can create the Pythagorean triple a2+(a2-1)2/4=(a2+1)2/4.
Now for the evens, just look at c=b+2. Then a2=(b+2)2-b2=4b+4, so b=(a2-4)/4= a2/4-1 and so we have a triple that all even values of a are a part of.
Now the fun part comes in by smushing the two equations together such that odd values of a use the first equation and even values of a use the second. All I did was find the average of the two equations and then I subtract the difference for add a, add the difference for even a. This is really tough to describe, so don't worry if this is gibberish.
Add the two equations together and divide by 2. I will just do this with the formula for finding b:
Now we find the difference between that and either the equation for odd a or even a (it should be the same, since we took the average):
Now if we want to add that when a is odd and subtract when it is even, we need to use the fact that (-1)a is 1 if a is even, -1 if a is odd:
But since the have the same denominator:
And you will find for c:
So to make it look prettier:
You can derive more formulas this way, too, so have fun ! Now you know that every integer greater than 2 can be a leg of a right triangle whose lengths form a Pythagorean triple.