# What is the formula for "pi"?

**URL:** https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566
**Category:** Factual Questions
**Created:** [March 7, 2010, 12:10am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566 "2010-03-07T00:10:49Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Jinx](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@Jinx](https://boards.straightdope.com/u/Jinx)
#### Post date: [March 7, 2010, 12:10am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/1 "2010-03-07T00:10:49Z")

</div>

What formula or algorithm do they use to calcualte pi? And, how do they know that it is the correct formula to calculate that IS how many times the diameter of a given circle would wrap around its circumference? Maybe the model is wrong!

---

<div class="post-metadata">

### Author: ![KarlGauss](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/karlgauss/32/3713_2.png) [@KarlGauss](https://boards.straightdope.com/u/KarlGauss)
#### Post date: [March 7, 2010, 12:12am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/2 "2010-03-07T00:12:35Z")

</div>

I can’t answer any better than [this](http://en.wikipedia.org/wiki/Calculating_Pi) (re: how it’s calculated). In particular, look at [this section](http://en.wikipedia.org/wiki/Calculating_Pi#20th_century) in the article.

---

<div class="post-metadata">

### Author: ![beowulff](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/beowulff/32/542_2.png) [@beowulff](https://boards.straightdope.com/u/beowulff)
#### Post date: [March 7, 2010, 12:37am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/3 "2010-03-07T00:37:55Z")

</div>

A friend and I once wondered the same thing - so we decided to figure out how to do it without any help. The method we came up with is to approximate a circle with a polygon. Then you can calculate the circumference by multiplying the length of each side times the number of sides. You can then get arbitrarily close to pi by making the number of sides arbitrarily large. This method always overestimates the size of pi. If you do the same thing with an inscribed polygon, you can approach pi from the other side, which lets you converge on the actual value of pi faster.

---

<div class="post-metadata">

### Author: ![John\_Mace](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/john_mace/32/185_2.png) [@John\_Mace](https://boards.straightdope.com/u/John_Mace)
#### Post date: [March 7, 2010, 12:52am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/4 "2010-03-07T00:52:22Z")

</div>

> [@beowulff](#):
>
> A friend and I once wondered the same thing - so we decided to figure out how to do it without any help. The method we came up with is to approximate a circle with a polygon. Then you can calculate the circumference by multiplying the length of each side times the number of sides. You can then get arbitrarily close to pi by making the number of sides arbitrarily large. This method always overestimates the size of pi. If you do the same thing with an inscribed polygon, you can approach pi from the other side, which lets you converge on the actual value of pi faster.

Archimedes beat you to this by about 2,000 years, but that’s still worth a congrats!

---

<div class="post-metadata">

### Author: ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)
#### Post date: [March 7, 2010, 1:17am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/5 "2010-03-07T01:17:05Z")

</div>

> [@beowulff](#):
>
> A friend and I once wondered the same thing - so we decided to figure out how to do it without any help. The method we came up with is to approximate a circle with a polygon. Then you can calculate the circumference by multiplying the length of each side times the number of sides. You can then get arbitrarily close to pi by making the number of sides arbitrarily large. This method always overestimates the size of pi. If you do the same thing with an inscribed polygon, you can approach pi from the other side, which lets you converge on the actual value of pi faster.

That’s exactly how Archimedes did it. (You are probably not as smart as he is, though, because it took you like 2500 years more than him to figure it out.)

---

<div class="post-metadata">

### Author: ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)
#### Post date: [March 7, 2010, 1:21am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/6 "2010-03-07T01:21:18Z")

</div>

One way to calculate pi to an arbitrary precision is to calculate the following infinite series:

4 - ( 4/3 ) + ( 4/5 ) - ( 4/7 ) + ( 4/9 ) - ( 4/11 ) …

Keep going and you get closer and closer to pi. This method is not particularly efficient, and it doesn’t tell you how many digits are correct and where the incorrect digits begin. There are methods for calculating a given digit of pi, but I don’t know them.

---

<div class="post-metadata">

### Author: ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)
#### Post date: [March 7, 2010, 1:25am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/7 "2010-03-07T01:25:47Z")

</div>

More generally, since Pi is irrational no single operation can give it’s exact value. However there are proofs that certain infinite series have Pi as their limit, and by extension algorithms that involve iteration (taking the result you’ve reached so far and running it through the algorithm again) converge on Pi. How _useful_ a formula is for generating Pi is another matter: some are very inefficient, taking a huge number of steps before reaching even a rough approximation of Pi.

---

<div class="post-metadata">

### Author: ![Exapno\_Mapcase](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/exapno_mapcase/32/1051_2.png) [@Exapno\_Mapcase](https://boards.straightdope.com/u/Exapno_Mapcase)
#### Post date: [March 7, 2010, 1:29am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/8 "2010-03-07T01:29:04Z")

</div>

> [@Jinx](#):
>
> And, how do they know that it is the correct formula to calculate that IS how many times the diameter of a given circle would wrap around its circumference?

Maybe because if the formula weren’t correct, wheels wouldn’t be round. :smack:

---

<div class="post-metadata">

### Author: ![Covered\_In\_Bees](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@Covered\_In\_Bees](https://boards.straightdope.com/u/Covered_In_Bees)
#### Post date: [March 7, 2010, 1:33am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/9 "2010-03-07T01:33:22Z")

</div>

> [@friedo](#):
>
> That’s exactly how Archimedes did it. (You are probably not as smart as he is, though, because it took you like 2500 years more than him to figure it out.)

I hate it when I invent or discover something and it turns out someone invented/discovered it thousands of years before I did.

Lemme tell you about this named Prometheus…

---

<div class="post-metadata">

### Author: ![Polycarp](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Polycarp](https://boards.straightdope.com/u/Polycarp)
#### Post date: [March 7, 2010, 1:33am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/10 "2010-03-07T01:33:31Z")

</div>

Pi = _c/d_, where _c_ is the circumference of a circle of diameter _d_. Bettr than that by formula you cannot do, since it’s an irrational (“transcendental”) number.

For elegance, revise **friedo** ’s approximation to begin with 4\*\*/1\*\* - 4/3 + 4/5… Is there a logical reason why a sequence of adding and subtraacting 4 divided by consecutive odd digits approximates pi so closely?

---

<div class="post-metadata">

### Author: ![beowulff](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/beowulff/32/542_2.png) [@beowulff](https://boards.straightdope.com/u/beowulff)
#### Post date: [March 7, 2010, 1:45am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/11 "2010-03-07T01:45:38Z")

</div>

> [@friedo](#):
>
> That’s exactly how Archimedes did it. (You are probably not as smart as he is, though, because it took you like 2500 years more than him to figure it out.)

Yeah, well, he probably didn’t have a public school education, either. 😃

---

<div class="post-metadata">

### Author: ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)
#### Post date: [March 7, 2010, 1:47am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/12 "2010-03-07T01:47:43Z")

</div>

> [@Exapno\_Mapcase](#):
>
> Maybe because if the formula weren’t correct, wheels wouldn’t be round. :smack:

C’mon, it isn’t that dumb of a question. **Jinx** is essentially confused about how we can prove that a specific formula yields _pi_ if we are using it to compute digits of _pi_ we’ve never seen before.

---

<div class="post-metadata">

### Author: ![Exapno\_Mapcase](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/exapno_mapcase/32/1051_2.png) [@Exapno\_Mapcase](https://boards.straightdope.com/u/Exapno_Mapcase)
#### Post date: [March 7, 2010, 2:57am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/13 "2010-03-07T02:57:47Z")

</div>

> [@Derleth](#):
>
> C’mon, it isn’t that dumb of a question. **Jinx** is essentially confused about how we can prove that a specific formula yields _pi_ if we are using it to compute digits of _pi_ we’ve never seen before.

Whoosh.

---

<div class="post-metadata">

### Author: ![Cabbage](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@Cabbage](https://boards.straightdope.com/u/Cabbage)
#### Post date: [March 7, 2010, 2:58am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/14 "2010-03-07T02:58:02Z")

</div>

> [@Polycarp](#):
>
> Pi = _c/d_, where _c_ is the circumference of a circle of diameter _d_. Bettr than that by formula you cannot do, since it’s an irrational (“transcendental”) number.
> 
> For elegance, revise **friedo** ’s approximation to begin with 4\*\*/1\*\* - 4/3 + 4/5… Is there a logical reason why a sequence of adding and subtraacting 4 divided by consecutive odd digits approximates pi so closely?

Actually, “irrational” and “transcendental” are two different ideas (though the latter is a subset of the former). “Irrational” means the number can’t be written as a quotient of two integers, while “transcendental” means the number is not a zero of a polynomial with integer coefficients. For example, the square root of 2 is irrational, but not transcendental.

As for that specific series, the idea is this:

There’s a power series expansion for the function 1/(1-x):

1 / (1 - x) = 1+x+x^2+x^3+x^4+…

Now substitute x with -u^2:

1 / (1 + u^2) = 1 - u^2 + u^4 - u^6 + u^8 - u^10 + …

Now integrate both sides with respect to u. The left hand side is arctan(u). We’ll do the right hand side by the power rule:

arctan(u) = u - u^3/3 + u^5/5 - u^7/7 + …

Now set u=1. Plugging in gives:

pi/4 = 1 - 1/3 + 1/5 - 1/7 + …

Multiply by 4 and you’re done.

(Of course, this brushes over a few things such as questions of convergence and worrying about the constant of integration, but that’s the basic idea).

---

<div class="post-metadata">

### Author: ![aceplace57](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/aceplace57/32/3500_2.png) [@aceplace57](https://boards.straightdope.com/u/aceplace57)
#### Post date: [March 7, 2010, 4:00am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/15 "2010-03-07T04:00:02Z")

</div>

22/7 is a close approximation of the ratio of a circle’s circumference to its diameter.

It’s what I used in applied math for engineering and construction calculations.

it’s accurate to two decimal places (3.14).

---

<div class="post-metadata">

### Author: ![aceplace57](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/aceplace57/32/3500_2.png) [@aceplace57](https://boards.straightdope.com/u/aceplace57)
#### Post date: [March 7, 2010, 4:08am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/16 "2010-03-07T04:08:36Z")

</div>

This article is easy to read and informative.  
[http://www.mscf.uky.edu/~lee/ma502/pi/MA502piproject.html](http://www.mscf.uky.edu/~lee/ma502/pi/MA502piproject.html)

---

<div class="post-metadata">

### Author: ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)
#### Post date: [March 7, 2010, 4:17am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/17 "2010-03-07T04:17:19Z")

</div>

> [@aceplace57](#):
>
> 22/7 is a close approximation of the ratio of a circle’s circumference to its diameter.
> 
> It’s what I used in applied math for engineering and construction calculations.
> 
> it’s accurate to two decimal places (3.14).

I’ve never used that approximation because, quite without meaning to, I memorized it to five places (3.14159) at a young age and I’ve always been able to use that.

**Exapno Mapcase** , isn’t it usually considered good form to answer questions before getting into the stupid jokes?

---

<div class="post-metadata">

### Author: ![AWB](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@AWB](https://boards.straightdope.com/u/AWB)
#### Post date: [March 7, 2010, 4:18am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/18 "2010-03-07T04:18:10Z")

</div>

A quicker algorithm to find pi is the following:

Let x[sub]1[/sub]=2, or some other number close to pi. Set your calculator to radians mode.

Then let:

x[sub]2[/sub]=x[sub]1[/sub]-tan(x[sub]1[/sub])

x[sub]2[/sub] will be a closer approximation to pi than x[sub]1[/sub] was.

Then repeating that:

x[sub]n+1[/sub]=x[sub]n[/sub]-tan(x[sub]n[/sub])

will get you closer and closer to pi, very quickly.

If the number you start with is not pi/2 \<= x[sub]1[/sub] \<= 3pi/2, this process will converge to the nearest multiple of pi.

This is basically using Newton’s Method, which states: Given a function ƒ(x) and its derivative ƒ '(x), we begin with a first guess x[sub]1[/sub]. Provided the function is reasonably well-behaved, a better approximation than x[sub]1[/sub] is

x[sub]2[/sub]=x[sub]1[/sub]-ƒ(x[sub]1[/sub])/ƒ '(x[sub]1[/sub])

or more generally:

x[sub]n+1[/sub]=x[sub]n[/sub]-ƒ(x[sub]n[/sub])/ƒ '(x[sub]n[/sub])

This is repeated until a sufficiently accurate value is reached.

In my example, I’m basically finding a root of ƒ(x) = sin(x), which equals 0 at all integral multiples of pi. And since ƒ '(x)=cos(x), I replaced the ratio of sine and cosine with tan(x).

---

<div class="post-metadata">

### Author: ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)
#### Post date: [March 7, 2010, 4:23am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/19 "2010-03-07T04:23:32Z")

</div>

Surprisingly, there is also a formula that allows you to compute the _n_-th (base 16 or base 2) digit of _pi_ without having to compute any of the previous digits. It’s called the [BBP formula](http://mathworld.wolfram.com/BBPFormula.html) after its inventors, Bailey, Borwein, and Plouffe. [Here is a PDF that goes into some detail about this miraculous algorithm.](http://www.andrews.edu/~calkins/physics/Miracle.pdf)

---

<div class="post-metadata">

### Author: ![KarlGauss](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/karlgauss/32/3713_2.png) [@KarlGauss](https://boards.straightdope.com/u/KarlGauss)
#### Post date: [March 7, 2010, 4:27am UTC](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566/20 "2010-03-07T04:27:43Z")

</div>

> [@Jinx](#):
>
> What formula or algorithm do they use to calcualte pi? And, how do they know that it is the correct formula to calculate that IS how many times the diameter of a given circle would wrap around its circumference? Maybe the model is wrong!

Well, how about if you calculate pi empirically? You’d have to agree (I think) it would be pretty convincing if the value of pi emerged from an “experiment” (even if, as strongly suspected, Buffon cheated).

With that (hopefully) intriguing introduction, I strongly suggest you look [here](http://en.wikipedia.org/wiki/Buffon%27s_needle) and then [here](http://www.angelfire.com/wa/hurben/buff.html). For sure, don’t skip that second link and the applet demo therein at the bottom of the page. Definitely worth your time.

[Next page](https://boards.straightdope.com/t/what-is-the-formula-for-pi/531566.md?page=2)
