Discuss Scratch

mumu245
Scratcher
1000+ posts

How to calculate Pi?

PhiPhenomenon wrote:

(#11)
There's a pretty cool infinite sum that can be used to calculate pi:

(I swear there's an image, cubeupload's just down)
However, it's pretty slow. You have to sum like the first thousand terms of the terms to get like the first four places of pi.

There's a faster one called the Machin formula, but it requires a little more math:

(There's also an image here)
You can find the arctangent block from the operators section:
([atan v] of ())
Scratch is not precise enough.

* * *

Decimals in Scratch aren't infinitely precise. The computer uses 58 bits, which equates to about 10 digits.

select this text then press Ctrl+Shift+Down to read more
PhiPhenomenon
Scratcher
500+ posts

How to calculate Pi?

mumu245 wrote:

PhiPhenomenon wrote:

(#11)
There's a pretty cool infinite sum that can be used to calculate pi:

(I swear there's an image, cubeupload's just down)
However, it's pretty slow. You have to sum like the first thousand terms of the terms to get like the first four places of pi.

There's a faster one called the Machin formula, but it requires a little more math:

(There's also an image here)
You can find the arctangent block from the operators section:
([atan v] of ())
Scratch is not precise enough.

* * *

Decimals in Scratch aren't infinitely precise. The computer uses 58 bits, which equates to about 10 digits.
If the OP wanted to, they could use the arbitrary-precision arithmetic described in Super Pi Calc by DadOfMrLog. To avoid loss of precision from Scratch decimals, it uses lists to keep track of individual terms. Then it manually sums them together instead of using the addition operator.

Powered by DjangoBB