Discuss Scratch
- mumu245
-
1000+ posts
How to calculate Pi?
(#11)Scratch is not precise enough.
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 ())
* * *
Decimals in Scratch aren't infinitely precise. The computer uses 58 bits, which equates to about 10 digits.
- PhiPhenomenon
-
500+ posts
How to calculate Pi?
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.(#11)Scratch is not precise enough.
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 ())
* * *
Decimals in Scratch aren't infinitely precise. The computer uses 58 bits, which equates to about 10 digits.
- tim_buck_II
-
50 posts
How to calculate Pi?
I have a project that does this: https://scratch.mit.edu/projects/982730462/
Edit: I recommend using method 3 (The Gregory-Leibniz series), because while it doesn't converge quite as quickly as method 2 (the Nilakantha series), scratch “lets” it be more accurate once it's finished
Edit: I recommend using method 3 (The Gregory-Leibniz series), because while it doesn't converge quite as quickly as method 2 (the Nilakantha series), scratch “lets” it be more accurate once it's finished
Last edited by tim_buck_II (April 12, 2025 22:05:59)
- TutoeTurtle
-
100+ posts
How to calculate Pi?
This is the most accurate way to calculate pi:
1/π = 12 * ∑ ((-1)^k * (6k)! * (13591409 + 545140134k) * (3k)! * (k!)^3) / (640320^(3k+3/2))
Unfortunately, there's no sum operator ( ∑ ) in scratch so… yeah. The Chudnovsky Algorithm doesn't work well on scratch.
1/π = 12 * ∑ ((-1)^k * (6k)! * (13591409 + 545140134k) * (3k)! * (k!)^3) / (640320^(3k+3/2))
Unfortunately, there's no sum operator ( ∑ ) in scratch so… yeah. The Chudnovsky Algorithm doesn't work well on scratch.
- N8_D_GR8_1
-
1000+ posts
How to calculate Pi?
I made a program with that algorithm. The problem is I didn't plan for having more than 16 digit precision, so it doesn't get that many digits. It's fast though! This is the most accurate way to calculate pi:https://scratch.mit.edu/projects/1145688427/
1/π = 12 * ∑ ((-1)^k * (6k)! * (13591409 + 545140134k) * (3k)! * (k!)^3) / (640320^(3k+3/2))
Unfortunately, there's no sum operator ( ∑ ) in scratch so… yeah. The Chudnovsky Algorithm doesn't work well on scratch.
- TutoeTurtle
-
100+ posts
How to calculate Pi?
Yup she either didn't know or was just simplifying so you could remember it better.so…my teacher lied…she said 22/7 WAS piThe OP wants an approximation of pi that goes on as long as they can. 22/7 comes out to about 3.1428. That's a 0.0403% error from the actual value of pi, so it's fine to use in calculations. However, it's 3rd decimal place is already wrong. but my teacher said to use that
did my teacher lie to me?
- somethingelse0_0
-
65 posts
How to calculate Pi?
its just for easier calculation, as pi is irrationalbut my teacher said to use thatThat is a terrible estimation of pi compared to what OP's asking for. 22/7 = pi
did my teacher lie to me?
- somethingelse0_0
-
65 posts
How to calculate Pi?
there are actually a lot of ways to find pi
- somethingelse0_0
-
65 posts
How to calculate Pi?
It's impossible to do this, because we cannot measure the circumference and diameter of a circle perfectly. It is a good estimation, but not good enough. circumference / diameter
Last edited by somethingelse0_0 (May 24, 2025 09:28:43)
- -20thaccount-
-
52 posts
How to calculate Pi?
here's a funny approach
https://scratch.mit.edu/projects/682780554/
WHY DOES IT SAY Last edited by kaj (Tomorrow 00:00:00)
- N8_D_GR8_1
-
1000+ posts
How to calculate Pi?
It is just a part of his signature. In case you didn't know, kaj is an older user that made a big commotion about hacking scratch to get attention.here's a funny approach
https://scratch.mit.edu/projects/682780554/
WHY DOES IT SAY Last edited by kaj (Tomorrow 00:00:00)
last edited by skibidifarm (-100 BC 99:99:99)