[sci.math] Program for Calculating PI

avenger@wpi.WPI.EDU (Samuel Joseph Pullara) (04/03/91)

Could someone please send me a program that will calculate PI to any
arbitrary number of digits?  Thanks in advance...

--
/------------------------------------------------------------------------\
| Sam Pullara, Undergraduate Physics     Worcester Polytechnic Institute |
| avenger@wpi.wpi.edu                      (c) 1990 Avenger Publications |
|______________-All my opinions were expressed or implied.-______________|

bs@faron.mitre.org (Robert D. Silverman) (04/03/91)

In article <AVENGER.91Apr2185942@wpi.WPI.EDU> avenger@wpi.WPI.EDU (Samuel Joseph Pullara) writes:
>Could someone please send me a program that will calculate PI to any
>arbitrary number of digits?  Thanks in advance...
 
Let me add my opinion.

Please do NOT comply with the above request.

If the poster wants a large number of digits [of pi], over 1 billion
have already been calculated.

If the poster wants to know HOW it is done, he would be better off
studying the actual mathematics than by reading some computer program.
He might even then [God forbid!] learn something by writing his own
program.

I fail to see what the poster hopes to accomplish by having someone else
hand him a black box program to compute something that has already been
done many times. All the poster would do is waste CPU time on some machine
repeating those calculations, while learning NOTHING in the process.
 
On the other hand, if the user wants to know about HOW the Chudnovskys
did the calculation (using an analytic continuation of a formula of
Ramanujan), I'll be GLAD to provide that information.
Or if he wants to know how D. Bailey (et. al.) used the arithmetic-geometric
mean along with FFT multiply routines to calculate Pi to many places, I'll
be happy to provide that as well.


The above request sounds suspiciously like a homework assignment to me.
--
Bob Silverman
#include <std.disclaimer>
Mitre Corporation, Bedford, MA 01730
"You can lead a horse's ass to knowledge, but you can't make him think"

kasdan@cunixa.cc.columbia.edu (John Kasdan) (04/03/91)

In article <1991Apr3.014832.15021@linus.mitre.org> bs@faron.mitre.org (Robert D. Silverman) writes:
>In article <AVENGER.91Apr2185942@wpi.WPI.EDU> avenger@wpi.WPI.EDU (Samuel Joseph Pullara) writes:
>>Could someone please send me a program that will calculate PI to any
>>arbitrary number of digits?  Thanks in advance...
> 
>Let me add my opinion.
>
>Please do NOT comply with the above request.
>
>If the poster wants a large number of digits [of pi], over 1 billion
>have already been calculated.
>
>If the poster wants to know HOW it is done, he would be better off
>studying the actual mathematics than by reading some computer program.
>He might even then [God forbid!] learn something by writing his own
>program.
>
>I fail to see what the poster hopes to accomplish by having someone else
>hand him a black box program to compute something that has already been
>done many times. All the poster would do is waste CPU time on some machine
>repeating those calculations, while learning NOTHING in the process.
> 
>On the other hand, if the user wants to know about HOW the Chudnovskys
>did the calculation (using an analytic continuation of a formula of
>Ramanujan), I'll be GLAD to provide that information.
>Or if he wants to know how D. Bailey (et. al.) used the arithmetic-geometric
>mean along with FFT multiply routines to calculate Pi to many places, I'll
>be happy to provide that as well.
>
>

I, for one, would be very happy to see Mr. Silverman post the above
information.  The only article on the Chudnovsky's work that I have
seen is in the NAS journal, and I can't follow the details.  On the
other hand, I found the bc program which was posted a while ago to be
fascinating.  I had not realized that the algorithm was anything like
that short.  True, I did not understand what integral it was
evaluating, nor why it worked but, as is the case with much
mathematics that I see or hear, I got some sort of feeling for what
was going on that might make me more receptive the next time I get a
chance to learn more (which will be, I hope, in the near future when
Mr. Silverman makes good on his promise.)

>The above request sounds suspiciously like a homework assignment to me.
>--

This sounds like paranoia to me; what kind of class could possibly
assign such homework?   

>Bob Silverman
>#include <std.disclaimer>
>Mitre Corporation, Bedford, MA 01730
>"You can lead a horse's ass to knowledge, but you can't make him think"


/KAS            
John Kasdan,  Columbia University School of Law
"If there weren't so many people righting wrongs, there wouldn't be so
many wrongs to right". H.J. Simon, Bridge in the Menagerie.

ct@dde.dk (Claus Tondering) (04/03/91)

bs@faron.mitre.org (Robert D. Silverman) writes:

>In article <AVENGER.91Apr2185942@wpi.WPI.EDU> avenger@wpi.WPI.EDU (Samuel Joseph Pullara) writes:
>>Could someone please send me a program that will calculate PI to any
>>arbitrary number of digits?  Thanks in advance...
> 
>Let me add my opinion.
>
>Please do NOT comply with the above request.
>
>If the poster wants a large number of digits [of pi], over 1 billion
>have already been calculated.
>
>I fail to see what the poster hopes to accomplish by having someone else
>hand him a black box program to compute something that has already been
>done many times. All the poster would do is waste CPU time on some machine
>repeating those calculations, while learning NOTHING in the process.

But you forget something: The pure joy of seeing something work! I think I
understand the original poster's motives for issuing his request, and I can
certainly sympathize. There is a simple pleasure in seeing a computer print
out the result of a complex calculation. This joy is purely irrational - it
has nothing to do with the joy of learning or the joy of creating - but it
is a joy nevertheless. However, the joy disappears if the computer program
is simply printing a string of digits that have been hard-coded into the
program from a book.

Bob, your reply is 100% reasonable from a purely logical point of view; but
there are pleasures in this world that cannot be justified by logic, and
seeing a computer print out the digits of PI or e or sqrt(2) as the result
of a computation is one of those pleasures.
-- 
Claus Tondering,         Dansk Data Elektronik A/S, Herlev, Denmark
E-mail: ct@dde.dk
------------------------------------------------------------------------------
1 ns < 2 cents < 10 V < 1 km < 100 degrees C < 20 mips < 4 MPa < 1,000,000,000

digdon@ug.cs.dal.ca (Mike Digdon) (04/04/91)

In article <1991Apr3.014832.15021@linus.mitre.org> bs@faron.mitre.org (Robert D. Silverman) writes:
>In article <AVENGER.91Apr2185942@wpi.WPI.EDU> avenger@wpi.WPI.EDU (Samuel Joseph Pullara) writes:
>>Could someone please send me a program that will calculate PI to any
>>arbitrary number of digits?  Thanks in advance...
> 
>Let me add my opinion.
>
>Please do NOT comply with the above request.
>
>If the poster wants a large number of digits [of pi], over 1 billion
>have already been calculated.
>
>If the poster wants to know HOW it is done, he would be better off
>studying the actual mathematics than by reading some computer program.
>He might even then [God forbid!] learn something by writing his own
>program.
>
>I fail to see what the poster hopes to accomplish by having someone else
>hand him a black box program to compute something that has already been
>done many times. All the poster would do is waste CPU time on some machine
>repeating those calculations, while learning NOTHING in the process.

Indeed, why waste time doing something that was already done.. perhaps that
is why he is asking for the program... why go thru all of the programming
when it has already been done before? Re-inventing the wheel is not what
programming is all about..
So if he wants a program, by all means, let him have it... if he wants
to learn, he can study code.. that's the best way to learn..

bs@gauss.mitre.org (Robert D. Silverman) (04/04/91)

In article <1991Apr4.132101.9623@cs.dal.ca> digdon@ug.cs.dal.ca (Mike Digdon) writes:
:In article <1991Apr3.014832.15021@linus.mitre.org> bs@faron.mitre.org (Robert D. Silverman) writes:
:>In article <AVENGER.91Apr2185942@wpi.WPI.EDU> avenger@wpi.WPI.EDU (Samuel Joseph Pullara) writes:
:>>Could someone please send me a program that will calculate PI to any
:>>arbitrary number of digits?  Thanks in advance...
:> 
:>Let me add my opinion.
:>
:>Please do NOT comply with the above request.
:>
:>If the poster wants a large number of digits [of pi], over 1 billion
:>have already been calculated.
:>
:>If the poster wants to know HOW it is done, he would be better off
:>studying the actual mathematics than by reading some computer program.
:>He might even then [God forbid!] learn something by writing his own
:>program.
:>
:>I fail to see what the poster hopes to accomplish by having someone else
:>hand him a black box program to compute something that has already been
:>done many times. All the poster would do is waste CPU time on some machine
:>repeating those calculations, while learning NOTHING in the process.
:
:Indeed, why waste time doing something that was already done.. perhaps that
:is why he is asking for the program... why go thru all of the programming
:when it has already been done before? Re-inventing the wheel is not what
:programming is all about..
:So if he wants a program, by all means, let him have it... if he wants
:to learn, he can study code.. that's the best way to learn..
 -------------------------------------------------------------


I don't know about everyone else, but the attitude implied by this
last sentence frightens me. No wonder today's undergraduates are
ill-prepared. 

The way to learn how to compute Pi is to study the math and the algorithms,
not to look at someone else's code.


As for not reinventing the wheel, I agree, but......

Why does one need a black box program to compute the digits of Pi???
Why repeat calculations that have already been done (and published!) before???
The simple act of running such a program is in fact reinventing the wheel....

If it's the digits one wants, then they are available.

If one wants the program for the pleasure of computing something, that I
can understand. But why something that's been done thousands of time???
Why not something new?? How about a program to compute one of the less
famous transcendental constants? 


And.... (pardon my language)

WHAT IS SO FUCKING SPECIAL ABOUT COMPUTING PI AS OPPOSED TO SOME OTHER NUMBER???

--
Bob Silverman
#include <std.disclaimer>
Mitre Corporation, Bedford, MA 01730
"You can lead a horse's ass to knowledge, but you can't make him think"

jroth@allvax.enet.dec.com (Jim Roth) (04/05/91)

In article <1991Apr4.150053.29873@linus.mitre.org>, bs@gauss.mitre.org (Robert D. Silverman) writes...

>WHAT IS SO * SPECIAL ABOUT COMPUTING PI AS OPPOSED TO SOME OTHER NUMBER???

    "I am ashamed to tell you how man digits I carried in the computation,
     having no other business at the time"

     - I. Newton, quoted in "A History of PI"

picquend@unix1.cs.umass.edu (Marc Picquendar) (04/05/91)

In article <1991Apr4.150053.29873@linus.mitre.org> bs@gauss.mitre.org (Robert D. Silverman) writes:
WHAT IS SO FUCKING SPECIAL ABOUT COMPUTING PI AS OPPOSED TO SOME OTHER NUMBER???
>

I might sound blase, but I don't get any kicks out of computing 1
anymore.

Marc

xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan) (04/05/91)

[Computing Pi to arbitrary precision: what kind of a class could assign
such homework anyway?]

My 1962 numerical analysis class for one.  It is an excellent introduction
to questions of roundoff error, managing large datasets, literature searches,
and, of course, arbitrary precision arithmetic.

Kent, the man from xanth.
<xanthian@Zorch.SF-Bay.ORG> <xanthian@well.sf.ca.us>

ct@dde.dk (Claus Tondering) (04/05/91)

bs@gauss.mitre.org (Robert D. Silverman) writes:

>WHAT IS SO FUCKING SPECIAL ABOUT COMPUTING PI AS OPPOSED TO SOME OTHER NUMBER?

You may want to read Carl Sagan's book "Contact". Computing PI plays
an incredibly important, even religious, role in that book. (And it is
extremely well-written!)
-- 
Claus Tondering,         Dansk Data Elektronik A/S, Herlev, Denmark
E-mail: ct@dde.dk
------------------------------------------------------------------------------
1 ns < 2 cents < 10 V < 1 km < 100 degrees C < 20 mips < 4 MPa < 1,000,000,000

fox@allegra.att.com (David Fox) (04/05/91)

In article <1991Apr4.150053.29873@linus.mitre.org> bs@gauss.mitre.org (Robert D. Silverman) writes:

   I don't know about everyone else, but the attitude implied by this
   last sentence frightens me. No wonder today's undergraduates are
   ill-prepared. 

   The way to learn how to compute Pi is to study the math and the algorithms,
   not to look at someone else's code.

This is pure arrogance.  There is no "best" way to learn something,
whatever way works for a particular person is the "best" way.
Perhaps if we weren't so pedantic about how to learn things
we would graduate more people who are talented in unconventional
ways and fewer people who are mediocre in conventional ways.

-david

cet1@cl.cam.ac.uk (C.E. Thompson) (04/07/91)

In article <1991Apr5.064220.18509@dde.dk> ct@dde.dk (Claus Tondering) writes:
>bs@gauss.mitre.org (Robert D. Silverman) writes:
>
>>WHAT IS SO FUCKING SPECIAL ABOUT COMPUTING PI AS OPPOSED TO SOME OTHER NUMBER?
>
>You may want to read Carl Sagan's book "Contact". 

If Bob Silverman has avoided this so far, I advise him to keep it that way!
Bad for the blood pressure, especially for mathematicians.

>                                                  Computing PI plays 
>an incredibly important, even religious, role in that book.

It occurs at the end of the book, but I don't think it has `an incredibly
important role'. Anyway, the idea used is extremely jejune. 

>                                                            (And it is 
>extremely well-written!)

De gustibus non disputandum, but I could hardly agree less.

Chris Thompson
JANET:    cet1@uk.ac.cam.phx
Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk

herrickd@iccgcc.decnet.ab.com (04/12/91)

In article <1991Apr4.150053.29873@linus.mitre.org>, bs@gauss.mitre.org (Robert D. Silverman) writes:
> If one wants the program for the pleasure of computing something, that I
> can understand. But why something that's been done thousands of time???
> Why not something new?? How about a program to compute one of the less
> famous transcendental constants? 
> 
My continued fraction arithmetic rational arithmetic package 
included a general square root extracter.  I never did see a 
way to start computing the continued fraction for a specific
(that's exactly one) transcendental number.  Of course pi was
the one I was toying with (yes, this part of the activity was
pure dilletante).

How does one find the greatest integer in (q*pi - p) when the
point of the exercise is to compute pi, not know it?

Robert Silverman, you say try another transcendental constant.
Name one that you find interesting.  Change the continued
fraction question to that constant.  It is the continued fraction
expansion of a transcendental that interests me.  Not only pi.

dan herrick
herrickd@iccgcc.decnet.ab.com

weverka@spot.Colorado.EDU (Robert T. Weverka) (04/12/91)

In article <AVENGER.91Apr2185942@wpi.WPI.EDU> avenger@wpi.WPI.EDU (Samuel Joseph Pullara) writes:
>Could someone please send me a program that will calculate PI to any
>arbitrary number of digits?  Thanks in advance...
>
Since you didn`t specify language, how about Mathematica?
example program for calculating Pi to 1 billion digits (Note will run on any
machine which runs Mathematica, from the Mac to the Cray
____________________________
In[1]:= N[Pi,1000000000]

Out[1]= 3.1415926535897932384626433832795028841971693993751058209749445923078\

>    164062862089986280348253421170679821480865132823066470938446095505822317\

>    253594081284811174502841027019385211055596446229489549303819644288109756\

>    659334461284756482337867831652712019091456485669234603486104543266482133\

>    936072602491412737245870066063155881748815209209628292540917153643678925\

>    903600113305305488204665213841469519415116094330572703657595919530921861\

>    173819326117931051185480744623799627495673518857527248912279381830119491\

>    298336733624406566430860213949463952247371907021798609437027705392171762\

>    931767523846748184676694051320005681271452635608277857713427577896091736\

>    371787214684409012249534301465495853710507922796892589235420199561121290\

>    219608640344181598136297747713099605187072113499999983729780499510597317\

>    328160963185950244594553469083026425223082533446850352619311881710100031\
..........