Fractional Approximation of Irrational Numbers
π (Pi)
The value of π has been computed to enormous precision. The Kanada Laboratory at the University of Tokyo set a record of 206,158,430,000 decimal digits in 1999. Much earlier, however, the famous approximation 355/113 had already been obtained by the Chinese mathematician Zu Chongzhi during the Southern and Northern Dynasties period.
The simpler approximation 22/7 for π is also historically interesting, as it appears in the origin of the 231 cubic inch definition of the US gallon.
Since rational approximations are often convenient, I tried generating several higher precision approximations as well.
| Upper Bound | Numerator a | Denominator b | Error (a/b/ln(10)-1) |
|---|---|---|---|
| 16-bit | 355 | 113 | 8.49136786583708625840e-8 |
| 5 decimal digits | 99733 | 31746 | 3.81881198949430055092e-9 |
| 6 decimal digits | 833719 | 265381 | 2.77421939101155628946e-12 |
| 7 decimal digits | 5419351 | 1725033 | 7.04890217867358664916e-15 |
| 8 decimal digits | 85563208 | 27235615 | 2.73804930887241960781e-16 |
| 9 decimal digits | 657408909 | 209259755 | -5.44767386326588380711e-18 |
| 31-bit | 1068966896 | 340262731 | -9.77236323203935200888e-19 |
| 32-bit | 3618458675 | 1151791169 | -1.65038166494360663281e-19 |
| 10 decimal digits | 6167950454 | 1963319607 | -2.42761825922838344760e-20 |
| 12 decimal digits | 21053343141 | 6701487259 | -8.32827592510769072009e-23 |
| 14 decimal digits | 8958937768937 | 2851718461558 | -2.45785970095542706416e-27 |
| 16 decimal digits | 6134899525417045 | 1952799169684491 | -1.54785025105017880241e-32 |
| 18 decimal digits | 430010946591069243 | 136876735467187340 | 2.75587618588738719392e-36 |
| 64-bit | 2646693125139304345 | 842468587426513207 | -4.49046611523687068218e-39 |
| 127-bit | 60728338969805745700507212595448411044 | 19330430665609526556707216376512714945 | 1.98652948184227162437e-76 |
| 128-bit | 256839923861488782607902790348837497679 | 81754686931803956266412424933874257924 | -2.76396581129743574033e-78 |
Euler's Number e
I also generated fractional approximations for Euler's number e.
| Upper Bound | Numerator a | Denominator b | Error (a/b/ln(10)-1) |
|---|---|---|---|
| 8-bit | 193 | 71 | 1.03119167375784216350e-5 |
| 15-bit | 23225 | 8544 | 2.48206319277341287008e-9 |
| 16-bit | 49171 | 18089 | 1.01774028148239222876e-10 |
| 6 decimal digits | 566827 | 208524 | 4.24477193524942965466e-12 |
| 7 decimal digits | 9242691 | 3400196 | 9.39365936708327277024e-14 |
| 8 decimal digits | 28245729 | 10391023 | 2.26630045186603754982e-16 |
| 10 decimal digits | 848456353 | 312129649 | -2.21730813031467866914e-19 |
| 12 decimal digits | 563501581931 | 20730064706 | 4.28563301202314957246e-24 |
| 14 decimal digits | 46150226651233 | 16977719590391 | 5.54377713289347224505e-29 |
| 16 decimal digits | 2124008553358849 | 781379079653017 | -2.40820008083386219477e-32 |
| 18 decimal digits | 106246577894593683 | 39085931702241241 | 8.91254046041767100087e-36 |
| 64-bit | 5739439214861417731 | 2111421691000680031 | -2.84379499543328650267e-39 |
| 128-bit | 32899961416752178009859175564060540001 | 12103219420556805047490636736113723601 | -5.12409357801477027851e-77 |
And while at it, I also computed approximations for ln(10).
| Upper Bound | Numerator a | Denominator b | Error (a/b/ln(10)-1) |
|---|---|---|---|
| 8-bit | 175 | 76 | 2.01885930140768282573e-5 |
| 15-bit | 12381 | 5377 | -3.63694236969525253020e-9 |
| 16-bit | 53443 | 2321 | -1.57023376770388504366e-10 |
| 8 decimal digits | 11249839 | 4885743 | -6.88220614857135166216e-16 |
| 10 decimal digits | 1784326399 | 774923109 | 2.95609872891646180027e-20 |
| 12 decimal digits | 829450012292 | 360225563353 | 9.64071099020018463581e-25 |
| 14 decimal digits | 57579414720272 | 25006422084233 | -1.75732289543998383413e-28 |
| 17 decimal digits | 227480160645689 | 98793378510888 | 6.20618869283960716155e-32 |
| 18 decimal digits | 652415938230071451 | 283340641879052828 | 2.48418613473633684568e-36 |
| 63-bit | 7013186985772460987 | 3045788408476679291 | -3.20170789425199490362e-38 |
| 64-bit | 9948944967727459672 | 4320771900243161573 | 9.83627881266804634475e-40 |
| 127-bit | 113914734359959275163002921430992681610 | 49472540540005072595078612933407385387 | -7.595937959911257199419e-77 |
| 128-bit | 239379993428631369984404812056898355503 | 103961410224091287935222581325528594506 | 8.480564324700164171770e-78 |
Approximation Using Continued Fractions
Example of a fractional approximation program using calc and continued fractions:
/* fract - fractional approximation program
* Rev.1.05 (May 18 2026), (c) 2008, Takayuki HOSODA.
* SPDX-License-Identifier: BSD-3-Clause
* http://www.finetune.co.jp/~lyuka/
*/
config("display", 20)
config("mode", "real")
config("epsilon", 1e-50)
define fract(x, err)
{
local a, c, d, e, n, t;
local i, j;
local mat m[100];
c = a = abs(x);
printf("#fractional approximation for\n", a);
printf("#order\tcoefficients\tnumerator\tdenominator\terror\n");
i = 0;
e = 1;
do {
m[i] = floor(c);
if (m[i] != 0) {
n = 1;
d = 0;
for (j = i; j >= 0; j--){
t = n;
n = n * m[j] + d;
d = t;
}
e = abs(a * d / n - 1);
printf("%d\t%d\t%d\t%d\t%e\n", i, m[i], n, d, e);
}
c -= m[i];
if ((c == 0) || (e < err))
break;
c = 1 / c;
} while (++i < 100);
}
fract(pi(), 1e-20)
quit
Appendix — Wine and Fractional Approximation of π
One day I was talking with a friend living in California about Napa wines. Apparently, homemade wine is allowed there up to 200 gallons per year.
After looking into it, I found that one gallon had originally been defined as a cylinder of diameter 7 inches and height 6 inches, which was later replaced during Queen Anne's era using the approximation 22 / 7 for π.
The excess introduced by the approximation may as well be regarded as the angels' share*1 :-)
πr2 ≈ 22 / 7 × (7/2)2 × 6 = 231
Somehow, it feels like a pleasantly harmonious number.
And if one used cubes, the Chinese Remainder Theorem would allow every integer up to 231 to be represented by the remainders of each edge length. Though admittedly, liquids are difficult to stack...
After all, wine is eau de vie — the water of life. May happiness visit everyone ;-)
*1: The "Angels' share" here corresponds to approximately π×(3.5)2×6 - 231 ≈ 0.093 cubic inches, which would amount to roughly 24 drops.
*2: The Chinese Remainder Theorem is used in high precision arithmetic, including computations of π and error correction systems.