Now, here’s a real oldie but goodie: Find positive integers *x*, *y*, and *z* such that

*x*^{2} + *y*^{2} = *z*^{2} .

Of course, the three sides of any right triangle will satisfy that equation, but few right triangles have all three sides of integer length. The most well known example of such a *Pythagorean triple* is (3,4,5): 3^{2}+4^{2}=9+16=25=5^{2}. There are an infinite number of others, of course: if you have one triple (*x*,*y*,*z*) then for any positive integer *n*, (*nx*,*ny*,*nz*) is also a triple. But that’s not very interesting. However, there are an infinite number of *primitive* triples — ones in which *x*,*y*, and *z* have no common factor.

I think the best way to approach Pythagorean triples is to start with a simple and not at all obviously relevant fact: If two integers *a* and *b* have the same *parity* (i.e., both are even or both are odd), then there exist two integers *c* and *d* such that* *

*a* = *c* + *d* and

*b* = *c* – *d*

Specifically, *c* is the arithmetic mean of *a* and *b*, (*a*+*b*)/2, and *d* is half their difference, (*a*–*b*)/2. Of course, if *a* and *b* did not have the same parity (if one was even and the other odd), their sum and difference would be odd and *c* and *d* would not be integers. Since they do have the same parity, their sum and difference is even and *c* and *d* are integers. Furthermore, it’s clear that if *a* and *b* are odd, then *c* and *d* must have opposite parity; if they’re even, *c* and *d* must have the same parity.

So what does this have to do with Pythagorean triples? Well…

First of all, in a triple, can *x* and *y* both be odd? If they are, then their squares are too, and the sum of their squares must be even but not divisible by 4: (2*m*+1)^{2}+(2*n*+1)^{2} = 4(*m*^{2}+*n*^{2}+*m*+*n*)+2. But if *z* is odd, *z*^{2} is odd, and if it’s even, *z*^{2} is divisible by 4. Therefore *x* and *y* cannot both be odd. Of course since (3,4,5) and (6,8,10) are both triples, we can see *x* and *y* can both be even (and then *z* will be even), or they can be opposite parity (and *z* will be odd.) Either way, at least one of *x* and *y* will be even (let’s say *y* must be even) and the other (let’s say *x*) will have the same parity as *z*.

Where to go from here? Well, *x* and *z* have the same parity, so let’s write them as sums and differences of two integers — this time we call them *u* and *v*:

*x* = *u* – *v* and* *

*z* = *u* + *v*

But we can rewrite *x*^{2} + *y*^{2} = *z*^{2} as

*y*^{2} = *z*^{2} – *x*^{2}

= (*z*+*x*)(*z*–*x*)

= 4*uv*

Now if *y*^{2} is a perfect square, that means each of its prime factors occurs to an even number of powers. To get *y*^{2} = 4*uv*, any prime factors of *u* occurring with an odd number of powers must also occur in *v* with an odd number of powers, and vice versa. In other words, *u* and *v* must each be a product of a square number and a factor common to both:

*u* = *ab*^{2} and

*v* = *ac*^{2} .

Then 4*uv* = 4*a*^{2}*b*^{2}*c*^{2} = a perfect square as required. We also know that, since *x* is positive, *u*>*v* and therefore *b*>*c*.

Summarizing: all Pythagorean triples are of the form

*x* = *a*(*b*^{2}–*c*^{2})

*y* = 2*abc*

*z* = *a*(*b*^{2}+*c*^{2})

where *a*, *b*, and *c* are positive integers with *b* > *c*.

For a triple to be primitive, *x* and *y* (and therefore *z*) must have no common factors. That means *a* = 1, *b* and *c* must have no common factors, and *b* and *c* must have opposite parity (else *x* and *y* would both be even).

It’s amusing to consider some particular types of triples. For instance, it’s clear that the difference between *z* and *x* is 2*ac*^{2}. This means they’ll differ by their minimum amount, 2, only if *a* = *c* = 1; these triples are (3,4,5), (8,6,10), (15,8,17), (24,10,26)…. For *b* even (odd), these are (are not) primitive.

*y* and *z* can differ by 1, if 2*bc*+1 = *b*^{2} + *c*^{2}. (*a*, of course, must be 1.) Rewriting, *b*^{2} – 2*bc* + *c*^{2} = (*b*–*c*)^{2} = 1, so *b* = *c*+1. These triples are (3,4,5), (5,12,13), (7,24,25), (9,40,41)…

*x* and *y* can differ by 1, if 2*bc*±1 = *b*^{2} – *c*^{2}. (Again, *a* must be 1.) This is a Pell equation, much trickier to deal with than the foregoing. I’ll merely point out that, if *x* and *y* are large and differ by unity, then a triangle with sides *x*, *y*, and *z* is nearly isoceles, so that *x*/*z* or *y*/*z*, or better yet (*x*+*y*)/2*z*, is an excellent rational approximation to the inverse of the square root of 2. That might lead you to suspect a connection between Pell equations and continued fractions. Indeed there is such a connection, and these triples are numerically related to the continued fraction expansion of the square root of 2. For more on Pell equations I refer you to this MathWorld page.

## Another approach

(See http://mathforum.org/pcmi/hstp/sum2001/wg/number…/session13.pdf.) Consider the Gaussian integer *p* = *b* + *ci *where *b* and *c* are integers and *i* is √–1. The square of *p* is

*p*^{2}= (*b* + *c**i*)^{2} = (*b*^{2} – *c*^{2}) + 2*bci*.

The norm of *p*^{2} is

|*p*^{2}| = (*p*^{2})(*p*^{2})* = (*b*^{2} – *c*^{2}) ^{2} + 4*b*^{2}*c*^{2}.

But the norm of *p*^{2} equals the square of the norm of *p*:

|*p*^{2}| =|*p*|^{2} = (*b*^{2} + *c*^{2}) ^{2} = (*b*^{2} – *c*^{2}) ^{2} + 4*b*^{2}*c*^{2}

which gives us *x* = (*b*^{2} – *c*^{2}), *y* = 2*bc*, *z* = (*b*^{2} + *c*^{2}) as a Pythagorean triple. It’s the same formula as before (for *a* = 1) derived differently.

## Triples II

Let’s consider some generalizations of the Pythagorean triple concept, starting with solutions to:

*x*^{2} + *y*^{2} = *nz*^{2}

where of course *n* as well as *x*, *y*, and *z* are integers. I don’t have much to say about this for now, other than a few comments for *n* = 2. In that case *x* and *y* have the same parity so we can write

*x* = *u* – *v*

*y* = *u* + *v*

and

*x*^{2} + *y*^{2} =

(*u*^{2} – 2*uv* + *v*^{2}) + (*u*^{2} + 2*uv* + *v*^{2}) =

2(*u*^{2} + *v*^{2}) = 2*z*^{2}

Then *u*, *v*, and *z* are a Pythagorean triple. We can illustrate this graphically as follows:

Here *DAB* and *DCB* are two right triangles, with integer legs, and with the latter isoceles: *CD* = *BC*. Then *AB*^{2} + *AD*^{2} = *2 CD*^{2}. Now drop perpendiculars *CE* to *AB* and *DF* to *CE*. Right triangles *BEC* and *CFD* have congruent hypoteneuses, and since angles *DCF* and *BCE* sum to a right angle, angles *BCE* and *CDF* must be congruent; therefore triangles *BEC* and *CFD* are congruent. Then *AB* = *DF* + *EB* and *AD* = *CE* – *CF* = *DF* – *EB*. Since *AB* and *AD* are integers, *DF* and *EB* must be integers or half integers, and the latter is ruled out by their being legs of right triangles with integer hypoteneuses. Therefore *DF*, *EB*, and *CD* are a Pythagorean triple, and the Cartesian coordinates of *C* (taking *A* as the origin) are integers (as are, of course, those of all the other labelled points).

For example, if *CF* = 3, *DF* = 4, and *CD* = 5, then the coordinates of all points are:

A = (0, 0)

B = (7, 0)

C = (4, 4)

D = (0, 1)

E = (4, 0)

F = (4, 1)

The diagonals of the quadrilateral are sqrt (50) and sqrt (32) — not integers, but their product is sqrt (1600) = 40, an integer! As was pointed out in a thread on alt.math.recreational, points *A*, *B*, *C*, and *D* lie on a circle, and there is a theorem that tells us *A*, *B*, *C*, and *D* lie on a circle if and only if *AC* * *BD* = *AD* * *BC* + *AB* * *CD*. In this case, the product of the diagonals must be 7*5 + 1*5 = 40.

## Triples III

Another variant on Pythagorean triples is Eisenstein triples, which satisfy

*x*^{2} + *y*^{2} – *xy* = *z*^{2} .

Such a triple is the lengths of the sides of a 60-degree triangle, using the law of cosines and cos (60°) = 0.5. For example, a triangle with sides 5, 8 and 7 has a 60 degree angle between the first two sides.

To generate Eisenstein triples we can make use of the number α = –1/2 + √3/2*i*, which satisfies:

α^{2} = –α–1

|α| = 1

α + α* = –1

Using these relations you can show *z*^{2} = (*x*+*y*α)(*x*+*y*α*). So now: Proceeding analogously to above where we used Gaussian integers to generate Pythagorean triples, square the number *p* = *a*+*b*α:

*p*^{2} = *a*^{2} + *b*^{2}α^{2} + 2*ab*α = *a*^{2} + *b*^{2}(–α–1) + 2*ab*α

= *a*^{2} – *b*^{2} + (2*ab*–*b*^{2})α .

The norm |*p*^{2}|, after some algebra, turns out to be equal to (*a*^{2} – *ab* + *b*^{2})^{2}. But |*p*^{2}| = |*p*|^{2}. This then gives us Eisenstein triples: *x* = *a*^{2} – *b*^{2}, *y* = 2*ab*–*b*^{2}, *z* = *a*^{2} – *ab* + *b*^{2}. For instance, *a* = 3, *b* = 2 gives *x* = 5, *y* = 8, *z* = 7.

You can get triples corresponding to integer sides of 120° triangles similarly, using 1/2 + √3/2*i*.

## Quadruples I

The Pythagorean triples correspond to points in the plane whose *x* coordinate, *y* coordinate, and distance from the origin all are integers.

The obvious generalization to *n*-dimensional space is the (*n*+1)ples (*x*_{1}, *x*_{2}… *x _{n}*,

*z*) such that

sum(*i*=1..n) *x*_{i}^{2} = *z*^{2} .

In the case *n* = 3, these are quadruples (*x*, *y*, *z*, *w*). What can we say about them? Well, let’s start again with parity considerations. At least two of *x*, *y*, and *z* — say *x* and *y* — must have the same parity. But then *z* must have the same parity as *w*. Then we can write *x* and *y* as sums and differences of two integers *a* and *b*, and *z* and *w* as sums and differences of two other integers, *c* and *d*. We can then get the relation

*a*^{2} + *b*^{2} = 2*cd*.

Obviously this means *a* and *b* must have the same parity — meaning *x* and *y* must be even.

And that’s about all there is to say. Pick two positive integers *a* and *b*<*a* with the same parity, compute (*a*^{2} + *b*^{2})/2, then split the result into two factors and call them *c* and *d*<*c*; then *x*=*a*–*b*, *y*=*a*+*b*, *z*=*c*–*d*, and *w*=*c*+*d* are a solution quadruple. Example: *a* and *b* are 12 and 8; then we need factors of (12^{2}+8^{2})/2 = 104. We can use *c*=13, *d*=8. Then *x*=12-8=4, *y*=12+8=20, *z*=13-8=5, and *w*=13+8=21. And indeed 4^{2}+20^{2}+5^{2}=241=21^{2}. (We also could have used *c*=26, *d*=4, or *c*=104, *d*=1, et cetera., to get other quadruples.)

This is almost too easy. You can go to quintuples, if you like, but that just adds variables without really making things any more interesting. In fact, there’s a theorem that *almost* all positive integers can be written as the sum of three squares (possibly including 0^{2}) and *all* positive integers can be written as the sum of four squares. So the “special” nature of Pythagorean triples becomes watered down in higher dimensions.

But there’s still some fun to be had with quadruples of a different nature…

## Quadruples II

What if we generalize Pythagorean triples to (*n*+1)ples (*x*_{1}, *x*_{2}… *x _{n}*,

*z*) such that

sum(*i*=1..n) *x*_{i}^{2} = (*n*-1)*z*^{2} ?

Why would you want to? Well, it’s not clear that you would; but for *n* = 3, this is

*x*^{2} + *y*^{2} + *z*^{2} = 2*w*^{2} .

And this arises in the following problem: Find three integers such that the sums of any two, *and* the sum of all three, all are perfect squares. Obviously if two of them sum to *x*^{2}, another two sum to *y*^{2}, and the third pair sum to *z*^{2}, then the sum of all three must be (*x*^{2} + *y*^{2} + *z*^{2})/2 = *w*^{2}. Find all the solutions of the latter and some of them may give you solutions to the former.

So, OK, that’s some sort of motivation. Once more, consider parity. Take *x* and *y* as being the same parity. Then the sum of their squares is even and *z* must be even to make the sum of all three squares even. But what’s the parity of *w*? *z*^{2} is divisible by 4; *x*^{2}+*y*^{2} is too, if *x* and *y* are even, or not, if they’re odd. Therefore the left side is divisible by 4 if and only if *x* and *y* are even, and that means *w* has to have the same parity as *x* and *y*.

In that case we can have integers *s*, *t*, *u*, and *v* such that

*w*=*s*+*t* = *u*+*v*

*x*=*s*–*t*; *y* = *u*–*v* .

Then

*z*^{2} = 4*d*^{2} = 4*st* + 4*uv*

= 4(*st* + *u*(*s*+*t*–*u*))

*d*^{2} = *st*+*su*+*tu*–*u*^{2} .

If *t* = –*u* then this becomes

*d*^{2} = -2*u*^{2}

with no real solutions. Therefore *t*+*u* is nonzero and we can solve for *s* getting

*s* = (*d*^{2} + *u*^{2} – *tu*) / (*t*+*u*)

= (*d*^{2} + *u*^{2} – (*p*–*u*)*u*) / *p*

= (*d*^{2} + 2*u*^{2}) / *p* – *u* .

Here *p* = *t*+*u*. And this tells us our prescription. Pick positive integers *d* and *u*. Compute *f* = *d*^{2} + 2*u*^{2} and let positive integer *p* be one of the factors of *f* less than sqrt(*f)*. Compute *s* = *f* / *p* – *u* and *t* = *p* – *u*. Then the solution quadruples are to be found among

*x* = *s*–*t*

*y* = 2*u*–*s*–*t*

*z* = 2*d*

*w* = *s*+*t*

I said “to be found among”. This prescription can give negative values for *y*. (Of course, if you take the absolute value of *y*, you end up with a solution quadruple in positive integers.) *y* can also come out to zero. You also can get the same quadruple (in a different order) from different starting values of *d*, *p*, and *u*. So the choices of these parameters do not map onto the positive solution quadruples. But all the solutions are found with this recipe.

For example, take *d*=10 and *u*=20. *d*^{2} + 2*u*^{2} = 900, so a possible value for *p* is 25. Then *s* = 900/25-20 = 16. *t* = 25-20 = 5. Then *x*=11, *y*=19,

*z*=20, and *w*=21 is a solution quadruple: 11^{2}+19^{2}+20^{2} = 121+361+400 = 882 = 2(21^{2}).

Not all solution quadruples can be solved to get three positive integers which add pairwise or all three to squares, but this one can. It’s simple to solve

*l* + *m* = 11^{2}

*l* + *n* = 19^{2}

*m* + *n* = 20^{2} .

The result is *l* = 41, *m* = 80, *n* = 320, all three of which sum to 441 = 21^{2}.