Sponsored Content
The Lounge What is on Your Mind? PI calculated by hand. If this doesn't blow your mind nothing will. Post 303014724 by wisecracker on Monday 19th of March 2018 02:09:47 PM
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?
 

8 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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
OCLOCK(1)						      General Commands Manual							 OCLOCK(1)

NAME
oclock - round X clock SYNOPSIS
oclock [-option ... ] DESCRIPTION
Oclock simply displays the current time on an analog display. OPTIONS
-fg color choose a different color for the both hands and the jewel of the clock -bg color choose a different color for the background. -jewel color choose a different color for the jewel on the clock. -minute color choose a different color for the minute hand of the clock. -hour color choose a different color for the hour hand of the clock. -backing { WhenMapped Always NotUseful } selects an appropriate level of backing store. -geometry geometry define the initial window geometry; see X(7). -display display specify the display to use; see X(7). -bd color choose a different color for the window border. -bw width choose a different width for the window border. As the Clock widget changes its border around quite a bit, this is most usefully set to zero. -shape causes the clock to use the Shape extension to create an oval window. This is the default unless the shapeWindow resource is set to false. -noshape causes the clock to not reshape itself and ancestors to exactly fit the outline of the clock. -transparent causes the clock to consist only of the jewel, the hands, and the border. COLORS
If you would like your clock to be viewable in color, include the following in the #ifdef COLOR section you read with xrdb: *customization: -color This will cause oclock to pick up the colors in the app-defaults color customization file: /usr/lib/X11/app-defaults/Clock-color. Below are the default colors: Clock*Background: grey Clock*BorderColor: light blue Clock*hour: yellow Clock*jewel: yellow Clock*minute: yellow SEE ALSO
X(7), X Toolkit documentation AUTHOR
Keith Packard, MIT X Consortium X Version 11 oclock 1.0.3 OCLOCK(1)
All times are GMT -4. The time now is 12:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy