# Questions about pi

**URL:** <https://boards.straightdope.com/t/questions-about-pi/662796>\
**Category:** Factual Questions\
**Created:** [July 6, 2013, 5:17pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796 "2013-07-06T17:17:43Z")\
**Posts on this page:** 13\
**Page:** 3

<div class="post-metadata">

**Author:** ![runningdude](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@runningdude](https://boards.straightdope.com/u/runningdude)\
**Post date:** [July 7, 2013, 5:23pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/41 "2013-07-07T17:23:43Z")

</div>

> [@standingwave](#):
>
> That’s about what I get. I suppose it depends on the current estimate for the size of the universe. From wiki I found:  
> Radius of the observable universe: 4.32×10^26 meters  
> Planck length: 1.62×10^−35 metres.  
> Radius of obv universe in planck lengths: 2.67×10^61.

“3.14” is enough to _accurately_ estimate the circumference of the universe based the distance you’ve given (your estimate has only 3 significant figures! ;)).

---

<div class="post-metadata">

**Author:** ![yabob](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yabob/32/2821_2.png) [@yabob](https://boards.straightdope.com/u/yabob)\
**Post date:** [July 7, 2013, 6:27pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/42 "2013-07-07T18:27:21Z")

</div>

> [@Dr.Strangelove](#):
>
> First, it’s easy to exclude lots of fractions as uninteresting, because there are fractions with smaller numbers but with a better approximation. Here’s a list of the first few:  
> [http://www.isi.edu/~johnh/BLOG/1999/0728\_RATIONAL\_PI/top\_approximations.txt](http://www.isi.edu/~johnh/BLOG/1999/0728_RATIONAL_PI/top_approximations.txt)
> 
> 22/7 and 355/113 are “extra special” in that the next larger numerators with a better approximation are quite a bit larger. For 22/7, the next better fraction is 179/57. For 355/113, it’s 52163/16604 (it jumps over two orders of magnitude!).
> 
> The next “extra special” fraction is 5419351/1725033.

BTW, a good way to obtain best rational approximations for real numbers is by use of [Continued fractions.](http://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations)

For instance a couple continued fraction expansions of pi with lengths 2 and 3 give you those first two approximations:

[3;7] = 22/7  
[3;7,16] = 355/113

I didn’t care to use enough significant digits of pi to calculate length 5 (If you calculate length 4 it comes out even at the 4th place and gives you [3;7,16] again).

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [July 7, 2013, 6:51pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/43 "2013-07-07T18:51:36Z")

</div>

> [@Frylock](#):
>
> **Indistinguishable** was _cooperating_ with you. He was working entirely within the spirit of what you were attempting.

> [@Frylock](#):
>
> There it is again! He literally _just told you_ the opposite of this! He said there _is_ an insight you’re on to!

> [@Frylock](#):
>
> I understand all that, but I believed what ought to be stressed to **deltasigma** was not just “you’re wrong,” but “you’re going in an interesting direction although the way you do it turns out not to work quite right. But still, we can try something like it, and yes, there are interesting things to say here.”
> 
> That’s what I think **Indistinguishable** was doing, and **deltasigma** ought to have taken this as a positive development.

Yup.

---

<div class="post-metadata">

**Author:** ![dougie\_monty](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@dougie\_monty](https://boards.straightdope.com/u/dougie_monty)\
**Post date:** [July 7, 2013, 7:08pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/44 "2013-07-07T19:08:13Z")

</div>

Donald Knuth, who more recently has written a serious set of computer manuals, devised the Potrzebie System of Weights and Measures for _MAD Magazine_ in the late 1950s. It includes this sentence (which looks like this, depending how you read it):  
“Halvah is a form of pie, 3.1416 and a specific heat.  
And it has a specific gravity of of .31416.” 😃

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [July 7, 2013, 7:18pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/45 "2013-07-07T19:18:38Z")

</div>

> [@yabob](#):
>
> BTW, a good way to obtain best rational approximations for real numbers is by use of [Continued fractions.](http://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations)

Yep, continued fractions are interesting. Pi’s first few terms are:  
3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, 3 …

Truncating anywhere gives you a good approximation. But the \*really \*good approximations come from truncating just before a very large term. That 292 is large, and so truncating to [3, 7, 15, 1], which reduces to [3, 7, 16], gives us the 355/113 fraction.

The next term over 10 (an arbitrary threshold I chose) shows that the next good truncation point is at 14, and so the reduced continued fraction becomes [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 4]. As it happens, that’s the same 5419351/1725033 fraction that I mentioned (and “discovered” by eyeballing the rate of denominator increase).

Next one after that is [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 3] = 21053343141/6701487259 (stops just before that 84; 22 good digits).

---

<div class="post-metadata">

**Author:** ![Learjeff](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Learjeff](https://boards.straightdope.com/u/Learjeff)\
**Post date:** [July 8, 2013, 5:11pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/46 "2013-07-08T17:11:14Z")

</div>

For engineering purposes, we use whatever precision is required by the application.

For most cases, we use a 24-bit significand (single precision) or 53-bit significand (double precision), without even thinking about it, since we rarely need more.

For special purpose applications where we have reason to suspect we might need more accuracy, we do an error analysis to show what the error term is based on the precision of various variables and constants, and choose the appropriate precision to provide the desired resulting precision, using partial differentials or other techniques. I learned how to do this in calc 3, but never applied it in the real world, being a software engineer rather than a _real_ engineer. 🙂

---

<div class="post-metadata">

**Author:** ![Napier](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@Napier](https://boards.straightdope.com/u/Napier)\
**Post date:** [July 8, 2013, 6:52pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/47 "2013-07-08T18:52:50Z")

</div>

Wouldn’t it be true that pi is not the ratio of circumference to diameter, but rather only an upper limit on that ratio, because of whatever mass is within the circle? There would be a different general relativistic effect on the diameter dimension as opposed to the circumference dimension. Given that pi is available to large numbers of digits from a great many sources, this distinction will often be the limiting one for accuracy if we define pi as circumference over diameter.

---

<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:** [July 8, 2013, 7:07pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/48 "2013-07-08T19:07:49Z")

</div>

> [@Napier](#):
>
> Wouldn’t it be true that pi is not the ratio of circumference to diameter, but rather only an upper limit on that ratio, because of whatever mass is within the circle? There would be a different general relativistic effect on the diameter dimension as opposed to the circumference dimension. Given that pi is available to large numbers of digits from a great many sources, this distinction will often be the limiting one for accuracy if we define pi as circumference over diameter.

I’m not buying this. By definition, the diameter distance is that between two opposing points on the circumference. You’re trying to make it an actual line through the center instead of a virtual one.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [July 8, 2013, 7:25pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/49 "2013-07-08T19:25:35Z")

</div>

I don’t know anything about physics, but it’s certainly true that curvature can lessen the ratio between “The arclength around the locus of points at a fixed straight-line distance from a center” (circumference of a circle) and “The straight-line distance between two opposite points on that locus” (diameter of that circle).

Consider the Earth, where lines of lattitude form circles with the North pole as their center, and twice the distance (along a line of longitude) from the North pole as their diameter. For lines of lattitude close to the North pole, we get ratios close to pi, but as we approach the Equator, we get ratios approaching 2. And then as we approach the South pole but continue to consider the North pole the center, the circumference-to-diameter ratio further approaches 0.

---

<div class="post-metadata">

**Author:** ![leahcim](https://avatars.discourse-cdn.com/v4/letter/l/b4bc9f/32.png) [@leahcim](https://boards.straightdope.com/u/leahcim)\
**Post date:** [July 8, 2013, 8:20pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/50 "2013-07-08T20:20:31Z")

</div>

> [@Napier](#):
>
> Wouldn’t it be true that pi is not the ratio of circumference to diameter, but rather only an upper limit on that ratio, because of whatever mass is within the circle? There would be a different general relativistic effect on the diameter dimension as opposed to the circumference dimension. Given that pi is available to large numbers of digits from a great many sources, this distinction will often be the limiting one for accuracy if we define pi as circumference over diameter.

[This](http://www.johnstonsarchive.net/relativity/stcurve.pdf) is the cite I usually toss out for this. Basically the author does some GR calculations to determine how far pi is “off” for circles around the Earth and the Sun due to relativistic effects.

For a circle around the Earth the paper gets that the diameter is 4.4mm larger than its circumference divided by pi, and for a circle around the Sun, the diameter is 4.1km larger than C/pi.

---

<div class="post-metadata">

**Author:** ![Quercus](https://avatars.discourse-cdn.com/v4/letter/q/7ab992/32.png) [@Quercus](https://boards.straightdope.com/u/Quercus)\
**Post date:** [July 8, 2013, 8:41pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/51 "2013-07-08T20:41:12Z")

</div>

> [@runningdude](#):
>
> “3.14” is enough to _accurately_ estimate the circumference of the universe based the distance you’ve given (your estimate has only 3 significant figures! ;)).

This is a pretty overlooked point. Your answer is only ever as accurate as the least accurate input to the calculation. So the answer to ‘how many digits of pi do you need’ is pretty much always 'one more significant digit than your least accurate measurement. If your software has pi defined to a bunch of digits, sure, why not use them, but they won’t make your answer any more accurate if you’ve only measured the radius of the circle to an accuracy of one part in fifty anyway. And since there are very very few real-world measurements accurate to much more than one part in a thousand or so, 3.1415 is plenty for nearly any calculation.

> [@Learjeff](#):
>
> For engineering purposes, we use whatever precision is required by the application.  
> For most cases, we use a 24-bit significand (single precision) or 53-bit significand (double precision), without even thinking about it, since we rarely need more.
> 
> For special purpose applications where we have reason to suspect we might need more accuracy, we do an error analysis to show what the error term is based on the precision of various variables and constants, and choose the appropriate precision to provide the desired resulting precision, using partial differentials or other techniques. I learned how to do this in calc 3, but never applied it in the real world, being a software engineer rather than a _real_ engineer. 🙂

So, I’m curious, have you ever had an application where you needed more than 53 bits of precision in anything, let alone pi?

> [@Napier](#):
>
> Wouldn’t it be true that pi is not the ratio of circumference to diameter, but rather only an upper limit on that ratio, because of whatever mass is within the circle? There would be a different general relativistic effect on the diameter dimension as opposed to the circumference dimension. Given that pi is available to large numbers of digits from a great many sources, this distinction will often be the limiting one for accuracy if we define pi as circumference over diameter.

Well, we define pi as circumference over diameter of a circle on a flat plane, which we can calculate to arbitrary precision. What’s inaccurate is saying that for a circle in warped space the ratio of the circumference and diameter is going to be exactly pi; depending on the geometry of the curvature, the ratio could be very different.

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [July 8, 2013, 9:01pm UTC](https://boards.straightdope.com/t/questions-about-pi/662796/52 "2013-07-08T21:01:44Z")

</div>

> [@Quercus](#):
>
> So, I’m curious, have you ever had an application where you needed more than 53 bits of precision in anything, let alone pi?

I once wrote a program that calculated pi to a few million digits, so yes, I needed the extra precision for that :).

There are problems where error can diverge exponentially. Just as a simple example, I had a problem where I wanted to repeatedly (trillions of times) rotate a 2D unit vector around an axis by a specific angle. Using sines/cosines was too expensive, so instead I precomputed a 2x2 matrix that I repeatedly multiplied by. But after many iterations the error diverges and you no longer have a unit vector.

My solution was to renormalize the vector every so often, but I can put that off longer the more precision bits I have. Even so, there’s no number of bits that would be sufficient to last even modest lengths of time without renormalization.

---

<div class="post-metadata">

**Author:** ![Napier](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@Napier](https://boards.straightdope.com/u/Napier)\
**Post date:** [July 9, 2013, 2:14am UTC](https://boards.straightdope.com/t/questions-about-pi/662796/53 "2013-07-09T02:14:42Z")

</div>

> [@Exapno\_Mapcase](#):
>
> I’m not buying this. By definition, the diameter distance is that between two opposing points on the circumference. You’re trying to make it an actual line through the center instead of a virtual one.

I don’t think I follow you. Space is space, right? There’s only one line between two diametrically opposed points on this circle.

[Previous page](https://boards.straightdope.com/t/questions-about-pi/662796.md?page=2)
