Waste less time on Facebook — follow Brilliant.
×

Approximations for \( \pi \)

I would like to know how are approximations for \( \pi \) like \[ \frac{355}{113} \] computed.I tried to find some by guess and check and I came up with \[\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!

Note by Tan Li Xuan
3 years, 8 months ago

No vote yet
1 vote

  Easy Math Editor

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 \times 3 \)
2^{34} \( 2^{34} \)
a_{i-1} \( a_{i-1} \)
\frac{2}{3} \( \frac{2}{3} \)
\sqrt{2} \( \sqrt{2} \)
\sum_{i=1}^3 \( \sum_{i=1}^3 \)
\sin \theta \( \sin \theta \)
\boxed{123} \( \boxed{123} \)

Comments

Sort by:

Top Newest

Usually fractional approximations of irrational numbers(\(e\),\(\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,…]\)(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 \(e\).

Unfortunately the continued fraction representation of \(\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:

\[\pi \approx 3.1415927\] Taking the reciprocal of \(0.1415927\) \[ \pi \approx 3+ {1\over\displaystyle 7.0625133}\] And repeating this over and over we get.. \[\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 \(15\) it gives the approximation \[\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 \(\frac{2549491779}{811528438}\).

Thaddeus Abiy - 3 years, 8 months ago

Log in to reply

Thanks!

Tan Li Xuan - 3 years, 8 months ago

Log in to reply

think of how it was invented.....

Max B - 3 years, 8 months ago

Log in to reply

pi?or the method?

Thaddeus Abiy - 3 years, 8 months ago

Log in to reply

×

Problem Loading...

Note Loading...

Set Loading...