Advertisement

a number for pi

Started by February 07, 2003 12:08 PM
27 comments, last by JYoung 21 years, 11 months ago
Unfortunately (or perhaps fortunately for the universe) I believe Pi is known to be non-algebraic - meaning there''s no equation for it. There are several sequences that provide progressively better approximations, though most converge pretty slowly (I tried one with a programmable calculator and got bored of hitting the execute button before it had stabilised to the limits of the display (10 digits)). It should be pretty easy to find them with a little research.
You are right, pi is not algebraic, which means it is not the solution to a polynomial function with integer coefficients. There are formulas that exist- the best place to look for them is http://mathworld.wolfram.com. However, as one of GRhodes'' links tell you, it is not really needed for all practical purposes. I forget what the exact value is, but if you wanted to calculate the circumfrance of the universe to the diameter of a hydrogen atom, you need less than 100 digits of pi.


Brendan
Brendan"Mathematics is the Queen of the Sciences, and Arithmetic the Queen of Mathematics" -Gauss
Advertisement
Haha, thanks for the input, and that last example gave a bit of perspective to it all. Thanks again.
another expression for PI:

4*integral(sqrt(1-x^2) dx, [0,1])
Visit our homepage: www.rarebyte.de.stGA
Pi = sqrt(6/P)

where P is the probability of two random numbers being relatively prime. So you can compute an approximation to Pi by computing a large number of pairs of random integers and approximating P as the fraction of those pair that actually are relatively prime.

Not very accurate, but I find it funny...

quote:
Original post by MichaelT
#define my_PI 3.1415926535897932384626433832795

and you are good to go.

____________________________________________________________
Try RealityRift at www.planetrift.com
Feel free to comment, object, laugh at or agree to this. I won't engage in flaming because of what I have said.
I could be wrong or right but the ideas are mine.





or in C++ you can do it like this

    const float PI = 3.141592f;    


I prefer const to #define


[edited by - Mars_999 on February 26, 2003 2:24:51 PM]
Advertisement
Well, pi is transcendental, but there is an infinite sum that is easy to calculate and converges pretty quickly to the first few decimal places.

sum(1/x^2,x,1,infinity)=(pi^2)/6

This is similar to that probability one, but much cheaper and easier to implement.
You know what I never noticed before?
to easily get pi accurate to as many places as the FPU can handle

[type] pi;
__asm{
fldpi
fstp [size] ptr pi
}

If you use M_PI or some such predefined number (3.141...) then the compiler is likely to create an unnamed variable holding pi each time you use it. This can screw up the cache. If you''re coding an intensve funciton in assembly, fldpi also has virtually no cost (no memory read, pairs with anything...)

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...
>Pi = sqrt(6/P)
>where P is the probability of two random numbers being
>relatively prime. So you can compute an approximation to Pi by
>computing a large number of pairs of random integers and
>approximating P as the fraction of those pair that actually
>are relatively prime.
>Not very accurate, but I find it funny...

It gets even better than this: i read somewhere that they used the coordinates of where V2 rockets struck London in WW2 to compute a value of Pi accurate to two digits :D

This topic is closed to new replies.

Advertisement