

#Calculate pi program code#
From a computational point of view, using a scripting language like python for iterative algorithms doesn't make the least sense - your PC is going to be far more occupied by translating your python code to executable structures than it will be with executing the core algorithm.This is a bit hard to answer, but let's try nevertheless: And of course if we start with a number closer to the square root (such as a or b) then it will take fewer iterations to calculate the square root. I would like to know how efficient are the algorithms above, in \$\mathcal(n)\$ (n is the number of digits to calculate), and how efficient is my program? I prefer not to import modules, but use pure Python (either 2 or 3) without any import. I used Python and only integers (I didn't want to use floating point numbers), and used the Gauss–Legendre algorithm because it was the simplest to implement (I considered using the Borwein's algorithm, but I didn't want to calculate third roots of numbers, and the Chudnovsky algorithm seemed a little complicated, although maybe I'll give it a try). To save the console output to a text file, use the menu item Edit -> Save Console to File.I saw this question and answer about calculating pi on Stack Overflow, and I decided to write my own program for calculating pi. I can only vouch for the first thirty or so digits, personally. I used the Xmaxima console for this result: (%i1) bfloat(%pi),fpprec:1000
#Calculate pi program software#
This is an open source (GPL) software project, available from Sourceforge. The symbolic and numeric calculation package Maxima appears capable of doing this rather easily. Not having used any of these other utilities I am unable to comment on individual features.
#Calculate pi program windows#

Pagliaruloįreely distributable, email: AMD A4-3400 APU with Radeon(tm) HD Graphics detected I was able to generate the following output: QPI-QuickPi v4.0, (c) 2000-2005 S. It will optionally write this output to a text file.īy entering this command: qpi 1mi -fancy:100,100,1000000,no, pi.txt

QuickPI is a Windows only command line tool that will generate pi to arbitrary length up to 256 million decimal places.
