All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Pythagorean H/L ratios (Posted on 2017-07-08)
Find the smallest pythagorean triple a<b<c where c/a is within 0.005 of 1.54 and then do the same for c/b.

 No Solution Yet Submitted by Jer No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 Another approach Comment 2 of 2 |
I saw Charlie's program and thought there had to be a more efficient way to search for the triplets.

I had an idea of incrementing either the leg or hypotenuse depending if the c/a ratio was either high or low.  I used the parameterization a=u^2-v^2, b=2*u*v, c=u^2+v^2.  If the c/a ratio is too low then v is increased and if the ratio is too high then u is increased.
`    5   print=print+"output.txt"   10   U=2:V=1:C=5:A=3:R=5/3:X=0   15   D=abs(R-1.54)   20   while X<1000   30   if R>1.54 then U=U+1 else V=V+1   40   C=U^2+V^2:A=U^2-V^2:R=C/A:X=X+1:B=2*U*V   45   D2=abs(R-1.54)   46   if D<D2 then 60   47   D=D2   50   print U;V,C;A;B,R   60   wend:'while x   65   print=print`
The original UBASIC program that printed all results is just the multiples of 10.  The other lines add record keeping to only print successively better triangles.  Lines 5 and 65 are for printing to a file.  The output of this program is:
` 4  2 	 20  12  16 	 1.6666666666666666666  6  3 	 45  27  36 	 1.6666666666666666666  7  3 	 58  40  42 	 1.45  9  4 	 97  65  72 	 1.4923076923076923076  11  5 	 146  96  110 	 1.5208333333333333333  13  6 	 205  133  156 	 1.5413533834586466165  26  12 	 820  532  624 	 1.5413533834586466165  39  18 	 1845  1197  1404 	 1.5413533834586466165  52  24 	 3280  2128  2496 	 1.5413533834586466165  65  30 	 5125  3325  3900 	 1.5413533834586466165  78  36 	 7380  4788  5616 	 1.5413533834586466165  89  41 	 9602  6240  7298 	 1.538782051282051282  102  47 	 12613  8195  9588 	 1.5391092129347162903  115  53 	 16034  10416  12190 	 1.5393625192012288786  128  59 	 19865  12903  15104 	 1.5395644423777416104  141  65 	 24106  15656  18330 	 1.5397291773122125702  154  71 	 28757  18675  21868 	 1.5398661311914323962  167  77 	 33818  21960  25718 	 1.5399817850637522768  334  154 	 135272  87840  102872 	 1.5399817850637522768  501  231 	 304362  197640  231462 	 1.5399817850637522768  514  237 	 320365  208027  243636 	 1.5400164401736313074  681  314 	 562357  365165  427668 	 1.5400079416154341188 `
The last line is impressively close to 1.54 for running less than 5 seconds.

After letting the program run longer (x<100000) the best it found was {u=8801, v=4058, c=93924965, a=60990237, b=71428916, r=1.5400000003279213359}.

Edited on July 9, 2017, 12:11 am
 Posted by Brian Smith on 2017-07-09 00:05:16

 Search: Search body:
Forums (0)