Little explorations with HP calculators (no Prime)
|
11-05-2017, 04:05 PM
(This post was last modified: 11-05-2017 07:19 PM by pier4r.)
Post: #247
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
I am slowly continuing to explore the "integer numerator ranges that enclose pi" (I post it here and not in another thread because I already mentioned the exploration here).
At the moment I'd like to see how the numerators approaches pi keeping a dynamic TopX of approximations. The program I assembled so far does a lot of list processing and the listExt library of DavidM is super helpful. Especially KSORT is great. The program has the following idea: create a list that contains quintuplets { D NL NH VL VH } D: denominator NL: numerator low (minimum of the range given the denominator) NH: numerator high (maximum of the range given the denominator) VL: value NL/D VH: value NH/D I do not just add to the result all the quintuplets between firstDenominator (say 1) and maxDenominator (say 10). Instead I want to add those approximations that make it to the "actual top5", where actual means: considering the quintuplets computed so far. This excluding quintuplets that produce the same best approximation. For example 14 43 44 3.071... 3.14285... is considered equal to 7 21 22 3 3.14285... because the best approximation produced ( 44/14 ) is already in the top 5, since 22/7 was the first instance found for that approximation. (I may later on check if also the second approximation is worth the top5) The program is the following Code:
The program runs on my hp50g in 646 seconds for the first 1000 denominators. And uses 10232 seconds for the first 10k denominators. Seeing the fraction slowly closing in pi is satisfying. The values so far: Code:
I do not use heavy stack manipulations, although I use them more than before. For example I build the list only at the end of the iterations, as suggested by John Keith. I avoid too much stack acrobatics due to readability of the code but I am pretty sure other people could make the program way faster. Therefore I posted it because I am curious to see how it can be optimized. Wikis are great, Contribute :) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)