Approximations for \( \pi \)

I would like to know how are approximations for π \pi like 355113 \frac{355}{113} computed.I tried to find some by guess and check and I came up with 6588873695866720973036362107\frac{65888736958667}{20973036362107} ( Yeah,it's very hard to memorize) but it's only accurate to 15 decimal digits.My method was to choose a random number for the denominator and multiply it by the value of π \pi up to 20 digits to get the numerator.So,are there more efficient methods to compute approximations for π \pi ?Thanks for any answers in advance!

#Pi #Approximation

Note by Tan Li Xuan
7 years, 1 month ago

No vote yet
1 vote

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

Usually fractional approximations of irrational numbers(ee,(2)\sqrt(2)..) can be easily computed from their Continued Fraction representation.

For instance the constant e=[2;1,2,1,1,4,1,1,6,1,1,8,]e= [2;1,2,1,1,4,1,1,6,1,1,8,…](AO03417) as you can see, follows a simple pattern in its continued fraction representation. By using this pattern we can easily compute more and more accurate convergents of ee.

Unfortunately the continued fraction representation of π=[3;7,15,1,292,1,1,1,2,1,3,1,]\pi= [3;7,15,1,292,1,1,1,2,1,3,1,…](AO01203) contains seemingly random digits.

However it is possible to compute such convergents by first finding the decimal representation of π\pi and then approximate the decimal using the continued fraction method .

To demonstrate, π\pi to seven decimal places is:

π3.1415927\pi \approx 3.1415927 Taking the reciprocal of 0.14159270.1415927 π3+17.0625133 \pi \approx 3+ {1\over\displaystyle 7.0625133} And repeating this over and over we get.. π3+17+115+11+1293+110.320556\pi \approx 3+ {1\over \displaystyle 7 + {1\over \displaystyle 15 + {1\over \displaystyle 1 + {1\over \displaystyle 293 + {1\over \displaystyle 10.320556}}}}} and so on.. If we truncate the fraction at 1515 it gives the approximation π3+17+115+1=3+16113=355113\pi \approx 3+ {1\over \displaystyle 7 + {1\over \displaystyle 15 + 1}} = {3 + {16\over 113}} = {355\over 113}

Since python already implements the rational approximation algorithm in its fractions module , all we have to do is find a large string of π\pi(I used the ‎The Spigot Algorithm here) and use the .limit_denominator(x) method to find a rational approximation.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from fractions import *
from decimal import *
#Spigot implementation http://stackoverflow.com/questions/9004789/1000-digits-of-pi-in-python
def make_pi():
    q, r, t, k, m, x = 1, 0, 1, 1, 3, 3
    for j in range(1000):
        if 4 * q + r - t < m * t:
            yield m
            q, r, t, k, m, x = 10*q, 10*(r-m*t), t, k, (10*(3*q+r))//t - 10*m, x
        else:
            q, r, t, k, m, x = q*k, (2*q+r)*x, t*x, k+1, (q*(7*k+2)+r*x)//(t*x), x+2


digits = make_pi()
pi_list = []
my_array = []

for i in make_pi():
    my_array.append(str(i))

my_array = my_array[:1] + ['.'] + my_array[1:]
big_float = Decimal("".join(my_array))
print Fraction(big_float).limit_denominator(10**9)

The code prints out a reasonable approximation 2549491779811528438\frac{2549491779}{811528438}.

Thaddeus Abiy - 7 years, 1 month ago

Log in to reply

Thanks!

Tan Li Xuan - 7 years, 1 month ago

think of how it was invented.....

Max B - 7 years, 1 month ago

Log in to reply

pi?or the method?

Thaddeus Abiy - 7 years, 1 month ago
×

Problem Loading...

Note Loading...

Set Loading...