# From what I understand, there s some sort of computer calculating pi

1. Oct 23, 2012

### LastTimelord

... and for a long time, I took this for granted, but now I'm starting to wonder how it is doing this. From my knowledge, the only way one could calculate pi is to measure the diameter and radius of a circle, and find the ratio, but to calculate an irrational decimal as thoroughly as we have would require an unrealistically accurate measurement. There may be some sort of equation that can be used to calculate pi, but I have no idea what it is.

So, how are mathematicians managing to calculate pi?

2. Oct 23, 2012

### Klungo

You mean arclength right?

Other ways to calculate pi is to use infinite series that we know converge to pi. One example, though not the best, is the arctan(1) series. Also called leibniz series.

Edit: You may understand this provided you have taken at least calculus 2 or learned it prior.

3. Oct 23, 2012

### LastTimelord

But from what I understand, pi is needed in order to calculate arctan... I may be wrong. I really don't know much about this.

4. Oct 23, 2012

### Vorde

Not quite.

There are lots of nice formulas for calculating pi, most of them fall under the category of infinite series, meaning there are ways to represent pi as the sum of an infinite amount of numbers (with each successive number being added becoming smaller so it approaches pi as the amount of numbers in the series you add up goes to infinity - something mathematicians call convergence).

This is one of many ways to calculate pi:
http://en.wikipedia.org/wiki/Leibniz_formula_for_π
(This is actually not a very efficient method, but it looks nice :)

All a computer does is, using formulas like these, add up millions and billions of fractions to get more and more accurate values.

5. Oct 23, 2012

### lurflurf

I like
$$\frac{1}{\pi}=\frac{2\sqrt{2}}{9801} \sum_{n=0}^\infty \frac{(4n)!}{(n!)^4} \cdot \frac{1103+26390n}{396^{4n}}$$

but there are many ways see
http://mathworld.wolfram.com/PiFormulas.html
http://www.numberworld.org/misc_runs/pi-5t/details.html
http://en.wikipedia.org/wiki/Pi
http://en.wikipedia.org/wiki/Machin-like_formula
http://mathworld.wolfram.com/Machin-LikeFormulas.html

for Arctan use a series for Arctan and
pi/4=Actan(1) along with a Machin-like formula such as
Arctan(1)=4Arctan(1/5)-Arctan(1/239)
to speed things up

6. Oct 23, 2012

### pwsnafu

Special mention goes to the BBP formula, which allows one to calculate the nth hexadecimal digit of ∏ without calculating the first (n-1)th digits.

7. Oct 23, 2012

### rcgldr

Note arctan(1) = π/4

another formula, note that dividing by (1/8)^2 can be done with a right shift of 6 bits:

arctan(1) = 6 arctan(1/8) + 2 arctan(1/57) + arctan(1/239)

a bunch of arctan formulas here:

http://www.jjj.de/arctan/arctanpage.html

Programs like pifast:

pifast.html

and the pi demo program for apfloat:

http://apfloat.org

use highly optimized extended precision math and normally use the Chudnovsky formula mentioned on the wiki page linked to above (other methods are offered as options). Since division is relatively slow. it's my understanding that the denominator is generated by multiplication into a huge number then only a single division is done, usually by inverting the denominator and multiplying.

All of this is way beyond anything practical in terms of physics, other than sub-sets of a large value for pi or e could be used for random numbers.

Last edited: Oct 23, 2012