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
COILY(1)						    Spring Python Documentation 						  COILY(1)

NAME
coily - command-line management tool for Spring Python SYNOPSIS
coily command DESCRIPTION
Coily is the command-line tool that utilizes the plugin system. It is similar to grails command-line tool, in that through a series of installed plugins, you are able to do many tasks, including build skeleton apps that you can later flesh out. If you look at the details of this app, you will find a sophisticated, command driven tool to built to manage plugins. The real power is in the plugins themselves. For information about Spring Python, it can be found at http://www.springpython.org/ OPTIONS
--help Displays a brief summary with all options. --list-installed-plugins List the plugins currently installed in this account. --list-available-plugins List the plugins available for installation. --install-plugin <name> Install the named plugin. --uninstall-plugin <name> Uninstall the named plugin by deleting its entry from ~/.springpython. --reinstall-plugin <name> Uninstall then install the plugin. SEE ALSO
The full documentation for coily and Spring Python is maintained as a HTML manual available at http://static.springsource.org/spring-python/1.2.x/sphinx/html/. AUTHOR
Greg Turnquist <gturnquist at vmware dotcom> COPYRIGHT
Apache Software License 1.2.0 2010-11-03 COILY(1)
All times are GMT -4. The time now is 09:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy