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

x/website: Has incorrect value for Pi calculated #53598

elpamyelhsa opened this issue Jun 29, 2022 · 3 comments · May be fixed by golang/website#165

x/website: Has incorrect value for Pi calculated #53598

elpamyelhsa opened this issue Jun 29, 2022 · 3 comments · May be fixed by golang/website#165
NeedsInvestigation website


Copy link

@elpamyelhsa elpamyelhsa commented Jun 29, 2022

What is the URL of the page with the issue?

What is your user agent?

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36



What did you do?

Select "Concurrent pi" from the Try Go dropdown list

What did you expect to see?


What did you see instead?


Getting math correct is really important, 3.14139 should be 3.14159. While this example is supposed to present an approximation of Pi, I would not consider this an approximate value if 15 decimal places are being quoted.

Copy link

@gopherbot gopherbot commented Jun 29, 2022

Change mentions this issue: _content/doc/play: use the Nilakantha Series to compute pi

Copy link

@ZekeLu ZekeLu commented Jun 29, 2022

Interesting! Though the purpose is to show the amazing use case of goroutine and channel, I think it makes sense to choose another implementation that gets a better result in the while.

Here is the updated demo:

Copy link

@robpike robpike commented Jun 29, 2022

P.S. This remarkable algorithm was found by a machine, and proven by mathematicians.

Here is the ivy version, including a pointer to a relevant paper.

# A much more efficient version found by PSLQ. See Nature, Vol 590, page 69.
op PSLQpiTerm N = (/16**N)* (4 / 1+8*N)-(2 / 4+8*N)+(/5+8*N)+(/6+8*N)
op PSLQpi N = +/PSLQpiTerm -1 + iota N

Not what you want here for the Go site, as it converges ridiculously fast and requires bignums, but it is indeed remarkable. You get one hex digit of precision per iteration.

PSLQpi 1

PSLQpi 2

PSLQpi 3

PSLQpi 4 

PSLQpi 5

PSLQpi 6

PSLQpi 7

Couldn't resist.

@dr2chase dr2chase added the NeedsInvestigation label Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
NeedsInvestigation website
None yet

Successfully merging a pull request may close this issue.

6 participants