- #1

Astronuc

Staff Emeritus

Science Advisor

- 19,798

- 3,247

- Summary:
- Integer ratio(s) approximating pi

On July 22, V50 wrote https://www.physicsforums.com/threads/happy-pi-day.985513/post-6518554,

and it got me thinking about the ratio of two integers approximating pi. I presume someone has done it, and that there is an algorithm for an optimal calculation.

Then I found - https://en.wikipedia.org/wiki/Approximations_of_π#Practical_approximations

7/22 = 0.3181818... but that's ~pi/10, but one can multiply by 10 and get 70/22, 3.181818... I didn't immediately realize that ratio is 35/11, which would have lead me to 355/113, which by the way gives me an error to pi of 2.6676418940E-07 (using Excel on a Mac). Nevertheless, 355/113 gives an efficient approximation with a very small error that 22/7

Anyway, I soon realized that I had started with 7/22 and not 22/7, the latter being the classic approximation with the smallest integers.

So, I started expanding the numerator and denominator.

22/7 = 220/70 = 3.142857

2200/701 = 3.13837375 (in wrong direction)

2203/701 = 3.14265335 overshoot

2202/701 = 3.14122682 undershoot

----------------------------------

a different path

22000 / 7001 = 3.142408 overshoot but less than 2203/701

22000 / 7002 = 3.141959 better

22000 / 7003 = 3.141511 better, but undershoot

22001 / 7003 = 3.141654

220010 / 70035 = 3.141429 scaling up

220010 / 70034 = 3.141474 moving in the right direction

220010 / 70033 = 3.14151900

220010 / 77032 = 3.141564 (pi = 3.14159265358979...)

Adjusting the numerator

220012 / 77032 = 3.1415924

2200121 / 700320 = 3.1415938

2200121 / 700321 = 3.1415894

22001212 / 7003200 = 3.1415941 (I didn't think to divided by 2, which would give me 11000606/3501600,

or by 4 giving 5500303 / 1750800

22001212 / 7003201 = 3.1415937

22001212 / 7003202 = 3.1415932

22001212 / 7003203 = 3.14159278

I started using Excel rather than my calculator

220012121 / 70032040 = 3.141592348302290

220012121 / 70032040 = 3.14159234830229 err -3.0528750194E-07

220012143 / 70032040 = 3.14159266244422 err 8.8544251931E-09

220012121 / 70032033 = 3.14159266231783 err 8.7280351835E-09

220012127 / 70032035 = 3.14159265827417 err 4.6843808832E-09

I tried a few more steps

2200121267 / 700320350 = 3.14159265399042 err 4.0062708706E-10

2200121270 / 700320351 = 3.14159265378824 err 1.9844437205E-10

2200121430 / 700320402 = 3.14159265347235 err -1.1744738515E-10

1100060715 / 350160201 divide by 2

366686905 / 116720067 divide previous line by 3, or the line before by 6. I realized this while creating this post. There were other opportunities to realize this earlier.

So I was wondering if there is a program or algorithm that has been developed to identify the best set of integers based on the desired error.

Or is 355⁄113 the best (most efficient, with a reasonably small error) and we're done.

and it got me thinking about the ratio of two integers approximating pi. I presume someone has done it, and that there is an algorithm for an optimal calculation.

Then I found - https://en.wikipedia.org/wiki/Approximations_of_π#Practical_approximations

When reading V50's post, I thought of 7/22 rather than 22/7.Depending on the purpose of a calculation, π can be approximated by using fractions for ease of calculation. The most notable such approximations are 22⁄7 (relative error of about 4·10^{−4}) and 355⁄113 (relative error of about 8·10^{−8}).

7/22 = 0.3181818... but that's ~pi/10, but one can multiply by 10 and get 70/22, 3.181818... I didn't immediately realize that ratio is 35/11, which would have lead me to 355/113, which by the way gives me an error to pi of 2.6676418940E-07 (using Excel on a Mac). Nevertheless, 355/113 gives an efficient approximation with a very small error that 22/7

Anyway, I soon realized that I had started with 7/22 and not 22/7, the latter being the classic approximation with the smallest integers.

So, I started expanding the numerator and denominator.

22/7 = 220/70 = 3.142857

2200/701 = 3.13837375 (in wrong direction)

2203/701 = 3.14265335 overshoot

2202/701 = 3.14122682 undershoot

----------------------------------

a different path

22000 / 7001 = 3.142408 overshoot but less than 2203/701

22000 / 7002 = 3.141959 better

22000 / 7003 = 3.141511 better, but undershoot

22001 / 7003 = 3.141654

220010 / 70035 = 3.141429 scaling up

220010 / 70034 = 3.141474 moving in the right direction

220010 / 70033 = 3.14151900

220010 / 77032 = 3.141564 (pi = 3.14159265358979...)

Adjusting the numerator

220012 / 77032 = 3.1415924

2200121 / 700320 = 3.1415938

2200121 / 700321 = 3.1415894

22001212 / 7003200 = 3.1415941 (I didn't think to divided by 2, which would give me 11000606/3501600,

or by 4 giving 5500303 / 1750800

22001212 / 7003201 = 3.1415937

22001212 / 7003202 = 3.1415932

22001212 / 7003203 = 3.14159278

I started using Excel rather than my calculator

220012121 / 70032040 = 3.141592348302290

220012121 / 70032040 = 3.14159234830229 err -3.0528750194E-07

220012143 / 70032040 = 3.14159266244422 err 8.8544251931E-09

220012121 / 70032033 = 3.14159266231783 err 8.7280351835E-09

220012127 / 70032035 = 3.14159265827417 err 4.6843808832E-09

I tried a few more steps

2200121267 / 700320350 = 3.14159265399042 err 4.0062708706E-10

2200121270 / 700320351 = 3.14159265378824 err 1.9844437205E-10

2200121430 / 700320402 = 3.14159265347235 err -1.1744738515E-10

1100060715 / 350160201 divide by 2

366686905 / 116720067 divide previous line by 3, or the line before by 6. I realized this while creating this post. There were other opportunities to realize this earlier.

So I was wondering if there is a program or algorithm that has been developed to identify the best set of integers based on the desired error.

Or is 355⁄113 the best (most efficient, with a reasonably small error) and we're done.

Last edited: