Compute Pi

7 posts / 0 new
Last post
Marvan0305's picture
Online
Last seen: 22 sec ago
Joined: Sep 19 2022 - 15:54
Posts: 9
Compute Pi

Can the Apple 2 Compute pi? If so what software?

Dr. Webster's picture
Offline
Last seen: 7 hours 6 min ago
Joined: Dec 19 2003 - 17:34
Posts: 1732
Yes, it can be done in BASIC.

Yes, it can be done in BASIC. See page 15 of this journal from 1978: http://archive.6502.org/publications/micro/micro_06_aug_1978.pdf

mmphosis's picture
Offline
Last seen: 4 days 17 hours ago
Joined: Aug 18 2005 - 16:26
Posts: 385
?4*ATN(1)

]PI=3.1415926535

]PRINT PI

3.14159266

How much precision were you looking for?

I am particular to tau: τ which is 2 * PI

]TAU = 8 * ATN(1)

]PRINT TAU

6.28318531

CVT
Online
Last seen: 1 hour 18 min ago
Joined: Aug 9 2022 - 00:48
Posts: 42
I don't think you get the

I don't think you get the point. The question was about computing PI to a very large number of decimals, not just 8.

macnoyd's picture
Online
Last seen: 56 min 5 sec ago
Joined: Oct 15 2012 - 08:59
Posts: 771
Clever way to calculate Pi

I found this to be a clever way to calculate Pi.  Not sure who came up with it, but it would be easy to write a basic program to do this.

 

Take 4 and subtract "4 divided by 3".

Then add "4 divided by 5".

Then subtract "4 divided by 7".

Continue alternating between adding and subtracting fractions with a numerator of 4 and a denominator of each subsequent odd number.

The more times you do this, the closer you will get to pi.

 

It would be nice to compare the calculation time to (say) 20 digits or so using Applesoft Basic vs. a Binary run-able calculation.

Offline
Last seen: 3 hours 40 min ago
Joined: Feb 27 2021 - 18:59
Posts: 192
Taylor

It's an application of the Taylor series. See https://math.hmc.edu/funfacts/taylor-made-pi/

Offline
Last seen: 4 hours 41 min ago
Joined: Jun 12 2022 - 23:35
Posts: 69
That's the Leibniz series:Pi

That's the Leibniz series:

Pi/4 = 1 - 1/3 + 1/5 - 1/7 ....

It is based on the Taylor series for the arctangent function

ATAN(X) = X - X/3 + X/5 - X/7 ...

knowing that ATN 1 = pi/4

unfortunately it converges logarithmically.  Basically you have to double the number of terms you need for each additional digit of accuracy.  Literally millions of terms are needed for 6 or 7 digits of accuracy.

The most efficient series I believe is the Bailey-Borwein-Plouffe formula and Bellard's formula

https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula

https://en.wikipedia.org/wiki/Bellard%27s_formula

It can directly generate binary digits of pi.  It is used in all of the big pi computation projects.

 

 

Log in or register to post comments