Twenty Two Sevenths
Jeffkillian.com initially started as a Geocities website when I was in 6th grade. Over the years, it has slowly evolved into a place where I can practice and become familiar with web development as it progresses. I started out coding with Microsoft Frontpage, then moved to Dreamweaver. Initially, there was very little coding, and it was all WYSIWYG. However, as I learned more, I could make it more interactive.


I incorporate drawings and blog posts to keep those that are interested updated. Through the evolution of the website, I was forced to learn HTML, PHP, CSS, XML, jQuery, javascript, and the handling of MySQL Databases. I've put online some code samples.
Twenty Two Sevenths

Upon making the April Fools Version of the site, I found this throwback website of animated gifs, which has a section called "Africa People." Way to stay classy.

I ran the 5k, and you can see the results here. It was really fun, and I'm looking forward to it next year. Tomorrow, I'm doing the Go St. Louis Half Marathon. I've never done one before, so that should be interesting.

So I've been teaching myself come C#. I was sitting in math class and pi was mentioned, and it got me wondering if there were better fractions to estimate pi.

So I wrote a program to figure it out. I wanted to know what fraction (integer/integer) closely estimates pi. As you increase (have more available) the integers in the fraction, we will be able to more closely estimate pi. At first, I just checked if any of the first 10 (meaning 1,2,3,...,7,8,9,10) were good matches. A match is defined to be a number n such that floor(pi*n)= a number, x, where x has d zeros immediately after the decimal point (e.g. n=36, pi*36 = x = 113.09, so d=1. We could then do 113.09/36, and obtain a rough estimate of pi =113/36~3.138.

The fraction estimating pi is x/n

I then did this for d=1,2,...,8, and for n=10,100,1000,..., 100000000

Decimal places (# of zeros after decimal)

1

2 3 4 5 6 7 8
       
Numbers checked (n)                  
10   0 0 0 0 0 0
100   10 0 0 0 0 0
1,000   89 8
10,000   883 88
100,000   8998 900 89 9 1
1,000,000   89990 8998 897 89 10
10,000,000   899976 89995 8990 897 91 8
100,000,000   Don't Care 89989 8999 898 92 7 1

For example, the highlighted square would show that there were 8 numbers in the 1-1000 range that, when you multiply any one of those numbers by pi, you get a number with exactly two zeros after the decimal. Similarly, there were 89 numbers in the 1-1000 range that, when you multiply those numbers by pi, you get a number with exactly one zero after the decimal. The fact that it is exact indicates that the columns are exclusive

Results
In the 1-100,000 range, there was only one number, n = "66,317", that satisfied d = 5 (aka pi*n equals a number with 5 zeros after the decimal). For this n, we get an estimation of pi is 208341/66317 = 3.141592653467436, which is better than the whole 22/7 crapstimation that most people use.

That's a pretty good estimation, but I figured I could do better. . The farthest I took it was the n=100,000,000 mark. At this point, the program significantly slows my computer, and takes a long time to compute. I skipped calculating the d=1 and 2 cases for this n, because it honestly isn't important. There are so many numbers satisfying this that it really slows the whole program down.

The interesting find was there was one number in the 100,000,000 range that was the best, and satisfied d=8. N = 78256779 gives an estimate of pi =

3.1415926535897931602832, which is significantly better than our previous estimate. 
Long story short, use 245850922/78256779, it's a better estimator.

Onward!
This was mostly just for me to practice my C# abilities, however, there is further work that could be done. I could run it for larger n (with n=1,000,000,000, there were no numbers that satisfied d=9). If I tried the next power of 10 higher, I get an error, for the maximum allowed value of an integer allowed in the program is 2,147,483,647<10,000,000,000 .

However, the more interesting area would be that I have only covered half of the possible options. I chose to only look at fractions that were slightly over pi. I could also search for fractions ending in .9, .99, .999,. etc. Maybe there is a better estimator in the 100,000,000 range doing that.


Write a comment...
Want more? Check the blog archives
Untitled Document