Re: Calculating Pi [message #53246] |
Mon, 02 April 2007 01:09  |
Paolo Grigis
Messages: 171 Registered: December 2003
|
Senior Member |
|
|
The problem here is not one of method for computing Pi
(as remarked, plenty are available), but rather the lack
of an arbitrary precision library in IDL... (or has
anybody already written one?)
Ciao,
Paolo
Jean H. wrote:
> Hi,
>
> interesting question indeed....
> My friend google found the following.
> The first method is easy to implement, does not require paper, scissors
> nor kids throwing rocks ....
>
> Jean
>
> [...]
|
|
|
Re: Calculating Pi [message #53250 is a reply to message #53246] |
Sun, 01 April 2007 11:22   |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
Hi,
interesting question indeed....
My friend google found the following.
The first method is easy to implement, does not require paper, scissors
nor kids throwing rocks ....
Jean
http://www.faqs.org/faqs/sci-math-faq/specialnumbers/compute Pi/
Newsgroups: sci.math
From: alopez-o@neumann.uwaterloo.ca (Alex Lopez-Ortiz)
Subject: sci.math FAQ: How to compute Pi?
Summary: Part 12 of many, New version,
Message-ID: <DhahaI76KE.HAv@undergrad.math.uwaterloo.ca>
Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
Date: Fri, 17 Nov 1995 17:14:38 GMT
Reply-To: sci.math@news.news.demon.net
Archive-Name: sci-math-faq/specialnumbers/computePi
Last-modified: December 8, 1994
Version: 6.2
How to compute digits of pi ?
Symbolic Computation software such as Maple or Mathematica can compute
10,000 digits of pi in a blink, and another 20,000-1,000,000 digits
overnight (range depends on hardware platform).
It is possible to retrieve 1.25+ million digits of pi via anonymous
ftp from the site wuarchive.wustl.edu, in the files pi.doc.Z and
pi.dat.Z which reside in subdirectory doc/misc/pi. New York's
Chudnovsky brothers have computed 2 billion digits of pi on a homebrew
computer.
There are essentially 3 different methods to calculate pi to many
decimals.
1. One of the oldest is to use the power series expansion of atan(x)
= x - x^3/3 + x^5/5 - ... together with formulas like pi =
16*atan(1/5) - 4*atan(1/239) . This gives about 1.4 decimals per
term.
2. A second is to use formulas coming from Arithmetic-Geometric mean
computations. A beautiful compendium of such formulas is given in
the book pi and the AGM, (see references). They have the advantage
of converging quadratically, i.e. you double the number of
decimals per iteration. For instance, to obtain 1 000 000
decimals, around 20 iterations are sufficient. The disadvantage is
that you need FFT type multiplication to get a reasonable speed,
and this is not so easy to program.
3. The third, and perhaps the most elegant in its simplicity, arises
from the construction of a large circle with known radius. The
length of the circumference is then divided by twice the radius
and pi is evaluated to the required accuracy. The most ambitious
use of this method was successfully completed in 1993, when
H. G. Smythe produced 1.6 million decimals using high-precision
measuring equipment and a circle with a radius of a staggering
nine hundred and fifty miles.
References
P. B. Borwein, and D. H. Bailey. Ramanujan, Modular Equations, and
Approximations to pi American Mathematical Monthly, vol. 96, no. 3
(March 1989), p. 201-220.
J.M. Borwein and P.B. Borwein. The arithmetic-geometric mean and fast
computation of elementary functions. SIAM Review, Vol. 26, 1984, pp.
351-366.
J.M. Borwein and P.B. Borwein. More quadratically converging
algorithms for pi . Mathematics of Computation, Vol. 46, 1986, pp.
247-253.
Shlomo Breuer and Gideon Zwas Mathematical-educational aspects of the
computation of pi Int. J. Math. Educ. Sci. Technol., Vol. 15, No. 2,
1984, pp. 231-244.
David Chudnovsky and Gregory Chudnovsky. The computation of classical
constants. Columbia University, Proc. Natl. Acad. Sci. USA, Vol. 86,
1989.
Y. Kanada and Y. Tamura. Calculation of pi to 10,013,395 decimal
places based on the Gauss-Legendre algorithm and Gauss arctangent
relation. Computer Centre, University of Tokyo, 1983.
Morris Newman and Daniel Shanks. On a sequence arising in series for
pi . Mathematics of computation, Vol. 42, No. 165, Jan 1984, pp.
199-217.
E. Salamin. Computation of pi using arithmetic-geometric mean.
Mathematics of Computation, Vol. 30, 1976, pp. 565-570
David Singmaster. The legal values of pi . The Mathematical
Intelligencer, Vol. 7, No. 2, 1985.
Stan Wagon. Is pi normal? The Mathematical Intelligencer, Vol. 7, No.
3, 1985.
A history of pi . P. Beckman. Golem Press, CO, 1971 (fourth edition
1977)
pi and the AGM - a study in analytic number theory and computational
complexity. J.M. Borwein and P.B. Borwein. Wiley, New York, 1987.
____________________________________________________________ _____
alopez-o@barrow.uwaterloo.ca
Tue Apr 04 17:26:57 EDT 1995
|
|
|
Re: Calculating Pi [message #53252 is a reply to message #53250] |
Sun, 01 April 2007 10:18   |
lasse
Messages: 48 Registered: February 2007
|
Member |
|
|
On 1 Apr, 18:07, "Braedley" <mike.braed...@gmail.com> wrote:
> Does anyone have code that can calculate pi to an arbitrary
> precision? This is purely an academic endeavour.
>
> Actually that's a lie. This is just so that I can show others up.
Hi,
I remembered that there was a Monte Carlo mehtod to do this and the
following came up after a quick search. This is probably not very
efficient, but very instructive, since you can actually paint the
circle and the square on piece of paper and have your kids throw
stones at it... anyway, here we go:
If a circle of radius R is inscribed inside a square with side length
2R, then the area of the circle will be pi*R^2 and the area of the
square will be (2R)^2. So the ratio of the area of the circle to the
area of the square will be pi/4.
This means that, if you pick N points at random inside the square,
approximately N*pi/4 of those points should fall inside the circle.
This program picks points at random inside the square. It then checks
to see if the point is inside the circle (it knows it's inside the
circle if x^2 + y^2 < R^2, where x and y are the coordinates of the
point and R is the radius of the circle). The program keeps track of
how many points it's picked so far (N) and how many of those points
fell inside the circle (M).
Pi is then approximated as follows:
4*M
pi = ---
N
Although the Monte Carlo Method is often useful for solving problems
in physics and mathematics which cannot be solved by analytical means,
it is a rather slow method of calculating pi. To calculate each
significant digit there will have to be about 10 times as many trials
as to calculate the preceding significant digit.
cheers
lasse
|
|
|
Re: Calculating Pi [message #53337 is a reply to message #53246] |
Mon, 02 April 2007 14:41  |
jschwab@gmail.com
Messages: 30 Registered: December 2006
|
Member |
|
|
On Apr 2, 4:09 am, Paolo Grigis <pgri...@astro.phys.ethz.ch> wrote:
> The problem here is not one of method for computing Pi
> (as remarked, plenty are available), but rather the lack
> of an arbitrary precision library in IDL... (or has
> anybody already written one?)
>
> Ciao,
> Paolo
There are a class of formulas called Bailey-Borwein-Plouffe (BBP) that
let you find the nth digit, without having found the preceding ones.
If you head to your library or Google around, I'm sure you can find
out enough to show off to your heart's content. With double precision,
I think that should let you get the first 10^7 digits or so.
I Googled and found code examples here
http://crd.lbl.gov/~dhbailey/expmath/bbp-codes/
Cheers,
Josiah
|
|
|
Re: Calculating Pi [message #53338 is a reply to message #53246] |
Mon, 02 April 2007 14:41  |
jschwab@gmail.com
Messages: 30 Registered: December 2006
|
Member |
|
|
On Apr 2, 4:09 am, Paolo Grigis <pgri...@astro.phys.ethz.ch> wrote:
> The problem here is not one of method for computing Pi
> (as remarked, plenty are available), but rather the lack
> of an arbitrary precision library in IDL... (or has
> anybody already written one?)
>
> Ciao,
> Paolo
There are a class of formulas called Bailey-Borwein-Plouffe (BBP) that
let you find the nth digit, without having found the preceding ones.
If you head to your library or Google around, I'm sure you can find
out enough to show off to your heart's content. With double precision,
I think that should let you get the first 10^7 digits or so.
I Googled and found code examples here
http://crd.lbl.gov/~dhbailey/expmath/bbp-codes/
Cheers,
Josiah
|
|
|