Re: calculating PI



On 9/28/08 11:50 AM, in article 1222617002.877.1222614035@xxxxxxxxxx, "David
Williams" <david.williams@xxxxxxxxxx> wrote:

-> I always liked the Montecarlo method for determining PI!

It's awfully slow, though!

I came across the following little thing on an old disk. It calculates
PI to amazing precision very quickly. I think someone gave it to me.
Maybe I understood it then, but not now. Can anyone tell me, please?

dow

-----------------------------------------

' PI calculator
DEFINT C, Z
DEFLNG D
DEFDBL P-T
P = 0
Q = 0
R = 0
S = 0
T = 0
D = 1
Z = 2
CLS
PRINT 4# * ATN(1)
FOR C = 1 TO 1000
T = S
S = R
R = Q
Q = P
P = P + 1 / D
Z = -Z
D = Z - D
NEXT
PRINT (P + 4 * (Q + S) + 6 * R + T) / 4
END

------------------------------------------------
Wow...

I ran this in TI-99 Extended Basic (all floats, a form of base-100 BCD).

When I assigned the expression to PIE at the end and printed PI-PIE, got 0
(with no ".").

First, PI is of course the constant for PI.
Second, before anyone says that it is really PI-PI because of 2-digit
variable names, TI has 15-significant characters in the variable name.
Third, a "." after a number when printed means the number is not exact, but
is outside the range of normal printing rules (thus requiring a PRINT
USING).

I'm trying to get the source-code to a fellow TI'ers program that calculates
PI to 5200 decimal places.

Recent post:
"Hi.

I'm pleased to announce that our TI 99/4A computer has calculated the
first 5200 decimals of Pi in 184 hours of continuous operation using
my PICALC XB program! I believe this is a record among all classic 8
bit computers (by far)."

I'll follow up with the source when I can get it converted... althought I
highly doubt the record... speed is not one of the 99's qualities.

.



Relevant Pages

  • Re: Math errors in python
    ... They don't even share three digits beyond the decimal point. ... > yet not all fractions can be represented by decimals. ... Hardware designers have settled on a binary representation of floating ... And BTW, your calculator is not, in general, more accurate than the ...
    (comp.lang.python)
  • Re: ((.99999.... == 1) == 1) = 1
    ... >Using Powertoys Calculator on Windows XP, I can disply up to 140 decimal ... as many digits as you want. ... 140 come no where near an infinite number of decimals. ...
    (sci.math)
  • Calculator Answer Doesnt Match Excel Answer
    ... calculator, and got $106,000,000. ... Excel gives me $103,246,753.25 as the answer. ... as currency with two decimals. ... college-level Finance class exam. ...
    (microsoft.public.excel.misc)
  • Re: Ruby Numbers
    ... In first_steps it looks at using ruby as a calculator ... are running into here is how Ruby handles floating point values. ... => 10.3359 4 decimals should only be three ...
    (comp.lang.ruby)