Computing π

﻿
Computing π

Similarly, the more complex approximations of π given below involve repeated calculations of some sort, yielding closer and closer approximations with increasing numbers of calculations.

Continued fractions

Besides its simple continued fraction representation [3; 7, 15, 1, 292, 1, 1, …] , which displays no discernible pattern, "π" has many generalized continued fraction representations generated by a simple rule, including these two.

:$3+pi= \left\{6 + cfrac\left\{1^2\right\}\left\{6 + cfrac\left\{3^2\right\}\left\{6 + cfrac\left\{5^2\right\}\left\{6 + cfrac\left\{7^2\right\}\left\{ddots,\right\}!$

:$frac\left\{4\right\}\left\{pi\right\} = \left\{1 + cfrac\left\{1^2\right\}\left\{3 + cfrac\left\{2^2\right\}\left\{5 + cfrac\left\{3^2\right\}\left\{7 + cfrac\left\{4^2\right\}\left\{ddots\right\}!$

(Other representations are available at [http://functions.wolfram.com/Constants/Pi/10/ The Wolfram Functions Site] .)

Trigonometry

: $frac\left\{pi\right\}\left\{4\right\} = frac\left\{1\right\}\left\{1\right\} - frac\left\{1\right\}\left\{3\right\} + frac\left\{1\right\}\left\{5\right\} - frac\left\{1\right\}\left\{7\right\} + cdots + frac\left\{\left(-1\right)^n\right\}\left\{2n+1\right\} + cdots!$

is the power series for arctan(x) specialized to "x" = 1. It converges too slowly to be of practical interest. However, the power series converges much faster for smaller values of $x$, which leads to formulas where $pi$ arises as the sum of small angles with rational tangents, such as these two by John Machin:

: $frac\left\{pi\right\}\left\{4\right\} = arctanfrac\left\{1\right\}\left\{2\right\} + arctanfrac\left\{1\right\}\left\{3\right\}!$

: $frac\left\{pi\right\}\left\{4\right\} = 4 arctanfrac\left\{1\right\}\left\{5\right\} - arctanfrac\left\{1\right\}\left\{239\right\}!$

Formulas for "π" of this type are known as Machin-like formulae.

Observing an equilateral triangle and noting that

: $sinleft \left(frac\left\{pi\right\}\left\{6\right\} ight \right)=frac\left\{1\right\}\left\{2\right\}!$

yields

: $pi = 3 sum_\left\{n=0\right\}^infty \left\{2n choose n\right\} frac\left\{1\right\}\left\{\left(2n+1\right) 16^n\right\} = 3 + frac\left\{1\right\}\left\{8\right\} + frac\left\{9\right\}\left\{640\right\} + frac\left\{15\right\}\left\{7168\right\} + cdots!$

The Salamin–Brent algorithm

The Gauss–Legendre algorithm or Salamin–Brent algorithm was discovered independently by Richard Brent and Eugene Salamin in 1975. This can compute pi to N digits in time proportional to N log(N) log(log(N)), much faster than the trigonometric formulae.

Arctangent

Knowing that $arctan\left(1\right) cdot 4 = pi!$ the formula can be simplified to get:

: $cfrac \left\{pi\right\}\left\{2\right\} = sum_\left\{n=0\right\}^\left\{infty\right\} cfrac \left\{n!\right\}\left\{\left(2n + 1\right)!!\right\} = 1 + cfrac\left\{1\right\}\left\{3\right\} + cfrac\left\{1cdot2\right\}\left\{3cdot5\right\} + cfrac\left\{1cdot2cdot3\right\}\left\{3cdot5cdot7\right\}+cdots!$

See: Double Factorial

Digit extraction methods

BBP formula (base 16)

The Bailey–Borwein–Plouffe formula (BBP) for calculating pi was discovered in 1995 by Simon Plouffe. The formula computes pi in base 16 without needing to compute the previous digits (digit extraction). [MathWorld: BBP Formula http://mathworld.wolfram.com/BBPFormula.html]

: $pi=sum_\left\{n=0\right\}^infty left\left(frac\left\{4\right\}\left\{8n+1\right\}-frac\left\{2\right\}\left\{8n+4\right\}-frac\left\{1\right\}\left\{8n+5\right\}-frac\left\{1\right\}\left\{8n+6\right\} ight\right)left\left(frac\left\{1\right\}\left\{16\right\} ight\right)^n!$

Bellard's improvement (base 2)

An alternative formula for computing pi in base 2 was derived by Fabrice Bellard. This O("n"2) algorithm is an improvement of the O("n"3log("n")3) algorithm, and has been measured to make computing binary digits of pi 43% faster. [Bellard's Website: http://fabrice.bellard.free.fr/pi/pi_bin/pi_bin.html]

: $pi=frac\left\{1\right\}\left\{2^6\right\}sum_\left\{n=0\right\}^infty frac\left\{\left(-1\right)^n\right\}\left\{2^\left\{10n left \left(-frac\left\{2^5\right\}\left\{4n+1\right\}-frac\left\{1\right\}\left\{4n+3\right\}+frac\left\{2^8\right\}\left\{10n+1\right\}-frac\left\{2^6\right\}\left\{10n+3\right\}-frac\left\{2^2\right\}\left\{10n+5\right\}-frac\left\{2^2\right\}\left\{10n+7\right\}+frac\left\{1\right\}\left\{10n+9\right\} ight \right)!$

Extending to arbitrary bases

In 1996, Simon Plouffe derived an algorithm to extract the "n"th digit of pi in an arbitrary base in O("n"3log("n")3) time. [Simon Plouffe, "On the computation of the n'th decimal digit of various transcendental numbers", November 1996]

=Improvement using the Gosper formula=

In 1997, Fabrice Bellard improved Plouffe's formula for digit-extraction in an arbitrary base to reduce the runtime to O("n"2). [Bellard's Website: http://fabrice.bellard.free.fr/pi/pi_n2/pi_n2.html]

Efficient methods

In the early years of the computer, the first expansion of "π" to 100,000 decimal places was computed by Maryland mathematician Dr. Daniel Shanks and his team at the United States Naval Research Laboratory (N.R.L.) in 1961.

Daniel Shanks and his team used two different power series for calculating the digits of "π". For one it was known that any error would produce a value slightly high, and for the other, it was known that any error would produce a value slightly low. And hence, as long as the two series produced the same digits, there was a very high confidence that they were correct. The first 100,000 digits of "π" were published by the Naval Research Laboratory.

None of the formulæ given above can serve as an efficient way of approximating "π". For fast calculations, one may use a formula such as Machin's:

: $frac\left\{pi\right\}\left\{4\right\} = 4 arctanfrac\left\{1\right\}\left\{5\right\} - arctanfrac\left\{1\right\}\left\{239\right\}!$

together with the Taylor series expansion of the function arctan("x"). This formula is most easily verified using polar coordinates of complex numbers, starting with

:$\left(5+i\right)^4cdot\left(-239+i\right)=-114244-114244i.!$

Formulae of this kind are known as "Machin-like formulae".

Many other expressions for "π" were developed and published by Indian mathematician Srinivasa Ramanujan. He worked with mathematician Godfrey Harold Hardy in England for a number of years.

Extremely long decimal expansions of "π" are typically computed with the Gauss-Legendre algorithm and Borwein's algorithm; the Salamin-Brent algorithm which was invented in 1976 has also been used.

The first one million digits of "π" and 1/"π" are available from Project Gutenberg (see external links below).The record as of December 2002 by Yasumasa Kanada of Tokyo University stands at 1,241,100,000,000 digits, which were computed in September 2002 on a 64-node Hitachi supercomputer with 1 terabyte of main memory, which carries out 2 trillion operations per second, nearly twice as many as the computer used for the previous record (206 billion digits). The following Machin-like formulæ were used for this:

:$frac\left\{pi\right\}\left\{4\right\} = 12 arctanfrac\left\{1\right\}\left\{49\right\} + 32 arctanfrac\left\{1\right\}\left\{57\right\} - 5 arctanfrac\left\{1\right\}\left\{239\right\} + 12 arctanfrac\left\{1\right\}\left\{110443\right\}!$:K. Takano (1982).

: $frac\left\{pi\right\}\left\{4\right\} = 44 arctanfrac\left\{1\right\}\left\{57\right\} + 7 arctanfrac\left\{1\right\}\left\{239\right\} - 12 arctanfrac\left\{1\right\}\left\{682\right\} + 24 arctanfrac\left\{1\right\}\left\{12943\right\}!$:F. C. W. Störmer (1896).

These approximations have so many digits that they are no longer of any practical use, except for testing new supercomputers. (Normality of "π" will always depend on the infinite string of digits on the end, not on any finite computation.)

In 1997, David H. Bailey, Peter Borwein and Simon Plouffe published a paper (Bailey, 1997) on a new formula for "π" as an infinite series:

: $pi = sum_\left\{k = 0\right\}^\left\{infty\right\} frac\left\{1\right\}\left\{16^k\right\}left\left( frac\left\{4\right\}\left\{8k + 1\right\} - frac\left\{2\right\}\left\{8k + 4\right\} - frac\left\{1\right\}\left\{8k + 5\right\} - frac\left\{1\right\}\left\{8k + 6\right\} ight\right).!$

This formula permits one to fairly readily compute the "k"th binary or hexadecimal digit of "π", withouthaving to compute the preceding "k" − 1 digits. [http://www.nersc.gov/~dhbailey/ Bailey's website] contains the derivation as well as implementations in various programming languages. The PiHex project computed 64-bits around the quadrillionth bit of "π" (which turns out to be 0).

Fabrice Bellard claims to have beaten the efficiency record set by Bailey, Borwein, and Plouffe with his formula to calculate binary digits of "π" [http://fabrice.bellard.free.fr/pi/pi_bin/pi_bin.html] :

:$pi = frac\left\{1\right\}\left\{2^6\right\} sum_\left\{n=0\right\}^\left\{infty\right\} frac$(-1)}^n}{2^{10n left( - frac{2^5}{4n+1} - frac{1}{4n+3} + frac{2^8}{10n+1} - frac{2^6}{10n+3} - frac{2^2}{10n+5} - frac{2^2}{10n+7} + frac{1}{10n+9} ight)!

Other formulæ that have been used to compute estimates of "π" include:

:$frac\left\{pi\right\}\left\{2\right\}=sum_\left\{k=0\right\}^inftyfrac\left\{k!\right\}\left\{\left(2k+1\right)!!\right\}=1+frac\left\{1\right\}\left\{3\right\}left\left(1+frac\left\{2\right\}\left\{5\right\}left\left(1+frac\left\{3\right\}\left\{7\right\}left\left(1+frac\left\{4\right\}\left\{9\right\}\left(1+cdots\right) ight\right) ight\right) ight\right)!$:Newton.

:$frac\left\{1\right\}\left\{pi\right\} = frac\left\{2sqrt\left\{2\left\{9801\right\} sum^infty_\left\{k=0\right\} frac\left\{\left(4k\right)!\left(1103+26390k\right)\right\}\left\{\left(k!\right)^4 396^\left\{4k!$:Srinivasa Ramanujan.

This converges extraordinarily rapidly. Ramanujan's work is the basis for the fastest algorithms used, as of the turn of the millennium, to calculate "π".

:$frac\left\{1\right\}\left\{pi\right\} = 12 sum^infty_\left\{k=0\right\} frac\left\{\left(-1\right)^k \left(6k\right)! \left(13591409 + 545140134k\right)\right\}\left\{\left(3k\right)!\left(k!\right)^3 640320^\left\{3k + 3/2!$:David Chudnovsky and Gregory Chudnovsky.

Projects

Pi Hex

Pi Hex was a project to compute three specific binary bits of π using a distributed network of several hundred computers. In 2000, after two years, the project finished computing the five trillionth, the forty trillionth, and the quadrillionth bits. All three of them turned out to be 0.

Background pi

Inspired by Pi Hex and Project Pi, [http://sourceforge.net/projects/backpi Background Pi] seeks to compute decimal digits of pi sequentially. The project has computed over a hundred thousand digits using spare CPU cycles. Background Pi is oriented to be more for an average end user than for a power user by offering an unobtrusive user interface. Research is underway on the efficiency of converting computed hex digits to decimal as computing hex digits is faster than computing decimal. A new version is in development that would manage multiple computation projects in a friendlier interface than BOINC.

ee also

* History of numerical approximations of π
* List of formulae involving π
* Software for calculating π
* Area of a disk
* Liu Hui's π algorithm

References

General

* [http://mathworld.wolfram.com/PiFormulas.html Mathworld - Pi Formulas]

Computation

* [http://sourceforge.net/projects/projectpi/ Project Pi]

Distributed computation

* [http://sourceforge.net/projects/backpi Background Pi]

Wikimedia Foundation. 2010.

Look at other dictionaries:

• computing — com‧put‧ing [kəmˈpjuːtɪŋ] noun [uncountable] COMPUTING the activity of using a computer, or writing computer programs: • How are your computing skills? • She studied computing at college. • wireless mobile computing devices ˈgrid comˌputing …   Financial and business terms

• computing — computing; su·per·computing; …   English syllables

• computing — ► NOUN ▪ the use or operation of computers …   English terms dictionary

• Computing — For the formal concept of computation, see computation. For the magazine, see Computing (magazine). For the scientific journal, see Computing (journal). A difference engine: computing the solution to a polynomial function …   Wikipedia

• computing — noun 1. the procedure of calculating; determining something by mathematical or logical methods • Syn: ↑calculation, ↑computation • Derivationally related forms: ↑computational (for: ↑computation), ↑compute …   Useful english dictionary

• computing — noun COMPUTING + NOUN ▪ skills ▪ power ▪ a hand held device that has as much computing power as many desktop PCs PREPOSITION ▪ in computing …   Collocations dictionary

• computing — [[t]kəmpju͟ːtɪŋ[/t]] 1) N UNCOUNT Computing is the activity of using a computer and writing programs for it. Courses range from cookery to computing. 2) ADJ: ADJ n Computing means relating to computers and their use. Many graduates are employed… …   English dictionary

• computing — /keuhm pyooh ting/, n. 1. the use of a computer to process data or perform calculations. 2. the act of calculating or reckoning. [1640 50; COMPUTE + ING1] * * * (as used in expressions) Reduced Instruction Set Computing DNA computing quantum… …   Universalium

• computing — com|put|ing [kəmˈpju:tıŋ] n [U] the use of computers as a job, in a business etc ▪ Have you ever done any computing? ▪ computing facilities for language research …   Dictionary of contemporary English

• computing — /kəmˈpjutɪŋ/ (say kuhm pyoohting) noun 1. the science or study of the principles and uses of computers. 2. the field of computer technology: to have a job in computing. –adjective 3. relating to computers: computing skills …   Australian English dictionary