• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Inefficient Ways to Calculate Pi

boooeee

Dart Fener
Joined
Aug 14, 2002
Messages
2,671
1. For each positive integer, calculate the number of ways it can be expressed as the sum of the square of any two integers. Denote the number of ways for a given number n to be P(n). You can use positive or negative integers in the sum. And, the order of the sum matters. In other words, 1^2 + 2^ 2 and 2^2 + 1^2 should be counted as two ways of expressing 5. Here are the first few examples:

1 = 1^2 + 0^2
1 = 0^2 + 1^2
1 = (-1)^2 + 0^2
1 = 0^2 + (-1)^2
2 = 1^2 + 1^2
2 = (-1)^2 + 1^2
2 = 1^2 + (-1)^2
2 = (-1)^2 + (-1)^2
There are no ways of expressing 3 as the sum of two squared integers.

So, P(1) = 4, P(2) = 4, and P(3) = 0. Continue this process for each number and calculate the average of P(n). For example, the average for the first three numbers is ( 4 + 4 + 0 ) / 3 = 2.666666….

As you add more and more numbers to your list, this average approaches Pi. In other words ( P(1) + P(2) + …. + P(N))/N approaches Pi as N approaches infinity.

2. Select two positive integers at random. If the two integers contain a common divisor, assign a value of 0 to this trial. If they do not contain a common divisor, assign a value of 1 to this trial. Repeat this process multiple times for new pairs of randomly selected positive integers. After N trials, add up the number of trials in which the two random numbers did not have a common divisor. Call this number m. Divide N by m. Multiply N/m by 6 and take the square root. As N approaches infinity, this number, (6N/m)^(1/2), approaches Pi. Another way of saying this is that the chances of any two random integers not containing a common divisor is 6/(Pi^2)

Who knows other horribly inefficient ways of approximating Pi?
 
Paint a square on the floor. Construct a circle in tangent to all four sides. Let side of square/diameter of circle = 1. Stand a way away and throw pennies into square. Find number of total pennies, count pennies in circle. Record. Repeat several thousand times. Find ratio of Pennies landing within circle to pennies thrown.

Or..... get a life.
:D
IIRichard
 
boooeee said:

Who knows other horribly inefficient ways of approximating Pi?

I don't think this is a very inefficient way of approximating Pi, I do, however, think it's a very amusing formula. It was devised by one Srinivasa Ramanujan (1887-1920) from India.
 
IIRichard said:
Paint a square on the floor. Construct a circle in tangent to all four sides. Let side of square/diameter of circle = 1. Stand a way away and throw pennies into square. Find number of total pennies, count pennies in circle. Record. Repeat several thousand times. Find ratio of Pennies landing within circle to pennies thrown.

Almost sounds like a drinking game.

Or..... get a life.
:D
IIRichard
Obviously not an option for me.

P.S. You forgot to add: "And then multiply by 4." :p
 
Define cos0 = 0, sin0 = 1. Define cosn+1 =s qrt((1+cosn)/2), sinn=sqrt((1-cosn)/2) and pin = (2^(n+1))sqrt((1-cosn)^2+sinn^2), with square roots calculated through Newtonian approximation.

Then pi should be equal to limit n-> infinity of pin. I believe that this is similar to a method used by an ancient Greek mathematician.
 
Re: Re: Inefficient Ways to Calculate Pi

Kaon said:
I don't think this is a very inefficient way of approximating Pi, I do, however, think it's a very amusing formula. It was devised by one Srinivasa Ramanujan (1887-1920) from India.
Wow. That is one ugly formula. Exactly the type of thing I was looking for.

Here's another method in the spirit of IIRichard's suggestion:

On a large sheet of paper, draw parallel lines spaced 2 inches apart. Get a needle that is one inch in length. Repeatedly toss the needle on the paper and take note as to whether the needle is touching one of the lines on the paper. After N trials, count up how many times the needle touched one of the lines. Call this number m. N/m -> Pi as N becomes large.
 
Select the largest spherical object you can find in the universe. Walk around the equatior of the object and record the distance C. Walk from one point on the sphere, through its center, to the opposite point and record the distance d. Compute C / d.

~~ Paul
 
Re: Re: Re: Inefficient Ways to Calculate Pi

boooeee said:
Wow. That is one ugly formula. Exactly the type of thing I was looking for.
Except that it looks like it should converge very quickly.
 
boooeee said:
1. For each positive integer, calculate the number of ways it can be expressed as the sum of the square of any two integers. Denote the number of ways for a given number n to be P(n). You can use positive or negative integers in the sum. And, the order of the sum matters. In other words, 1^2 + 2^ 2 and 2^2 + 1^2 should be counted as two ways of expressing 5. Here are the first few examples:

1 = 1^2 + 0^2
1 = 0^2 + 1^2
1 = (-1)^2 + 0^2
1 = 0^2 + (-1)^2
2 = 1^2 + 1^2
2 = (-1)^2 + 1^2
2 = 1^2 + (-1)^2
2 = (-1)^2 + (-1)^2
There are no ways of expressing 3 as the sum of two squared integers.

So, P(1) = 4, P(2) = 4, and P(3) = 0. Continue this process for each number and calculate the average of P(n). For example, the average for the first three numbers is ( 4 + 4 + 0 ) / 3 = 2.666666….

As you add more and more numbers to your list, this average approaches Pi. In other words ( P(1) + P(2) + …. + P(N))/N approaches Pi as N approaches infinity.

That's really cool. Why does it work?

I think one of the most fascinating things about the universe is the way everything ties together so nicely. Why on earth would you expect a constant whose purview seems limited to geometry to turn up in an investigation of properties of the integers?

That's why I have a poster on my wall that says, simply, e^ipi + 1 = 0.
 
1: Write a highly-efficient super-fantastic way to calculate pi.

2: Pick a random digit. Compare to first digit from super-fantastic way. If it matches, make another random digit and compare against the second digit. Continue until a digit doesn't match. If a digit doesn't match, start over.
 
Re: Re: Re: Re: Inefficient Ways to Calculate Pi

Art Vandelay said:
Except that it looks like it should converge very quickly.
Quickly if figured out on a computer. Very, very slowly if you have to calculate (n!)^4*(396)^4n by hand at every step.

Poor Ramanujan. His talent was as beautiful as it was useless.
 
c4ts said:
Bad ways to calculate Pi?

I've got one: the bible.
Or how about: Legislative Decree.

The Indiana House of Representatives (my home state) passed a bill in 1897 that would have legislated the value of Pi to 3.2.

This story circulated later as an Urban Legend, but with Alabama replacing Indiana (apparently the author thought that not even a Hoosier could be that stupid).

Link
 
Re: Re: Re: Re: Re: Inefficient Ways to Calculate Pi

Beleth said:
Quickly if figured out on a computer. Very, very slowly if you have to calculate (n!)^4*(396)^4n by hand at every step.

Poor Ramanujan. His talent was as beautiful as it was useless.

Well, actually formulas like his were used in 1989 to calculate the decimal expansion of pi to over 1 billion places. Obviously they used computers, but it's still not completely useless...
 
Re: Re: Inefficient Ways to Calculate Pi

Cecil said:
That's really cool. Why does it work?
I actually found this problem in a book called “The Mathematics of Oz” by Clifford Pickover. The frustrating thing about the problem is that he only provided a numerical solution via a computer program, not a real proof. Here’s the handwaving argument I came up with:

The trick is to think geometrically. Each way of writing the sum can be mapped on a one-to-one basis to a point on an xy-plane. For example, the 1 = (-1)^2 + 0^2 can be mapped to the point (-1,0); 2 = 1^2 + 1^2 can be mapped to the point (1,1).

So, imagine a grid of points on the xy-plane corresponding to all points (x,y) in which x and y are integers. How do we determine how many ways there are to express 46 as the sum of two squared integers? Geometrically, draw a circle on your grid with radius sqrt(46) and its origin at the point (0,0). Because the distance from each (x,y) point on the grid is sqrt(x^2 + y^2), if x^2 + y^2 = 46, then (x,y) will fall on the circle you just drew. So, the number of ways to express sqrt(46) as the sum of two squared integers corresponds to the number of (x,y) points that fall on the circle of radius sqrt(46).

Using this result, we can then determine the total number of ways to express the first N positive integers as the sum of two squared integers. To do that, all it takes is to draw your circle of radius sqrt(N), and then count all the (x,y) points enclosed by this circle, since this circle will also enclose the points that fall on the sqrt(N-1) circles, the sqrt(N-2) circle, and so on.

So, how many (x,y) points are enclosed by a circle with a radius of sqrt(N)? A good approximation would be the area of the circle, since each (x,y) point occupies one unit of area. As N becomes larger and larger, this approximation becomes more and more accurate. The area enclosed by the circle is Pi * (sqrt(N))^2 = Pi * N. To calculate the average, just divide this result by N, which gives Pi * N / N = Pi.
 
Re: Re: Re: Re: Inefficient Ways to Calculate Pi

Art Vandelay said:
Except that it looks like it should converge very quickly.
Yeah, but it's not like it would be my first choice if I wanted to calculate Pi. Calculating each term would not be fun.
 
Re: Re: Re: Inefficient Ways to Calculate Pi

Originally posted by boooeee
Using this result, we can then determine the total number of ways to express the first N positive integers as the sum of two squared integers. To do that, all it takes is to draw your circle of radius sqrt(N), and then count all the (x,y) points enclosed by this circle, since this circle will also enclose the points that fall on the sqrt(N-1) circles, the sqrt(N-2) circle, and so on.
And every enclosed lattice point falls on one such circle.
 
Re: Re: Inefficient Ways to Calculate Pi

Cecil said:
That's really cool. Why does it work?

I think one of the most fascinating things about the universe is the way everything ties together so nicely. Why on earth would you expect a constant whose purview seems limited to geometry to turn up in an investigation of properties of the integers?

That's why I have a poster on my wall that says, simply, e^ipi + 1 = 0.

ID?
 
Beleth said:
Quickly if figured out on a computer. Very, very slowly if you have to calculate (n!)^4*(396)^4n by hand at every step.
... not to mention that you'll need to use ANOTHER converging infinite series of some sort, before you even begin, so that you can first calculate the square root of 8.
 

Back
Top Bottom