Breaking up Pythagorean Triples

One of the thing I really love in mathematics is how different subjects, which at least when starting to learn mathematics seem far apart, can come together in interesting ways. While the first reaction of many people might be that it just makes it more complicated, I always thought that it is the other way around. This means that I can use everything that I know from all of the different subjects, instead of using just my knowledge from a single subject. More over, it is almost always interesting to see the same problem from several points of view, each one with its own tools and ideas, and see how they all connect.

In this post, I want to share one such problem with you. Originally, I knew it from the algebra point of view, and that alone can fill several posts. However, along the way I have heard about this interesting new geometric proof, which connects this already interesting problem to even more field in mathematics. And the best thing, as many problems, it has a very humble beginning with a theorem we all learn about in high school – the Pythagorean theorem.

For the Hebrew speaking people – a video version of this post can be found here.

Pythagorean Triples

We begin by recalling first the famous Pythagorean theorem. If we are given a right angled triangle, then the square of the length of the hypotenuse (the edge not touching the right angle) equals the sum of the squares of the lengths of the other edges:

There are many interesting proofs for this theorem, but here we would take it as a given, and instead concentrate on a special case of such triangles – those that have edges of positive integer length. The smallest such triangle has lengths 3,4 and 5, and you can check that 3^2 + 4^2 = 5^2.

These triples of integers corresponding to right angled triangles are called Pythagorean triples. They play all sorts of roles in mathematics, in particular in algebra and are quite interesting in general. However, these triples are not easy to come by. Even if we start with a triangle with edges of length m,n near the right angle, then we only know that the hypotenuse has length \sqrt{m^2 + n^2} which in general is not an integer. So already, just finding such triangles is not an easy task, not to mention try to find all of them. But mathematicians do not give up easily, and eventually we have found some trick to find these triples.

The first trick to find more Pythagorean triple is to start with a given one, e.g. (3,4,5), and to stretch it with some integer factor. For example, if we stretch it by 2, we get the triangle with sides (6,8,10) which is another Pythagorean triple. You can also check it algebraically, by noting that

10^2 - (6^2 + 8^2) = 2^2 [ 5^2 - (3^2 + 4^2) ] = 2^2 \cdot 0  = 0.

Of course, we can stretch our triples by any integer factor to get infinitely more Pythagorean triples. We can also try shrinking our triangle by some integer factor, but this doesn’t always give a new triangle with integer sides. If we are given a triple where all of its integers are divisible by the same number, then we can divide by it to get another Pythagorean triple (namely, move from (6,8,10) to (3,4,5) by dividing by 2). When we get to an integer triangle that we cannot shrink any more, or algebraically speaking, the greatest common divisor of the lengths of its sides is 1, we call the Pythagorean triple primitive. For example, our (3,4,5) triple is primitive.

With this stretching and shrinking process, instead of looking for all the Pythagorean triples, we can restrict our attention to only primitive triples. If we can find all of them, we can then find all the Pythagorean triples by simply stretching them. This process already gives us a lot of integer triangles, but not all of them, so we need more tricks. If up until now we multiplied by some integer, we now want to multiply by another Pythagorean triple.

Multiplying Pythagorean triples

If we start with any two Pythagorean triples (not necessarily distinct), for example

5^2 = 3^2 + 4^2

13^2 = 5^2 + 12^2,

we can multiply them to get

(5\cdot 13)^2 = (3^2 + 4^2)(5^2 + 12^2)=(3\cdot 5)^2 + (3\cdot 12)^2 + (4\cdot 5)^2 + (4\cdot 12)^2.

This shows that if both 5^2 and 13^2 are sums of two squares, then their product is a sum of four squares. While this is already not a trivial result, we actually want to know if we can write it as sum of two squares.

To somehow go down to 2 squares we use the following trick. While the equations are defined over the integers, in a sense the right place to view them in the complex world. Indeed, in the complex world a “sum of two squares” have a very special meaning, since a^2 + b^2 =(a+bi)(a-bi) is a complex number times its conjugate.

Rewriting the product from above we get that:

5^2 = 3^2 + 4^2=(3+4i)(3-4i)

13^2 = 5^2 + 12^2=(5+12i)(5-12i)

(5\cdot 13)^2 = [(3+4i)(5+12i)] [(3-4i)(5-12i)] = [-33+56i]\cdot [-33-56i] = 33^2+56^2.

In other words, we can now multiply two Pythagorean triples to get a new one. Note that while in the integer world we had both multiplication (the squares) and addition, which results in sum of four squares, in this complex world everything became multiplication, and it is much easier to work with only multiplication than with both multiplication and addition.

In the previous section we saw that we can either stretch our triangles or reverse this process by shrinking them. Here we saw that we can multiply them, but can we break them apart also? For example, if we only knew that (5\cdot 13)^2 can be written as a sum of squares, then can we conclude that both 5^2 and 13^2 are sums of two squares? Or going even further, are 5 and 13 are sums of two squares?

The same complex trick from above shows that if 5 is a sum of squares, then so it 5^2, but is the opposite true as well? For these specific cases, we can actually check that this is true (5=1^2+2^2, \;\; 13 = 2^2+3^2), but can we show it in general?

More formally, if n\cdot m = a^2+b^2, is it true that both n and m are sums of two squares? With this formulation it is not true. For example, if n is any number which is not a sum of two squares (e.g. n=3) then n\cdot n = n^2 + 0^2 or even 2n\cdot n = n^2 + n^2 are counter examples. To avoid these type of examples, let us assume that a,b are coprime, and we are going to show that in this case the claim holds. Such points (a,b) where a and b are coprime are called primitive points. Note that in our Pythagorean triple world, this condition is simply the primitiveness of the Pythagorean triple.

The lattice of good points

Our goal now is to somehow start with the equality n\cdot m = a^2 + b^2, and try to find a solution for n = \tilde{a}^2 + \tilde{b}^2. We already saw before that sum of two squares a^2+b^2 can be thought of as a complex number times its conjugate, but another interpretation is just the distance squared of the point (a,b) from the origin. With this point of view the question becomes the following:

Question: Given an integer point v\in \mathbb{Z}^2 in the plane, with distance squared \left\Vert v \right\Vert^2=n\cdot m, is there another point with distance squared equals to n ?

As an example, assume that we start with the point (3,4), which satisfies 3^2 + 4^2 = 5^2, and we want to find a point (a,b) such that a^2 + b^2 = 5.

Since our only input is a given integer point with distance squared divisible by n, we would like to somehow use it to create more points with this property. Eventually, after we find all the points that we can with distance squared divisible by =n\cdot m, \; m\in \mathbb{Z}, we want to look for the one closest to the origin, namely with smallest m, and hope that m=1.

We already seen the first trick to create more such points. If v\in \mathbb{Z}^2 satisfies n \mid \left\Vert v\right\Vert ^2, then the same is true for k\cdot v for all k \in \mathbb{Z}. All of these points are integer points on the line spanned by v, and as an exercise you should show that since (a,b) is primitive these are exactly all the integer points on this line.

Of course, these new points are further away from the origin, so we will need to use another way to get closer point. For that we will use a second trick – if n \mid \left\Vert (a, b)\right\Vert ^2 then it is also true that n \mid \left\Vert (a\pm n, b)\right\Vert ^2 and n \mid \left\Vert (a, b \pm n)\right\Vert ^2. For example

\left\Vert (a+n, b)\right\Vert ^2 = (a+n)^2 + b^2 = a^2 + b^2 +n(2a + n) =  \left\Vert (a, b)\right\Vert ^2   +n(2a + n)

so that n \mid \left\Vert (a, b)\right\Vert ^2 if and only if n \mid \left\Vert (a+n, b)\right\Vert ^2.

We can now create lots of new such points. We start with all the integer points on our line from above, and add all the new points that we can get to by moving n steps left, right, down or up.

For example, our original point was (3,4) which had distance squared 5^2. The next point on the line was (6,8) with distance squared 100. By jumping 5 units to the left and then 5 down we get the point (1,3) with distance squared 5\cdot 2 which in particular is closer to the origin than the point (3,4). Similarly, we can do it for (9,12) = 3\cdot (3,4) and after the 5-jumps get to (4,2) which has distance squared 20, and finally for the point (12, 16) = 4\cdot (3,4) which produce the point (2,1) with distance squared 5 which is exactly what we wanted to find.

Remark: These n-jumps basically tell us that in a sense we work modulo n. More specifically, we have the natural map \mathbb{Z}^2 \to (\mathbb{Z} / n\mathbb{Z})^2, where the points generated above are exactly the preimage of the line generated by (a,b). In the image below we see the line generated by (3,4) “modulo” 5. Each time the line gets to the right (resp. top) edge, it jumps 5 units to the left (resp. down).

The set of points that we get in the process defined above can also be written as

L=Span_\mathbb{Z} (\; (a,b), (0,n), (n,0) \; ) := \{ k_1(a,b)+k_2(0,n)+k_3(n,0) \mid k_1, k_2, k_3 \in \mathbb{Z}\}.

This is of course a set closed under addition and taking negatives, or in other words a subgroup of \mathbb{Z}^2 (and actually, it is a lattice). Our goal is to say something about the shortest nontrivial point in this set, and hopefully show that its distance squared from the origin is n.

In our (3,4,5) example, the lattice is going to be the blue point in the image below:

As you can see, it is a very nice looking (=symmetric) set of points. The question is how can we use its properties to say something about its shortest nonzero vector.

From lines to triangles

The natural setting of our new set is the 2-dimensional real plane, while we look for a result about the 1-dimensional length of the shortest vector, which make our problem a bit unnatural. To move from one to the other, we use a simple trick, and instead of looking on the size of the 1-dimensional vector, we will look on the size of a 2-dimensional triangle. More specifically, we want to look on the smallest possible triangle, and hopefully use it to say something about it edges (and in particular, that one of them is very small).

Let 0\neq v\in L be a shortest nontrivial vector, and choose some u\in L such that the triangle defined by 0,u,v is nontrivial (u and v are not on the same line) and the triangle doesn’t contain any more points from L, whether in the interior or on the edges (prove to yourself that such a triangle exists). This triangle now has 3 edges of lengths \left\Vert v\right\Vert ,  \left\Vert u\right\Vert and \left\Vert u-v\right\Vert. By definition we know that \left\Vert u\right\Vert \geq  \left\Vert v\right\Vert, but we claim that \left\Vert u-v\right\Vert  \geq  \left\Vert v\right\Vert also. Indeed, this follows from the fact that our set L is close under subtraction.

So what can we say about this triangle, which we know that all of its edges are at least of size \left\Vert v\right\Vert ? You can check that its area is at least the area of an equilateral triangle with all side equal to \left\Vert v\right\Vert, and we can compute directly the area of such triangle – it is exactly \frac {\sqrt{3}}{4}  \left\Vert v\right\Vert^2. We now have a way to give an upper bound on \left\Vert v\right\Vert – to do this we simply need to give an upper bound on the area of our original triangle.

Luckily for us, the set L has all sorts of nice properties. The first one, is that all of the triangles with vertices in L which don’t have any other point from L in them have the same area. This is true in general for every lattice (after finding the analogue for triangles in higher dimension). We will give an intuition for this result in dimension 2 later, but for now let us assume this claim. The question is, can we find such a triangle which we can easily compute its area?

In our (3,4,5) example, there is a very simple triangle that we can use. Its vertices are (0,0), (5,0) and (3,1). It has base of length 5 and height 1, so its area is exactly \frac{5\cdot 1}{2}. Can we do something similar in general?

A triangle with area 5/2.

To create such a triangle for the general case, we will start with the vertices (0,0) and (n,0) which we know are in L. To complete it to a triangle, we claim that there is (1) a point of the form (x,1)\in L and (2) there are no points in L strictly between (0,0) and (n,0). Given these two claims, the triangle with vertices (0,0), (n,0) and (x,1) doesn’t contain any points from L, other than its vertices, and its area is simply \frac{n \cdot 1}{2}.

Recall that our whole investigation started with the point (a,b) where a^2+b^2=nm and gcd(a,b)=1. This implies in particular that gcd(b,n)=1 also (since if p\mid b,n is some prime then p\mid nm-b^2 = a^2 and therefore p\mid a – contradiction). Using this coprime condition, we can find integers k_1, k_2 such that k_1 \cdot b + k_2  \cdot n =1, so that

(k_1\cdot a, 1) = k_1 (a,b) + k_2 (0,n) \in L.

This proves our first claim. For the second, if we can write

(k, 0) = k_1 \cdot (a,b) + k_2\cdot (0, n) + k_3 \cdot (n, 0),

then just looking on the second coordinate, we get that 0 = k_1 \cdot b + k_2 \cdot n. Since we already saw that b is coprime to n and now n \mid k_1 \cdot b we conclude that n\mid k_1. It then follows that k = k_1 \cdot a + k_3 \cdot n is divisible by n, which proves the second claim.

To summarize, given the shortest nonzero vector v\in L, we constructed a triangle with the length of each edge at least \left\Vert v\right\Vert. Its area is at least the area of an equilateral triangle with all edges of length \left\Vert v\right\Vert, which is exactly \frac{\sqrt{3}}{4}\left\Vert v\right\Vert^2. On the other hand our original triangle has the same area as other triangles defined by vertices in L (and no other points inside), which is \frac{n}{2}, so all in all we get that

\frac{n}{2} \geq  \frac{\sqrt{3}}{4}\left\Vert v\right\Vert^2

0<\left\Vert v\right\Vert \leq \sqrt{n\cdot \frac{2}{\sqrt{3}}}<\sqrt{n\cdot 2}.

Finally, recall that we constructed L so that all of its points have distance squared n\cdot k for some integer k, so we conclude that v must satisfy \left\Vert v\right\Vert^2 = n, thus completing our proof.

On the area of triangles

As mentioned before, the fact that all the triangles with vertices in L and no other points from it have the same area is a general property of lattices, and is not unique for this set.

For those who want to try and prove it formally, here are the steps that you should try to do:

  1. Instead of working with general triangles with vertices u,v,w, you can always translate them by w without changing the area, nor the number of points inside it, so that the vertices are u-w, v-w, 0. Namely, we can assume that one of the vertices is the origin.
  2. Next, show that L is actually generated over \mathbb{Z} by two vectors (specifically in this case, one such example is (n,0) and a vector of the form (x,1) that we know exists).
  3. More over, two vector u,v\in L generate it if and only if the triangle defined by 0, u, v doesn’t contain any other point from L.
  4. To compute the area of the triangle, we can simply put the two vector as columns of a 2\times 2 matrix M, and then the area will be \det(M)/2.
  5. Finally, to move from one such matrix to another M' there is always some g\in GL_2(\mathbb{Z}) such that M'=Mg. In particular this implies that the areas in the two triangles are the same, since \det(M') = \det(M)\cdot \det(g)=\det(M).

The arguments above can be generalized to higher dimension, however, in dimension 2 there is a nice geometric visualization of what happens there. There are three basic transformations that change the triangle without changing it area. The first one is simply a translation. The second is rotation. For the last one, since the area is the base times the height divided by two, we want to change the triangle without changing the sizes of the height and base. For that choose one edge as a base, and move it along the line the it defines and keep the opposing vertex at place. This keeps both the base and the height fix, and therefore the area of the triangle.

You should now spend some minutes convincing yourself that this is enough, at least for our example with 3^2+4^2=5^2. More over, try to see how these three transformation correspond to the algebraic proof above.

Some final remarks

We started our investigation with right angled triangles and the Pythagorean theorem, moved to the set of sum of two squares and saw some of its interesting algebraic properties, and while trying to figure them out, somehow managed to construct a lattice and looked for its shortest vector.

Each one of these steps has a full world of interesting mathematics behind it, and at least for me, I always found this type of problem, which involved several ideas and subjects together quite interesting. Not only it let us get to know new and interesting subjects, it also let us combine our knowledge from all of the different subject to create something new.

Our original problem here was to find all the Pythagorean triple, and here we “just” saw that the set of sum of two squares is not only multiplicative, but we can break them up also. This is not enough to find all the Pythagorean triples, but it is a big step. In particular, if we keep breaking them up, eventually we will get stuck at an “unbreakable” number, or in other words a prime number. Thus, in the end, we are left with the problem of which primes p can be written as p=a^2+b^2 (another favorite problem for me). Dealing with primes also involves lots of number theory which make this whole process even more interesting, but this is for another post.

For now, if you want to play around a little bit with the more geometric ideas mentioned in this post, and interact with all of the triangles in pictures above, you can go to the program used to create them here: https://openprocessing.org/sketch/1242516

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s