Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upBbp formula #1989
Bbp formula #1989
Conversation
|
I didn't intend to include aliquot_sum.py in the pull request but it was added for some reason. Is there a way to make my pull request only include the addition of bbp_formula.py? |
|
This is pretty cool! One issue with this implementation however: Currently it is limited to pythons standard double precision calculation. Which means regardless of how many iterations you supply you function with it will not get any more precise than that. To get around this we can use pythons builtin module One note about the formula itself: This is mainly used for finding the n-th number of pi without needing to calculate any of the previous digits! Which means we can efficiently calculate the 1 billionth digit of pi without needing to know the digits leading up to that one. So maybe another PR can be opened using with this same file but implements a new function called |
| # num_iterations + 1 because sum notation includes the last term | ||
| for index in range(num_iterations + 1): |
This comment has been minimized.
This comment has been minimized.
TheSuperNoob
May 16, 2020
Contributor
I'm not sure the + 1 part actually is needed. By definition this is an infinite sum which just gets more and more accurate with each iteration, so anytime you stop is technically the last iteration :)
And it might fit better to how you define num_iterations as well. As an example, default value for num_iterations is 1000, and starting with 0 and ending with 999 gives you a total of 1000 iterations.
Very minor detail though and shouldn't affect the final result.
ken437 commentedMay 16, 2020
Describe your change:
Adds an algorithm that approximates pi using the Bailey-Borwein-Plouffe formula, described at https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula
Checklist:
Fixes: #{$ISSUE_NO}.