courtvorti.blogg.se

Calculate pi.
Calculate pi.









calculate pi.

The long double TypeĪll the calculations in this project will be carried out using the long double type.

Calculate pi. code#

If you want to do something rather more serious than playing with my code you can download the application called y-cruncher used to break the record here. In this project I will code a few of the simpler methods to give a decidedly non-rigorous introduction to what is actually a vast topic. Trillions of digits aren't therefore useful in their own right but the effort put in to their calculation no doubt benefits mathematics and computer science. You can calculate the circumference of the Universe to the accuracy of a hydrogen atom using just 40dp which is the number reached over three centuries ago! And you only need 62 digits to calculate the circumference to the Planck length, the smallest meaningful unit of length which you can think of as a quantum of space. There is plenty of information around regarding the number of digits of π which are actually necessary for practical purposes. These generally calculate all the digits up to a certain point but there are also a few so-called spigot algorithms which calculate a given digit without calculating all the preceding ones first. OK, that's a slight exaggeration but there are many ways of getting the job done, ranging from the ancient 22/7 to recently discovered fast but complex methods such as the Chudnovsky Algorithm. So far π has been calculated to 22,459,157,718,361 digits (nearly twenty two and a half trillion) which, by coincidence, is the number of different ways there are of calculating it. Therefore it cannot be calculated as such, just estimated to (in principle) any number of digits. Pi is an irrational number starting off 3.14159 and then carrying on for an infinite number of digits with no pattern which anybody has ever discovered. I started off calling this project "Calculating Pi" but soon realised that I needed to rename it "Estimating Pi".











Calculate pi.