From: rusin@vesuvius.math.niu.edu (Dave Rusin) Newsgroups: sci.math Subject: Re: pythagorean triples Date: 22 Feb 1996 17:20:21 GMT One person writes: >Is there a listing of the first 100 pythagorean triples on the internet, Another writes: >>gET READY- HERE THEY ARE. >Sorted according to x > >u" v" x" y" z" x^2 y^2 z^2 > (v^2-u^2) 2uv (u^2+v^2) > >1 2 3 4 5 9 16 25 >2 3 5 12 13 25 144 169 >3 4 7 24 25 49 576 625 etc. (Way more than 100 posted). 1. You missed some. 2. The Bandwidth Police will be contacting you shortly. It would be more compact and more informative to say how you computed these. For the record: if (x,y,z) is a positive Pythagorean triple, _and_ x, y, and z are relatively prime, _and_ y is even (note: x and y can't both be odd) then there exist (relatively prime) integers u and v (of different parity, with v > u ) such that x=(v^2-u^2), y=2uv, z=(u^2+v^2) Conversely, all such triples satisfy x^2+y^2=z^2, x,y,z > 0, y even, and x, y, z relatively prime. In view of the conditions of the theorem, it appears you missed triples such as (4,3,5) (obtained by inversion), and (6,8,10) (obtained by scaling). We may certainly agree that these are 'trivial', but my guess is that the original poster is not at a level to know about such modifications. So perhaps it is better to point out that every triple (x,y,z) will be of one of these forms: ( abd, (a+b)(a-b)d/2, (a^2+b^2)d/2 ) ( 2uvd, (v+u)(v-u)d, (v^2+u^2)d ) for some integers u,v,d, or a,b,d with a and b both odd. (Here I have set a=(v+u), b=(v-u). ) Thus you can sort the triples by x simply by considering for each x all its possible factorizations. There will be many repeats unless you are careful to take gcd(u,v)=1 and so on. dave ============================================================================== Date: Mon, 26 Feb 1996 12:10:42 -0500 (EST) From: [Permission pending] To: rusin@vesuvius.math.niu.edu Subject: Re: pythagorean triples Newsgroups: sci.math Hi Dave. I thought you might like to know another *easy* way to generate all pythagorean triples, with no repeats in the list. Theorem: x^2 + y^2 = z^2 iff k^2 = 2mn where m=z-y, n=z-x, k=x+y-z. Proof: Note x = k + m, y = k + n, and z = k + m + n. Substituting these in for x, y, and z gives (k+m)^2 + (k+n)^2 = (k+m+n)^2 which can be simplified to k^2 = 2mn. Every step is reversible. How to generate all pythagorean triples: Take k to be even, then find every way to choose m and n so that k^2 = 2mn. (Note that if k is odd, then k^2 will be odd, and the left hand side is clearly even.) Let x = k+m, y = k+n, z = k+m+n. Here's a chart: k m n x y z 2 1 2 3 4 5 4 1 8 5 12 13 4 2 4 6 8 10 6 1 18 7 24 25 ============================================================================== Date: Mon, 26 Feb 96 12:02:23 CST From: rusin (Dave Rusin) To: [Permission pending] Subject: Re: pythagorean triples This is nice. I was trying to match the previous poster's intent to sort the triples by x, which is part of why what I suggested was more cumbersome. Also note that if you consider (x,y,z,) and (y,x,z) to be distinct, then the examples you sent are incomplete -- it's _not_ sufficient to take m <=n. Thanks for responding. dave