Occasionally, it is useful to have a rational approximation for Pi.
Some environments immediately come to mind:
Pedantry requires pointing out that floats use rational approximations of Pi as well; with the restriction that the denominator is a negative power of some radix--10 if you're a human, 2 if you're a computer....
[This may be true, but with a floating point package it's possible to just write 3.14159 as a constant. In the absence of floats, this is not possible and you must either divide or use scaled integers.]
Using the expression pi ~= a/b, here are some values for (a) and (b) that yield more-or-less usable values for Pi:
( a ) ( b ) ~pi value error (abs(pi - a/b))
The fraction 22/7 is probably the easiest to remember, but the most useful of these is arguably 355/113 since it is good to more than 5 places and requires only 3 digits for both (a) and (b), and is fairly easy to memorize. If you take the digits 113355, cut in the middle, and swap them, you have 355/113; an easy memory trick.
Did you use continued fractions to approximate the decimal value, or some other trick?
As much as I would like to take credit for this, no. This is compiled from data extracted from a number of sources, some of whom did indeed use continued fractions. -- GarryHamilton
Does the table have the property for that for every (A/B) listed, there is no closer approximation (A'/B') for which B' <= B?
Yes, that's why those selected values were chosen. There are intermediate values (like 25/8) that are "in the ball park" but for which a lower value of B' exists that produces a more accurate estimate of Pi.
25/8 is useful in that 8 is a power of two, so the result can be performed with bit-shifting. This is useful if you're working with a primitive microprocessor, where it's easier to shift bits than to divide integers. 101/32 and 201/64 get a little closer, and 201/64 only requires two shifts left and throwing away the least significant byte to perform the division. --NickBensema
See ContinuedFractions for a demonstration of a small piece of code that finds the "best" rational approximation to pi, e, sqrt(2), etc. -- DougMerritt
See also ValueOfPi