Seeing as I have a great interest in maths, at some point I decided to try and solve Fermat’s last theorem. I obviously didn’t get very far, but I did find some interesting things while attempting to find the solution. One discovery was a way to construct a Pythagorean triple given any natural number (positive whole numbers). This means that, given a positive integer x, you can always construct an equation:

x2 + y2 = z2

And it also gives you a way to construct this equation. There are 2 different equations, one for even numbers, and one for odd numbers:

if x is odd:

x2 + ((x2-1)2)2 = ((x2+1)2)2

for example, 72 +  ((72-1)2)2 = 49 + 576 = 625, which equals ((72+1)2)2 . This is the equivalent of 72 + 242 = 252

if x is even:

x2 + (x24 – 1)2 = (x24 + 1)2

for x=6:

(624 – 1)2 + 62 = 64 + 36 = 100, which equals  (624 + 1)2. This is the equivalent of 62 + 82 = 102.

Why does this work? Well, To start, it helps to understand a little bit about the relationship between odd numbers, square numbers, and Pythagorean triples.

Square numbers are numbers that are formed by taking an integer, for example 3, and multiplying them by themselves. 3×3 = 9, so 3 squared is 9. There is a cool mathematical fact, that all square numbers can be made by adding together a consecutive group of odd numbers; more specifically, n2 is the sum of the first n odd numbers. For example, 42 is 1+3+5+7, or 16, the first 4 odd numbers. To see why this works, you can represent the square number n2 as a geometric square, with a side length of n.

This table has side lengths of 6, and an area of 36 squares. But how does this translate into a square being made up of consecutive odd numbers? Well, if you colour the square like this, it makes more sense:

As you can see, each new layer of the square is in a different colour. If you count them, each differently coloured layer is an odd number. There is one black square, 3 red squares, 5 orange squares, 7 green, 9 blue, and 11 purple. Each of these layers is 2 larger than the previous, making it a new odd number. I’m not going to explain the proof here, but it is a fact that the nth square number is the sum of the first n odd numbers.

But how does this help us make Pythagorean triples? To start with, we will look at the case where x, the number chosen to be part of the Pythagorean triple, is odd. in this case, x2 will also be odd. Now, we know that x2 will look something like this on the chart (although it can cover more or less squares):

So, we know that it can fit on the chart as a square; but the square is itself an odd number, so it can also be fitted on the chart in one of the layers, since the layers cover all odd numbers starting at one:

This means that your odd square, in this case 9, is both a square, and also the difference between two other squares, in this case 42, and 52, because it adds the extra layer around 42 to make it into 52. In this case, your odd square is also the difference of two other squares, which means that you can write:

52 – 32 = 42

which can be rewritten as:

32 + 42 = 52

a Pythagorean triple. However, how do you extend this to the general case?

Well, firstly you take your generic odd square x2. You then need to find which layer of the square it is on; you know that the odd numbers in the layers rise by 2 every time, going 1,3,5,7,9, and so on, so you can figure out that, to get the position, you add one, to account for the whole series starting at 1 instead of 0, and divide it by 2, because it moves up by 2 every layer. this gives you (x2+1)2. This is the z of the answer, z2. To get y, you simply change the formula to (x2-1)2, to go one layer back, because the odd number only added one extra layer to get to z. this gives you:

x2 + ((x2-1)2)2 = ((x2+1)2)2

The formula from the beginning.

If x is even, the process is very similar, with one caveat; because x is even, it cannot be a layer in the square. It can, however, be two layers added together, because if you take any even number, divide it by two, and add one to one half and subtract one from the other, you get two consecutive odd numbers. This allows you to represent it with two layers. I won’t go through the explanation again, but it gives you this equation:

x2 + (x24 – 1)2 = (x24 + 1)2

This allows you to generate Pythagorean triples, and also shows that any natural number can generate a triple. A short python program that uses this principle:

```def Triple(x):
if x%2 != 0:
y = (x**2-1)/2
z = (x**2+1)/2
print x, 'squared plus', y, 'squared equals', z, 'squared.'
else:
y = (x**2/4)-1
z = (x**2/4)+1
print x, 'squared plus', y, 'squared equals', z, 'squared.'```

Have fun with this largely pointless piece of information!