PI calculated by hand. If this doesn't blow your mind nothing will.


 
Thread Tools Search this Thread
The Lounge What is on Your Mind? PI calculated by hand. If this doesn't blow your mind nothing will.
# 1  
Old 03-18-2018
PI calculated by hand. If this doesn't blow your mind nothing will.

This came to my attention very recently...
I have put it here as a fun item not related to UNIX in any way...

Chudnovsky algorithm - Wikipedia

WOW!
And a great, light hearted 16 minute video about it:

Calculating π by hand: the Chudnovsky algorithm - YouTube

Enjoy...

Last edited by wisecracker; 03-18-2018 at 03:57 PM.. Reason: No change except PT should read PI and I dunno how to edit it...
This User Gave Thanks to wisecracker For This Post:
# 2  
Old 03-18-2018
Fixed the title. Nice topic!
# 3  
Old 03-18-2018
I most like the d = −163 assumption - the rest is beyond me, I'm afraid.
# 4  
Old 03-19-2018
Hi...
(Apologies for any typos.)
I decided to try the Python code supplied in the wiki URL...
No alteration to the code, Python 2.7.10 - OSX default, and Python 3.5.2 on the same machine, both are old.
OSX 10.13.3, default bash terminal:
Code:
Last login: Mon Mar 19 13:26:13 on ttys000
AMIGA:amiga~> cd Desktop/Code/Python
AMIGA:amiga~/Desktop/Code/Python> python2.7 chudnovsky_pi.py
PI(maxK=70 iterations, gc().prec=1008, disp=80 digits) =
3.141592653589793238462643383279502884197169399375105820974944592307816406286208

For greater precision and more digits (takes a few extra seconds) - Try
Pi = PI(317,4501,4500)
Pi = PI(353,5022,5020)
AMIGA:amiga~/Desktop/Code/Python> python3.5 chudnovsky_pi.py
PI(maxK=70 iterations, gc().prec=1008, disp=80 digits) =
3.141592653589793238462643383279502884197169399375105820974944592307816406816734

For greater precision and more digits (takes a few extra seconds) - Try
Pi = PI(317,4501,4500)
Pi = PI(353,5022,5020)
AMIGA:amiga~/Desktop/Code/Python> _

Note the last 6 digits!
I have no idea why they should be different.
Is this a bug or just a limitation of version 2.7.x, assuming 3.5.x is correct?
Although I think Python 2.7.x is being dropped in 2020 so subtleties like this are being ignored?
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash script to get total size off of remainder calculated

I am working on a script to get the final total size and so far have the following and wondering if this can be improved. # Compare the desired size of each lvm to the standard size. If it is desired is larger than calculate the difference and keep that value as the amount to add to that LVM. ... (5 Replies)
Discussion started by: user3528
5 Replies

2. Shell Programming and Scripting

How to send mail at specific calculated time interval?

Hi All, I want to send an email if the time difference from previous mail sent is more than or equal to 30 mins. I have written below code and it's working fine. In this script I am storing previous mail sent time in txt file. Instead of storing in txt file how to store in a variable.... (8 Replies)
Discussion started by: nalu
8 Replies

3. What is on Your Mind?

Something in my mind - what's your opinion ?

Dear Forum staff / Advisors / members , I am having something in my mind, about Linux / Unix possible Interview questions collections, I guess if I post them here,which might be useful for our members and for students, and in meantime we can discuss also about those questions, what's your... (4 Replies)
Discussion started by: Akshay Hegde
4 Replies

4. Shell Programming and Scripting

Merge left hand strings mapping to different right hand strings

Hello, I am working on an Urdu to Hindi dictionary which has the following structure: a=b a=c n=d n=q and so on. i.e. Headword separated from gloss by a = I am giving below a live sample بتا=बता بتا=बित्ता بتا=बुत्ता بتان=बतान بتان=बितान بتانا=बिताना I need the following... (3 Replies)
Discussion started by: gimley
3 Replies

5. UNIX for Advanced & Expert Users

awk calculated with amazing result

I don't the following why ?:confused: $ awk 'BEGIN{printf "%.40f\n",(0.33*3)}' 0.9899999999999999911182158029987476766109 $ awk 'BEGIN{printf "%.4f\n",(0.33*3)}' 0.9900 (0 Replies)
Discussion started by: saloman
0 Replies

6. UNIX for Dummies Questions & Answers

awk calculated with amazing result

I don't the following why ?:confused: $ awk 'BEGIN{printf "%.40f\n",(0.33*3)}' 0.9899999999999999911182158029987476766109 $ awk 'BEGIN{printf "%.4f\n",(0.33*3)}' 0.9900 (0 Replies)
Discussion started by: saloman
0 Replies

7. Shell Programming and Scripting

adding calculated column

Hi, My text file looks like this... I am not sure if it is tab separated or space separated. SHANTNU 101 12:40:00 AM 04:53:00 AM 219:40:00 04:23:00 AM 10 12:01:00 AM 296:18 1:55 test 342 12:53:00 AM 01:09:00 PM 144:43:00 07:44:00 AM 47 12:05:00 AM... (7 Replies)
Discussion started by: shantanuo
7 Replies

8. UNIX for Dummies Questions & Answers

Create a calculated field from existing fields

I need to add an average field to a file. I can create it in an on-screen report and it does what I need using the awk command but I can't get it to create a new file with the additional field. Here's what I'm working with: file layout: id:lastname:firstname:grade1:grade2:grade3:grade4 I... (1 Reply)
Discussion started by: atchleykl
1 Replies
Login or Register to Ask a Question