Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement reciprocal Fibonacci constant #1619

Merged
merged 1 commit into from Nov 15, 2023
Merged

Implement reciprocal Fibonacci constant #1619

merged 1 commit into from Nov 15, 2023

Conversation

fredrik-johansson
Copy link
Collaborator

@fredrik-johansson fredrik-johansson commented Nov 15, 2023

A nearly useless mathematical constant, but I couldn't not implement it, just to have as a benchmark, when I realized that the preposterous series by Bill Gosper leads to a quasilinear-time algorithm (did no one else notice this before?).

In terms of speed, we have, for example, pi < reciprocal_fibonacci < log2:

~/src/flint$ build/examples/pi 10000000 -constant reciprocal_fibonacci -threads 8
precision = 33219285 bits... cpu/wall(s): 8.159 1.468
virt/peak/res/peak(MB): 799.89 799.89 489.29 489.29
[3.35988566624317755317{...9999959 digits...}54369788228597414996 +/- 2.55e-10000000]

~/src/flint$ build/examples/pi 10000000 -constant pi -threads 8
precision = 33219285 bits... cpu/wall(s): 3.809 0.644
virt/peak/res/peak(MB): 687.07 687.07 252.21 252.21
[3.14159265358979323846{...9999959 digits...}63171948173534895590 +/- 3.20e-10000000]

~/src/flint$ build/examples/pi 10000000 -constant log2 -threads 8
precision = 33219285 bits... cpu/wall(s): 14.056 2.429
virt/peak/res/peak(MB): 806.46 937.12 475.55 475.55
[0.69314718055994530941{...9999960 digits...}80135652602465385883 +/- 3.19e-10000001]

Edit: 1 billion digits in 12 minutes; I need to drop down to 2 threads or I run out of memory:

~/src/flint$ build/examples/pi 1000000005 -constant reciprocal_fibonacci -threads 2
precision = 3321928116 bits... cpu/wall(s): 1009.31 718.785
virt/peak/res/peak(MB): 16534.32 18638.34 15483.07 18098.75
[3.35988566624317755317{...999999964 digits...}02927932123820488401 +/- 2.91e-1000000005]

@fredrik-johansson fredrik-johansson merged commit cc5fbd2 into trunk Nov 15, 2023
17 checks passed
@mezzarobba
Copy link
Contributor

mezzarobba commented Nov 15, 2023

I realized that the preposterous series by Bill Gosper leads to a quasilinear-time algorithm

I wonder if this would generalize to a wider class of series using the ideas in https://epubs.siam.org/doi/abs/10.1137/1.9781611976496.14 (this is just wild speculation because of a vague formal analogy; I didn't try to understand what you are doing). Edit: probably not, I think I just imagined a link that doesn't really exist...

@fredrik-johansson
Copy link
Collaborator Author

Yeah, it's really interesting. Some more comments here: https://fredrikj.net/blog/2023/11/the-reciprocal-fibonacci-constant/

@fredrik-johansson fredrik-johansson deleted the fibonacci branch November 16, 2023 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants