Find Optimal Int Ratios to Approximate Pi

  • B
  • Thread starter Astronuc
  • Start date
  • Tags
    Pi
In summary, the conversation discusses various integer ratios that approximate pi and the process of finding the most efficient one with the smallest error. It also mentions the conflicting targets of minimal error and shortest length, making it difficult to find a single solution. The conversation also touches on the idea of using an algorithm to identify the best set of integers for a desired error margin. Finally, there is a mention of the various formulas and algorithms used to calculate pi.
  • #1
Astronuc
Staff Emeritus
Science Advisor
2023 Award
21,868
6,259
TL;DR 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
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).
When reading V50's post, I thought of 7/22 rather than 22/7.

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:
Mathematics news on Phys.org
  • #2
The best quotient is the one that takes the most digits. The shortest possible is ##3##. So we have two conflicting targets: minimal error and shortest length. To answer the question, we would need a combination of them to a single-valued function which we then can optimize. As long as we have both, I see no way to get to a result.

With respect to the many formulas to calculate ##\pi,## it might be more reasonable to ask for the fastest algorithm to achieve a given error margin or to ask for the shortest formula to describe an algorithm.
 
  • Like
Likes Janosh89, DaveE and FactChecker
  • #3
Astronuc said:
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

When reading V50's post, I thought of 7/22 rather than 22/7.

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.
Another good approximation is 312689/99532, which has an error of 3E-11, and you can continue indefinitely. Also, 3.1415926536 has even a smaller error...
You may want to look at the concept of continued fractions.
 
  • #4
IMO, the fraction approximation only has a benefit when it requires remembering fewer digits than simply memorizing the digits of pi to an equal accuracy. Very few meet that criteria. Even the benefit of 22/7 is debatable, since who does not already know 3.14?
 
  • Like
Likes Janosh89, DaveE and Vanadium 50
  • #5
A few points:

One is that @Astronuc has introduced the idea of a quality of approximation. I assert without proof that I would expect that on average adding a digit to the numerator improves the approximation by a factor of 10. 22/7 is off by a part in 2500, so I would expect a three digit denominator to be good to a part in 25,000. However, 355/113 is good to a part in 11 million - about 400 times better than expected.

It's a very good approximation indeed. To get a better approximation, you need to go to a 5-digit denominator: 103993/33102, although the best 5 digit approximation is 312689/99532.

Computers are so fast these days that if you want to know what the best approximation is with 6 digits in the denominator, one can brute-force test all million numbers. At this point, approximations lose their utility. Is it easier to memorize 4272943/1360120 than pi itself to 11 or 12 digits?

So, as far as useful approximations go, I think the case can be made for just two: 22/7 and 355/113.

PS My calculator tells me 4272943/1360120 is exactly equal to pi.
 
  • Like
Likes Astronuc
  • #6
Continued fractions give the "best" approximation in some sense - there won't be a better fraction (closer to pi) with a smaller denominator. The larger the next integer in the denominator of the continued fraction the better the approximation relative to the size of the denominator.

From Wikipedia:$$\pi=3+\textstyle \cfrac{1}{7+\textstyle \cfrac{1}{15+\textstyle \cfrac{1}{1+\textstyle \cfrac{1}{292+\textstyle \cfrac{1}{1+\textstyle \cfrac{1}{1+\textstyle \cfrac{1}{1+\ddots}}}}}}}$$

3+1/7 = 22/7, the next term is 333/106, and the following one is 355/113. The very large 292 that would enter the following term tells us that 355/113 is an unusually good approximation (and the next two will be quite poor again relative to their size).
 
  • Informative
  • Like
Likes FactChecker, berkeman, Astronuc and 1 other person
  • #8
mfb said:
3+1/7 = 22/7, the next term is 333/106, and the following one is 355/113. The very large 292 that would enter the following term tells us that 355/113 is an unusually good approximation (and the next two will be quite poor again relative to their size).
Yeah, I overlooked that section :rolleyes:
https://en.wikipedia.org/wiki/Pi#Approximate_value_and_digits
Fractions: Approximate fractions include (in order of increasing accuracy) 22/7, 333/106, 355/113, 52163/16604, 103993/33102, 104348/33215, and 245850922/78256779.
 

1. What is the purpose of finding optimal integer ratios to approximate Pi?

The purpose of finding optimal integer ratios to approximate Pi is to simplify and improve the accuracy of calculations involving Pi. By using integer ratios, we can avoid using irrational numbers and make calculations more manageable.

2. How do you find optimal integer ratios to approximate Pi?

There are various methods for finding optimal integer ratios to approximate Pi. One method is to use the continued fraction expansion of Pi, which involves repeatedly taking the reciprocal of the fractional part of Pi and converting it into a fraction. Another method is to use the Chudnovsky algorithm, which involves computing the sum of a series of terms using integer ratios.

3. What are the benefits of using optimal integer ratios to approximate Pi?

Using optimal integer ratios to approximate Pi has several benefits. It allows for more precise calculations compared to using decimal approximations of Pi. It also simplifies calculations, making them easier to perform and reducing the chances of errors. Additionally, it can help in reducing the computational load and time required for calculations.

4. Can optimal integer ratios accurately represent Pi?

No, optimal integer ratios cannot accurately represent Pi. Pi is an irrational number, meaning it cannot be expressed as a finite decimal or a ratio of integers. However, using optimal integer ratios can provide a close approximation of Pi and improve the accuracy of calculations involving Pi.

5. How can finding optimal integer ratios to approximate Pi be applied in real-world scenarios?

Finding optimal integer ratios to approximate Pi has various real-world applications. It is used in fields such as engineering, physics, and computer science to make precise calculations involving circles, spheres, and other circular shapes. It is also used in algorithms for digital signal processing and image compression. Additionally, it can be used in designing and constructing structures such as bridges and buildings that require precise measurements.

Similar threads

  • General Math
Replies
3
Views
888
Replies
5
Views
2K
  • General Math
Replies
4
Views
3K
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • General Math
Replies
2
Views
3K
  • Programming and Computer Science
Replies
4
Views
5K
  • Calculus and Beyond Homework Help
Replies
1
Views
13K
Replies
21
Views
3K
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top