Wednesday, March 14, 2018

Egyptian estimates of PI

I saw a neat tweet on how the estimate the Egyptians used for PI.

This is all my speculation, and maybe a math history buff can enlighten me, but the D^2 dependence they should discover pretty naturally.   Including the constant before squaring is, I would argue, just as natural as having it outside the parentheses, so let's go with that for now.   So was there a nearby better fraction?   How well did the Egyptians do?   A brute force program should tell us.

We will use the ancient programming language C:

#include
#include
int main() {
    double min_error = 10;
    for (int denom = 1; denom < 10000; denom++) {
        for (int num = 1; num < denom; num++) {
            double approx = 2*double(num)/double(denom);
            approx = approx*approx;
            double error2 = M_PI-approx;
            error2 = error2*error2;
            if (error2 < min_error) {
                min_error = error2;
                printf("%d/%d %f\n", num, denom, 4*float(num*num)/float(denom*denom));
            }
        }
    }
}


This produces output:

1/2 1.000000
2/3 1.777778
3/4 2.250000
4/5 2.560000
5/6 2.777778
6/7 2.938776
7/8 3.062500
8/9 3.160494
23/26 3.130177
31/35 3.137959
39/44 3.142562
109/123 3.141252
148/167 3.141597
4401/4966 3.141588
4549/5133 3.141589
4697/5300 3.141589
4845/5467 3.141589
4993/5634 3.141589
5141/5801 3.141590
5289/5968 3.141590
5437/6135 3.141590
5585/6302 3.141590
5733/6469 3.141590
5881/6636 3.141591
6029/6803 3.141591
6177/6970 3.141591
6325/7137 3.141591
6473/7304 3.141591
6621/7471 3.141591
6769/7638 3.141591
6917/7805 3.141592
7065/7972 3.141592
7213/8139 3.141592
7361/8306 3.141592
7509/8473 3.141592
7657/8640 3.141592
7805/8807 3.141592
7953/8974 3.141593
8101/9141 3.141593
8249/9308 3.141593
8397/9475 3.141593
8545/9642 3.141593


So 7/8 was already pretty good, and you need to get to 23/26 before you do any better!   I'd say the Egyptians did extremely well.

What if they had put the constants outside the parens?   How well could they have done?   We can change two of the lines above to:

double approx = 4*double(num)/double(denom);//approx = approx*approx;

and the printf to:

printf("%d/%d %f\n", num, denom, 4*float(num)/float(denom));

And we get:

1/2 2.000000
2/3 2.666667
3/4 3.000000
4/5 3.200000
7/9 3.111111
11/14 3.142857
95/121 3.140496
106/135 3.140741
117/149 3.140940
128/163 3.141104
139/177 3.141243
150/191 3.141361
161/205 3.141464
172/219 3.141552
183/233 3.141631
355/452 3.141593


So 7/9 is not bad!  And 11/14 even better.   So no clear winner here on whether the rational constant should be inside the parens or not.


14 comments:

ChenA said...

If you interested, around 464 AD, Zu Chongzhi calculate the approximate value of pi to 355/133。

Rashmi Chaudhary said...

Good Post. Thank you sharing.
seo companies in faridabad
best seo company in faridabad

Jasmine Miller said...

Great article. thank you for post.
website design san jose

Nectar Phyto said...

"Really Good Useful & informative blog. Really like to read this blog.
great article.The blog was really nice, I really found out about a lot of Awesome content. you can check these blog to get different types of knowledge"
anybloginfo
anybloginfo
anyblognews
universitycolleague
Interviewgyan
bestsites
socialmediaupdates
makemoneyasfreelance

Avvy malhotra said...

check here new profile of escorts model
Escorts in lahore
Escort in lahore
Escort lahore
Escorts lahore
Lahore escorts
Lahore escort
Call girls lahore
Call girl lahore
Lahore Call girls
Lahore Call girl

Rashmi Chaudhary said...

How to Get More Likes on Your Facebook Page

Avvy malhotra said...

The era has been running and the acceleration is provided by the online services. Therefore the online might act as the catalyst to look for the top IAS institute in Delhi. The utility of online isfast and accurate.
Top IAS institute in Delhi
upsc coaching in Agra
UPSC coaching in Delhi

Goggly Life said...

Escorts Lahore


Call Girls Lahore


Sex in Lahore


Lahore Escorts


Escorts Lahore


Call girls Lahore


Lahore Call Girls


http://www.sexinlahore.com/

emikhan said...

Welcome to pinnacle Escorts organisation in Lahore Lahore is one of the fine cities in the global and it's miles the 2d largest town in Pakistan and as properly the Capital of Punjabi province. Lahore Escorts is the fifth biggest city in South Asia and 26th inside the global. Lahore is a favourite tourist destination because the tradition of Lahore Escorts constantly drawn to foreigners. Lahore is a most effective of Pakistan’s most interesting and unique towns and is second best to Karachi in length. The town is factually the primary town of Punjab and is regularly stated too Because of cultural hub of Pakistan, with fairly some thrilling fascinations to satisfaction the informal vacationer. people come to Lahore only for amusing and leisure and we're an escort based totally agency in Lahore.





http://www.lahorecallgirls.com/

emikhan said...

http://tinyurl.com/y4awap4s

http://tinyurl.com/y3vawluz

http://tinyurl.com/y6ozbuss

http://tinyurl.com/yxalap96

https://plus.google.com/110595496262817253280/posts/2BMAVAYbgXP

https://plus.google.com/110595496262817253280/posts/WrSCD8PLbAv

https://plus.google.com/u/0/110595496262817253280

http://bit.ly/2XNYl3V

http://bit.ly/2TyLIKK

emikhan said...

http://tinyurl.com/y4awap4s
http://tinyurl.com/y3vawluz
http://tinyurl.com/y6ozbusshttp://tinyurl.com/yxalap96
https://plus.google.com/110595496262817253280/posts/2BMAVAYbgXPhttps://plus.google.com/110595496262817253280/posts/WrSCD8PLbAvhttps://plus.google.com/u/0/110595496262817253280
http://bit.ly/2XNYl3V
http://bit.ly/2TyLIKK

Software Development said...

online software delhi
online web design delhi
best software agency
new software agency
best website
travel car
website software
software agency
Waiting Periods for Ford Endeavour, Toyota Fortuner

Software Development said...

Every developer should have a blog

Pakistan Escorts Services said...

In this escorts Provider agency, you will profit vip escorts in lahore. VIP Escorts is one of the most trusted escorts Provider Group and one of the biggest Escorts Agency in Lahore. Here are the valid Profiles of our Hottest and High-level Escorts in Lahore for our dexterously-ordered Customers. Our focus is to boost your relationship on the high level in imitation of our VIP Model Escorts in Lahore. In our Website, you can profit your hands approaching the order of the exact Profiles and recommend of our all Escorts in Lahore. All our New Hiring Lahore Escorts are regularly updating. There are countless Escorts in Lahore classified according to facilities. Here you can pick Lahore escorts for full Services of Escorts in Lahore. There are plus many adult models drama their facilities in our agency as Escorts in Lahore. Enjoy your time subsequent to ardent Escorts in Lahore according to your intent.

Indian Escorts in Malaysia

Indian Call Girls in Malaysia