Finding the Number of Pythagorean Triples below a bound
- To: mathgroup at smc.vnet.net
- Subject: [mg68189] Finding the Number of Pythagorean Triples below a bound
- From: titus_piezas at yahoo.com
- Date: Sat, 29 Jul 2006 01:00:02 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hello all, Given the equation a^2+b^2 = c^2 with (a,b,c) positive integers, 0<a<=b. (For argument's sake, a=b will be allowed.) Let S(10^m) be the number of solutions with hypotenuse c < bound 10^m. (They need not be primitive.) Problem: Find S(10^m). What would be an efficient Mathematica code for this? The explicit (a,b,c)'s are not needed, just S(10^m). I also need "m" as high as possible, maybe m=6,7, with a reasonable run-time, say, less than an hour. (A kind person gave me a code but told me it may be practical only up to m=3.) I stumbled upon some code some time ago, but it only gives the explicit (a,b,c)'s with c<10^m, not the count: Block[{a,b}, For[a=1,a<(10^m/Sqrt[2]),a++, For[b=a,b<10^m,b++, If[Sqrt[a^2+b^2]==Round[Sqrt[a^2+b^2]]&&Sqrt[a^2+b^2]<10^m, Print[{a,b,Sqrt[a^2+b^2]}]]]]] for some positive integer "m". Can the above program be modified to give S(10^m)? Or what program would be fast, for m=6,7? Any help would be appreciated. Thanks. -Titus
- Follow-Ups:
- Re: Finding the Number of Pythagorean Triples below a bound
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Finding the Number of Pythagorean Triples below a bound