# Thread: Different ways of calculating pi

1. ## Different ways of calculating pi

Hi!

I would like to know some different ways of getting an approximation of pi. It can be everything from the simplest methods to the more complex ones where you can calculate thousands or maybe millions or billions of decimals in not too long time. So, maybe different persons can post different ways of calculating pi? I would like to have a formula where you can continue your calculations to get more decimals of pi, without having to do it all from the beginning because you started your calculations with too bad accuracy.

So, I can start with one that is probably one of the simplest possible:

Set $\displaystyle Z = 1$, and $\displaystyle h$ to be $\displaystyle \text{a very small number}$. Set $\displaystyle n = 0$.
While $\displaystyle imag(Z) > 0$ or $\displaystyle real(Z) > 0$, multiply $\displaystyle Z$ by $\displaystyle 1 + i \cdot h$ and add $\displaystyle 1$ to $\displaystyle n$.
Then multiply $\displaystyle n$ by $\displaystyle h$ to get an approximation of $\displaystyle \pi$. If you want to make it more exactly you can remove $\displaystyle imag(Z)/real(Z)$ from the aproximation.

The value $\displaystyle 1 + i \cdot h$ has the argument $\displaystyle h$, approximately, so everytime you multiply $\displaystyle Z$ by $\displaystyle 1 + i \cdot h$ you add almost $\displaystyle h$ to the argument of $\displaystyle Z$. When $\displaystyle imag(Z) \leq 0$ and $\displaystyle real(Z) < 0$, the argument of $\displaystyle Z$ is $\displaystyle \geq \pi$. Since $\displaystyle n$ keeps track of how many times you have multiplied $\displaystyle Z$, you can get the approximate argument of $\displaystyle Z$ by multiplying $\displaystyle n$ and $\displaystyle h$. And that little extra angle $\displaystyle Z$ has gone over the x-axis can be approximated by dividing $\displaystyle imag(Z)$ by $\displaystyle real(Z)$, since the angle is so small.

2. $\displaystyle \frac{\pi^2}{6}=1+\frac{1}{2^2}+\frac{1}{3^2}+...$
The limit of this series.

This is mine 34th Post!!!

3. Originally Posted by ThePerfectHacker
$\displaystyle \frac{\pi^2}{6}=1+\frac{1}{2^2}+\frac{1}{3^2}+...$
The limit of this series.

This is mine 34th Post!!!
How did you come up with that equation?

Oh, and then there is a similar one to that just I posted (but not as simple):

Set $\displaystyle x = -e$
While $\displaystyle imag(x) > h$ (where $\displaystyle h$ is a really smal number) or $\displaystyle real(x) < 0$, set $\displaystyle x = \sqrt{x}$.
Then set $\displaystyle x = x - 1$.
Calculate $\displaystyle \frac{imag(x)}{real(x)}$ to get $\displaystyle \pi$. If you want to make it more exactly, remove $\displaystyle \frac{imag(x)\ + \ \displaystyle{\frac{imag(x)^3}{real(x)^2}}}{2}\ =\ \frac{imag(x)\cdot(1 + \pi^2)}{2}$ from the result.

You can see it as if $\displaystyle x = e^{a\cdot (1\ +\ i\cdot\pi)}$. From the beginning $\displaystyle a = 1$. But for every time you set $\displaystyle x = \sqrt{x}$, $\displaystyle a$ is halved. When $\displaystyle a$ is small enough ($\displaystyle imag(x) \leq h$ and $\displaystyle real(x) \geq 0$), $\displaystyle x$ is almost 1, and the derivative of $\displaystyle x$ ...

I'm so tired I think I will continue later... (^O^)

4. Originally Posted by TriKri
How did you come up with that equation?
Euler gave an informal demonstration of this.
Also he was able to find a formula for all even ones,
$\displaystyle 1+\frac{1}{2^4}+\frac{1}{3^4}+...=\frac{\pi^4}{22}$
For 6,8,10,....

The standard why of showing this is through a Fourier series.

5. > The standard why of showing this is through a Fourier series.

Hm, wonder how you show it.

Anyway, I have read that there is some iterative formulas where you can start with a value of $\displaystyle \pi$ and iterate to get a succesive better value, no matter what value of $\displaystyle \pi$ you got currently. I have heard of formulas that doubles the number of decimals in each iteration. Does it sound familiar? Does anyone know of such a formula? Can someone derivate any of them?

6. Originally Posted by TriKri
> The standard why of showing this is through a Fourier series.

Hm, wonder how you show it.
The process is long but here is the idea.
The function $\displaystyle f(x)=x^2$ on $\displaystyle [-\pi,\pi]$ is turned into a periodic function of period $\displaystyle 2\pi$ that is, $\displaystyle f(x+2\pi)=f(x)$.
Now by the Fourier (Dirichlet) convergence theorem this function is almost everywhere continous thus it has a Fourier series. After you get that series some manipulations give you the elegant result.

Anyway, I have read that there is some iterative formulas where you can start with a value of $\displaystyle \pi$ and iterate to get a succesive better value, no matter what value of $\displaystyle \pi$ you got currently. I have heard of formulas that doubles the number of decimals in each iteration. Does it sound familiar? Does anyone know of such a formula? Can someone derivate any of them?
A useful way to compute values is through the Newton-Raphson method. Especially easy when we have polynomial functions. But the problem is that $\displaystyle \pi$ is transendental over $\displaystyle \mathbb{Q}$.
Those what you are saying might not be possible.
-----
Here is an infinite series developed by Ramanjuan.
It has a collasol rate of convergence,
$\displaystyle \frac{1}{\pi} = \frac{\sqrt{8}}{9801}\sum_{n=0}^{\infty} \frac{(4n)!}{(n!)^4} \cdot \frac{1103+26390n}{396^{4n}}$
It certainly is not the nicest looking formula.
But the the most effective.
If you have a computer language, program this and see the results.

7. Originally Posted by ThePerfectHacker
Here is an infinite series developed by Ramanjuan.
It has a collasol rate of convergence,
$\displaystyle \frac{1}{\pi} = \frac{\sqrt{8}}{9801}\sum_{n=0}^{\infty} \frac{(4n)!}{(n!)^4} \cdot \frac{1103+26390n}{396^{4n}}$
It certainly is not the nicest looking formula.
But the the most effective.
If you have a computer language, program this and see the results.
What amazes me is that I hear that the amount of accurate decimal places grows exponentially per term

8. Originally Posted by ThePerfectHacker
The process is long but here is the idea.
The function $\displaystyle f(x)=x^2$ on $\displaystyle [-\pi,\pi]$ is turned into a periodic function of period $\displaystyle 2\pi$ that is, $\displaystyle f(x+2\pi)=f(x)$.
Now by the Fourier (Dirichlet) convergence theorem this function is almost everywhere continous thus it has a Fourier series. After you get that series some manipulations give you the elegant result.

A useful way to compute values is through the Newton-Raphson method. Especially easy when we have polynomial functions. But the problem is that $\displaystyle \pi$ is transendental over $\displaystyle \mathbb{Q}$.
Those what you are saying might not be possible.
-----
Here is an infinite series developed by Ramanjuan.
It has a collasol rate of convergence,
$\displaystyle \frac{1}{\pi} = \frac{\sqrt{8}}{9801}\sum_{n=0}^{\infty} \frac{(4n)!}{(n!)^4} \cdot \frac{1103+26390n}{396^{4n}}$
It certainly is not the nicest looking formula.
But the the most effective.
If you have a computer language, program this and see the results.
Neato! Just the first term gives 6 decimal places. I'm impressed.

-Dan

9. Originally Posted by topsquark
Neato! Just the first term gives 6 decimal places. I'm impressed.

-Dan
Do not thank me, thank Ramanjuan.. His is one of the people from history I would like to meet.

10. Originally Posted by ThePerfectHacker
Here is an infinite series developed by Ramanjuan.
It has a collasol rate of convergence,
$\displaystyle \frac{1}{\pi} = \frac{\sqrt{8}}{9801}\sum_{n=0}^{\infty} \frac{(4n)!}{(n!)^4} \cdot \frac{1103+26390n}{396^{4n}}$
It certainly is not the nicest looking formula.
But the the most effective.
If you have a computer language, program this and see the results.
Wow, that must be some kind of super-duper formula! Exponentially growing number of correct decimals, that's something.

I have heard there was some guy in the 18:th or 19:th century or something like that who calculated over 700 decimals of pi by hand. Unfortunately for him and for everybody who used the more than 700 decimals daily, 20:th century computers has showed a misscalculation in his approximation after only (only? ) 200 decimals or so. Who was that man?

11. Originally Posted by TriKri
Wow, that must be some kind of super-duper formula! Exponentially growing number of correct decimals, that's something.

I have heard there was some guy in the 18:th or 19:th century or something like that who calculated over 700 decimals of pi by hand. Unfortunately for him and for everybody who used the more than 700 decimals daily, 20:th century computers has showed a misscalculation in his approximation after only (only? ) 200 decimals or so. Who was that man?
19th Century Vienesse mathemation used the classical arctangent formula and through and with aid of a calculating prodigy (Johann Martin Zacharais Dase) in those days those types of people were treated like computers, calculated 200 decimals places in less than 2 months.

12. From Science News 20th May 1995 (I remember reading this note in Nature at the time)
(By the way Bob Matthews is the guy who proved that in any universe with physical
constants compatible with intelligent (carbon based?) lifeforms, Buttered Toast like objects
falling from a worktop at a height suitable for such lifeforms would fall butter(-oid) side
down)

Spying pi in the sky

In the April 20 NATURE, Robert A.J. Matthews of the applied mathematics and computer science department at the University of Aston in Birmingham, England, describes how to use the distribution of bright stars across the night sky to deduce a surprisingly accurate value of pi, the ratio of the circumference of a circle to its diameter.

“My aim was to extract something mathematically interesting from something we’re all familiar with,” Matthews says.

This result follows from an application of certain theorems in number theory. These hold that, given any pair of whole numbers chosen from a large, random collection of numbers, the probability that the two numbers have no common factor other than 1 is 6/¹2 (about 0.61). For example, in a set of numbers including 8, 9, and 27, 9 and 27 have the common factor 3, whereas 8 and 27, as well as 8 and 9, have no common factor apart from 1. It’s possible to calculate the value of pi by determining what proportion of pairs of whole numbers selected from a large, random sample has no common factors.

As the source of random numbers for his “celestial” estimate of pi, Matthews used the angular separation between the positions of pairs of the 100 brightest stars. He checked a million pairs of these numbers for factors and obtained a value of 3.12772 for pi, which is within 0.5 percent of the actual value of 3.14159…. “The ancient Greeks used to believe that numbers lie at the root of all things,” Matthews notes. “I guess this result tends to support that idea.”

And here is the original:

Pi in the sky

Nature 374 681-682 1995

Over the years, people have pointed out that it's possible to get a pretty accurate value of the famous constant Pi ( = 3.14159....) from studying the dimensions of the Great Pyramid. Its base measures 230.35 metres, while its slanting face angle is 51.867 degrees, leading to an apex height of 146.71 metres, and thus a ratio of base to height of 1.5701, which is within 99.96 per cent of the true value of Pi/2. Some have even gone so far as to claim that this proves that aliens helped the great Egyptian engineer/architect Imhotep erect the pyramids. More likely, the presence of Pi in the design is really just a figment of the surveying techniques used, which may well have featured wheeled devices whose circumference is of course simply Pi times the wheel's diameter. In this paper, I show that it is possible to extract a similarly accurate value of Pi from a rather more "cosmic" source: the scattering of the brightest stars in the night sky.

Analytical number theory shows that if any two numbers are plucked at random from a large collection, the probability that two random numbers have no common factors apart from 1 is 6/(Pi)^2. Thus, by taking a large collection of random numbers and checking each pair for common factors, it is possible to estimate Pi. For a "cosmic" source of random numbers, I took the scattering of the 100 brightest stars in the night sky, worked out the angular separation of each star from every other star, and used this to create a collection of one million pairs of random numbers. By using the famous Euclidean algorithm for finding greatest common divisors, I then counted up the number of these pairs that had no common factor, and set the proportion equal to 6/(Pi)^2. The result leads to a value for Pi of 3.12772 - within 99.56 per cent of the true value. All of which shows, I guess, that whacky New Age ideas about mystical numbers and the cosmos aren't as whacky as they sound.

At the time this was published I was a bit perturbed by Bob's reuse of
the same stellar positions to generate a larger sample than possible if
each position is used once. However I simulated the procedure and it
IIRC did give better estimates than what I expected. Perhaps there is
a paper in justifying this reuse of points

RonL

Needles to say I like this approach as it is an example of what I call
Mad Science, which is also exemplified by Watson and Cricks work
on the structure of DNA.

me to science as a child, and is now under threat from what might
be called scientific political correctness, which holds that dull and boring
systematic carefully planned science (as exemplified by Jim Watson's
portrayal of Rosalind Franklin in the Double Helix) is correct science and
Mad Science is an aberration to be killed off.

13. Remembering Bob Matthews' method of estimating pi has reminded
me of the Buffon needle method. Reference can be found here

RonL

14. Originally Posted by CaptainBlack
Buffon needle method.
I have a question on this. When I first saw this I found it really interesting that $\displaystyle \pi$ appears in the probability (I believe that you have to think of the full area of the needle, which forms a circle, and hence $\displaystyle \pi$). But I was told it does not converge very fast. If randomly done on a computer it shall take a few thousand experiments to get a few decimal points. Your approach for calculating $\displaystyle \pi$ is more elegant but I win this competition because mine is more efficient.

15. That random number thing is interesting, cause I don't understand how $\displaystyle \pi$ can be in this kind of discrete probability, if I may say so. I guess that two randomly chosen positive numbers a and b both in the interval $\displaystyle [1, \infty)$ has this chance of not sharing any prime factor: $\displaystyle \prod_{p\text{ prime}} 1 - \frac{1}{p^2}$ because the chance is $\displaystyle \frac{1}{p}$ for a to be divisible by p and hence have prime factor p, and the same is for b. For both a and b to have prime factor p the chance is $\displaystyle \frac{1}{p^2}$. For a and b to not share prime factor p the chance is $\displaystyle 1 - \frac{1}{p^2}$. And for a and b to not share any of the primes as a prime factor the chance is $\displaystyle \prod_{p\text{ prime}} 1 - \frac{1}{p^2}$. Though I have no idea how to connect that formula with $\displaystyle \pi$.

Page 1 of 3 123 Last