Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Equation needed to calculate Pi to 100 or more decimal place

1 view
Skip to first unread message

Sean Dees

unread,
Feb 24, 1996, 3:00:00 AM2/24/96
to
Hi, I need an equation or formula that I can use to calculate Pi to more
than 100 decimal places... What is the formula that I should use? Thanks...

--
-Sean Dees.
Sean...@Mindlink.bc.ca
(Finished BT I - III, Wiz I - III
Ultima I, II, IV, M&M I, II)
If at first you don't succeed, destroy all evidence that you tried.


Pritpal Singh Narula

unread,
Feb 25, 1996, 3:00:00 AM2/25/96
to
Sean Dees (Sean...@mindlink.bc.ca) wrote:
: Hi, I need an equation or formula that I can use to calculate Pi to more

: than 100 decimal places... What is the formula that I should use? Thanks...

: --
: -Sean Dees.


--

/1 4 dx
Pi= | --------------
/0 1 + x^2

Paul
Math is
fun!
///// __MMM__ /
( o o ) (o o)
--------------o00--(_)--00o-----------oo0--(_)--0oo-----------------
| |
| Pritpal S. Narula NORTH CAROLINA STATE UNIVERSITY |
| NCSU Teaching Fellow Math Education / Mathematics |
| psna...@unity.ncsu.edu Freshman |
| |
| http://www4.ncsu.edu/unity/users/p/psnarula/www/ |
| |
|__________________________________________________________________|

h...@iwaynet.net

unread,
Feb 25, 1996, 3:00:00 AM2/25/96
to
Sean Dees wrote:
>
> Hi, I need an equation or formula that I can use to calculate Pi to more
> than 100 decimal places... What is the formula that I should use? Thanks...


Here's an equation that I figured out:

The limit of n*sin(360/n)/[2*cos(180/n)] as n approachs infinity equals
pi.

Higher the n, closer the answer is to pi. You can be as accurate as you
want; that is if you have the enouph time.

Jeppe Stig Nielsen

unread,
Feb 26, 1996, 3:00:00 AM2/26/96
to

I, myself, figured an even smarter equation out.

4*Arctan(1)+0*n

Already for n=1 you have more than 100 correct digits.


O \
- |
O /

/Jeppe


Bill Daly

unread,
Feb 26, 1996, 3:00:00 AM2/26/96
to
>Hi, I need an equation or formula that I can use to calculate Pi to more
>than 100 decimal places... What is the formula that I should use?

The "classical" approach uses the Machin identity

pi/4 = 4*atan(1/5) - atan(1/239)

You can calculate as many terms as you need of the atan() function via

atan(x) = x - x^3/3 + x^5/5 - ... + x^(4n+1)/(4n+1) - x^(4n+3)/(4n+3)
+ ...

Regards,

Bill

steve jeffrey harsh

unread,
Feb 27, 1996, 3:00:00 AM2/27/96
to Sean...@mindlink.bc.ca
The pi/4 equation that people usually know offhand converges rather slowly. Go
to some book and find Ramunjam's formula for pi which converges much! more
quickly to pi.


Colm Caulfield

unread,
Feb 27, 1996, 3:00:00 AM2/27/96
to
Bill Daly <nu...@chelsea.ios.com> wrote:
>Hi, I need an equation or formula that I can use to calculate Pi to more
>than 100 decimal places... What is the formula that I should use?

A nice impressive way to do this is to use a formula due to Ramanujan:
Consider the expression

a_n =[(4n)!]*(1103 +26390*n)/{[n!]*396^n}^4

Then define the partial sum

S_N = [(8)^(1/2)/9801]*[Sum (from n=0 to N) of a_n] (oh for TeX!)

then 1/S_12 -pi = 4.372 x 10^(-104) (yes just 13 terms according to Maple!)

You need about 140-150 or so terms in each atan of Machins formula for this
level of accuracy (though of course such terms are easier to work out).
Every extra term in Ramanujan's formula increases the accuracy by about 8
decimal places.
Don't ask me how it works! Of course since I don't know how Maple does it
I can't guarantee that this isn't a circular argument ...
Hope that helps
Colm
--
*******************************************************************************
*(Dr) C.P. Caulfield Room 3.6 *
* email: c.p.ca...@bris.ac.uk School of Mathematics *
* Phone: +44-117-928-7996 (office) University of Bristol *
* University Walk *
* fax: +44-117-928-7999 Bristol BS8 1TW UK *
*******************************************************************************


Colin Andrew Percival

unread,
Feb 27, 1996, 3:00:00 AM2/27/96
to
Sean Dees (Sean...@mindlink.bc.ca) wrote:
: Hi, I need an equation or formula that I can use to calculate Pi to more
: than 100 decimal places... What is the formula that I should use? Thanks...

inf.
---
Pi= \ (-i)
/ 16 * (4/(8i+1)-2/(8i+4)-1/(8i+5)-1/(8i+6))
---
i=1

You get approx. one hexadecimal digit (hexit?) for each term.

Dave Carpenter

unread,
Feb 27, 1996, 3:00:00 AM2/27/96
to
In article <83716-8...@mindlink.bc.ca>, Sean...@mindlink.bc.ca
(Sean Dees) wrote:

> Hi, I need an equation or formula that I can use to calculate Pi to more
> than 100 decimal places... What is the formula that I should use? Thanks...
>

> --
> -Sean Dees.
> Sean...@Mindlink.bc.ca
> (Finished BT I - III, Wiz I - III
> Ultima I, II, IV, M&M I, II)
> If at first you don't succeed, destroy all evidence that you tried.


How's this:

3.141592653589793238462643383279502884197169399375
10582097494459230781640628620899862803482534211706
79821480865132823066470938446095505822317253594081
28481117450284102701938521105559644622948954930381
96442881097566593344612847564823378678316527120190
91456485669234590992071188568065167451942528543409
64271825877594867237227818052636476240001253966769
58803786501460828202281029373153209312571960818250
88055454747385671998418586374609396532665152059732
30200470327367748014549418069976867613243271975438
84752285691446935454123565860783675210974816763774
40424443575913441029549872673485321553452260748746
07261272294756681440117171146164262329464280245194
16553103668226495999762474794964971942580962672394
35363909125367602466641661175276866349685951195337
90744923019073345333321686533168484290724097901531
07727405217592705578811026822246918337594614683389
32957689482234549106188131656936386750207761473092
71039650546608291414446931319129743860775232869818
000001373465107828774083538328579350606183962012466


:)
Dave

gold...@wisenet.net

unread,
Feb 28, 1996, 3:00:00 AM2/28/96
to
> Sean...@mindlink.bc.ca (Sean Dees) writes:
> Hi, I need an equation or formula that I can use to calculate Pi to more
> than 100 decimal places... What is the formula that I should use? Thanks...
>
> --
> -Sean Dees.
> Sean...@Mindlink.bc.ca
> (Finished BT I - III, Wiz I - III
> Ultima I, II, IV, M&M I, II)
> If at first you don't succeed, destroy all evidence that you tried.
>
>
>
>
>>>>
Here is a quick basic program which will give more than 20000 digits of pi
without modification. The last few digits may not be reliable. It uses some
coding to reduce the length of the arrays being acted upon.

DECLARE SUB add (digits AS INTEGER, w AS INTEGER, sum1() AS INTEGER, term() AS INTEGER)
DECLARE SUB subt (digits AS INTEGER, w AS INTEGER, sum1() AS INTEGER, term() AS INTEGER)
DECLARE SUB prnt (digits AS INTEGER, term() AS INTEGER)
DECLARE SUB LongDiv (digits AS INTEGER, d AS INTEGER, w AS INTEGER, term() AS INTEGER)
DIM digits AS INTEGER, dgts AS INTEGER
DEFINT D, I-K, N, W
CLS
OPEN "LPT1" FOR OUTPUT AS #1
WIDTH #1, 80
INPUT "Number of digits? ", dgts
digits = dgts \ 4 + 3
PRINT #1, TIME$
OPTION BASE 0
DIM sum1(0 TO digits) AS INTEGER
DIM term(0 TO digits) AS INTEGER
DIM temp(0 TO digits) AS INTEGER
term(1) = 16
w = 0
CALL LongDiv(digits, 5, w, term())
CALL add(digits, w, sum1(), term())
j = 0
DO WHILE 1
j = j + 1
WHILE term(w) = 0 AND w < (digits - 1)
w = w + 1
WEND
IF w = (digits - 1) THEN EXIT DO
CALL LongDiv(digits, 25, w, term())
FOR i = 0 TO (digits - 1)
temp(i) = term(i)
NEXT i
k = 2 * j + 1
PRINT w;
CALL LongDiv(digits, k, w, temp())
IF j MOD 2 > 0 THEN
CALL subt(digits, w, sum1(), temp())
ELSE CALL add(digits, w, sum1(), temp())
END IF
LOOP
FOR i = 0 TO digits
term(i) = 0
NEXT i
term(1) = 4
w = 0
CALL LongDiv(digits, 239, w, term())
CALL subt(digits, w, sum1(), term())
PRINT
j = 0
DO WHILE 1
j = j + 1
WHILE term(w) = 0 AND w < (digits - 1)
w = w + 1
WEND
IF w = (digits - 1) THEN EXIT DO
CALL LongDiv(digits, 239, w, term())
CALL LongDiv(digits, 239, w, term())
FOR i = 0 TO (digits - 1)
temp(i) = term(i)
NEXT i
k = 2 * j + 1
PRINT w;
CALL LongDiv(digits, k, w, temp())
IF j MOD 2 > 0 THEN
CALL add(digits, w, sum1(), temp())
ELSE CALL subt(digits, w, sum1(), temp())
END IF
LOOP
PRINT
PRINT #1, TIME$
CALL prnt(digits, sum1())
PRINT #1, TIME$
PRINT #1, CHR$(10)
CLOSE #1
END

DEFSNG D, I-K, N, W
SUB add (digits AS INTEGER, w AS INTEGER, sum1() AS INTEGER, term() AS INTEGER)
DEFINT I
i = (digits - 1)
WHILE i >= w
sum1(i) = sum1(i) + term(i)
IF sum1(i) > 9999 THEN
sum1(i) = sum1(i) - 10000
sum1(i - 1) = sum1(i - 1) + 1
END IF
i = i - 1
WEND
END SUB

DEFSNG I
SUB LongDiv (digits AS INTEGER, d AS INTEGER, w AS INTEGER, term() AS INTEGER)
DEFINT I, R
i = w
r = 0
WHILE i <= (digits - 1)
s& = r * 10000& + term(i)
term(i) = INT(s& / d)
r = s& MOD d
i = i + 1
WEND
END SUB

DEFSNG I, R
SUB prnt (digits AS INTEGER, term() AS INTEGER)
DEFINT I, U
FOR U = 1 TO (digits - 1)
IF term(U) > 999 THEN
PRINT #1, " " + MID$(STR$(term(U)), 2, 5);
ELSEIF term(U) > 99 THEN
PRINT #1, " 0" + MID$(STR$(term(U)), 2, 4);
ELSEIF term(U) > 9 THEN
PRINT #1, " 00" + MID$(STR$(term(U)), 2, 3);
ELSE PRINT #1, " 000" + MID$(STR$(term(U)), 2, 2);
END IF
NEXT U
PRINT #1,
END SUB

DEFSNG I, U
SUB subt (digits AS INTEGER, w AS INTEGER, sum1() AS INTEGER, term() AS INTEGER)
DEFINT I
i = (digits - 1)
WHILE i >= w
sum1(i) = sum1(i) - term(i)
IF sum1(i) < 0 THEN
sum1(i) = sum1(i) + 10000
sum1(i - 1) = sum1(i - 1) - 1
END IF
i = i - 1
WEND
END SUB

Kirill Ilukhin

unread,
Feb 29, 1996, 3:00:00 AM2/29/96
to

Hi, Jeppe !

Monday February 26 1996, Jeppe Stig Nielsen wrote:

>>> Hi, I need an equation or formula that I can use to calculate Pi to more
>>> than 100 decimal places... What is the formula that I should use?
>>> Thanks...

Here is the best way, IMHO:
n 2n+1
arctg(x)=sum ((-1) x )/(2n+1) ; n=1,2,3,...

n
pi/4=arctg(1)= sum (-1) /(2n+1) ;

So
pi=4(1-1/3+1/5-1/7+1/9-...)

You'll need to complete approx 10^100 steps to get Pi to 100 decimal places,
but there are a lot of ways to optimize this algorithm.

BRGDS, Kirill .
” Ilukhin Kirill
Mechanico-Mathematical Department of
Ulyanovsk State University
Ulyanovsk, Russia.


0 new messages