Skip to content

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

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

Closed
elpamyelhsa opened this issue Jun 29, 2022 · 3 comments
Closed

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

elpamyelhsa opened this issue Jun 29, 2022 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. website

Comments

@elpamyelhsa
Copy link

What is the URL of the page with the issue?

https://go.dev/

What is your user agent?

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

Screenshot

image

What did you do?

Select "Concurrent pi" from the Try Go dropdown list

What did you expect to see?

3.14159265358979

What did you see instead?

3.141392653591791

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.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/414826 mentions this issue: _content/doc/play: use the Nilakantha Series to compute pi

@ZekeLu
Copy link
Contributor

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: https://go.dev/play/p/aeA0HwfYiBz

@robpike
Copy link
Contributor

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
3.13333333333

PSLQpi 2
3.14142246642

PSLQpi 3
3.14158739035

PSLQpi 4 
3.14159245757

PSLQpi 5
3.14159264546

PSLQpi 6
3.14159265323

PSLQpi 7
3.14159265357

Couldn't resist.

@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 1, 2022
@seankhliao seankhliao modified the milestones: Unplanned, Unreleased Aug 20, 2022
@jamalc jamalc modified the milestones: Unreleased, website/unplanned Aug 29, 2022
@golang golang locked and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. website
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants