Fractional Approximation of π

Pizza illustrating fractional approximation of π
Revised: 2026-05-18
First published: 2012-02-05
Takayuki HOSODA

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.

Fractional Approximation of π (π ≈ 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628…)
Upper BoundNumerator aDenominator bError (a/b/ln(10)-1)
16-bit3551138.49136786583708625840e-8
5 decimal digits99733317463.81881198949430055092e-9
6 decimal digits8337192653812.77421939101155628946e-12
7 decimal digits541935117250337.04890217867358664916e-15
8 decimal digits85563208272356152.73804930887241960781e-16
9 decimal digits657408909209259755-5.44767386326588380711e-18
31-bit1068966896340262731-9.77236323203935200888e-19
32-bit36184586751151791169-1.65038166494360663281e-19
10 decimal digits61679504541963319607-2.42761825922838344760e-20
12 decimal digits210533431416701487259-8.32827592510769072009e-23
14 decimal digits89589377689372851718461558-2.45785970095542706416e-27
16 decimal digits61348995254170451952799169684491-1.54785025105017880241e-32
18 decimal digits4300109465910692431368767354671873402.75587618588738719392e-36
64-bit2646693125139304345842468587426513207-4.49046611523687068218e-39
127-bit60728338969805745700507212595448411044193304306656095265567072163765127149451.98652948184227162437e-76
128-bit25683992386148878260790279034883749767981754686931803956266412424933874257924-2.76396581129743574033e-78

Euler's Number e

I also generated fractional approximations for Euler's number e.

Fractional Approximation of e (e ≈ 2.71828182845904523536028747135266249775724709369995…
Upper BoundNumerator aDenominator bError (a/b/ln(10)-1)
8-bit193711.03119167375784216350e-5
15-bit2322585442.48206319277341287008e-9
16-bit49171180891.01774028148239222876e-10
6 decimal digits5668272085244.24477193524942965466e-12
7 decimal digits924269134001969.39365936708327277024e-14
8 decimal digits28245729103910232.26630045186603754982e-16
10 decimal digits848456353312129649-2.21730813031467866914e-19
12 decimal digits563501581931207300647064.28563301202314957246e-24
14 decimal digits46150226651233169777195903915.54377713289347224505e-29
16 decimal digits2124008553358849781379079653017-2.40820008083386219477e-32
18 decimal digits106246577894593683390859317022412418.91254046041767100087e-36
64-bit57394392148614177312111421691000680031-2.84379499543328650267e-39
128-bit3289996141675217800985917556406054000112103219420556805047490636736113723601-5.12409357801477027851e-77

And while at it, I also computed approximations for ln(10).

Fractional Approximation of ln(10) (ln(10) ≈ 2.30258509299404568401799145468436420760110148862877…)
Upper BoundNumerator aDenominator bError (a/b/ln(10)-1)
8-bit175762.01885930140768282573e-5
15-bit123815377-3.63694236969525253020e-9
16-bit534432321-1.57023376770388504366e-10
8 decimal digits112498394885743-6.88220614857135166216e-16
10 decimal digits17843263997749231092.95609872891646180027e-20
12 decimal digits8294500122923602255633539.64071099020018463581e-25
14 decimal digits5757941472027225006422084233-1.75732289543998383413e-28
17 decimal digits227480160645689987933785108886.20618869283960716155e-32
18 decimal digits6524159382300714512833406418790528282.48418613473633684568e-36
63-bit70131869857724609873045788408476679291-3.20170789425199490362e-38
64-bit994894496772745967243207719002431615739.83627881266804634475e-40
127-bit11391473435995927516300292143099268161049472540540005072595078612933407385387-7.595937959911257199419e-77
128-bit2393799934286313699844048120568983555031039614102240912879352225813255285945068.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.

1 gallon (Queen Anne's gallon) is defined as 231 cubic inches. Why is it such a curious number — the product of mutually prime numbers 3 ¡ß 7 ¡ß 11?

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 ;-)

Note:
*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.

See Also