Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

shuks

Calculating PI

This topic is 5342 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was experimenting a little in calculus the other day, and I came up with:

pi = 4*∫01sqrt(1-x2)dx

I didn't check it, but I'd imagine it's right.

Hmmm, that means that atan(1) = ∫01sqrt(1-x2)dx

[EDIT] pi in this font doesn't really look like pi ( π )

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________


[edited by - Thunder_Hawk on February 29, 2004 1:40:59 PM]

Share this post


Link to post
Share on other sites
Advertisement
Theres an article on msdn by Chris Sells on multithreading using C#. The sample program for the article can calculate pi to any given number of digits.
I haven''t looked at the source code because i am trying to do it first. The algorithm calculates 9 digits of pi at a time on a secondary thread which then updates a progressbar.

Share this post


Link to post
Share on other sites
Wow, people here are really uneducated about our second favorite constant pi (we like e the most, and if you don''t know what it is or why, then don''t ask). Off the top of my head, pi = 3.1415926535897932384626433... and can be found using various inverse trigonometric functions, although atan is probably the best because it''s intrisic to the FPU. The FPU also has a load-pi instruction, as well as others for other important constants. Pi is defined as M_PI in math.h if you need it for programming in C(++). ToohrVyk''s original post mentioned several ways of calculating it analytically, although zeta(2), the sum he described, converges VERY slowly. The method Shadowdancer gave was given by Ramanujan, and probably isn''t accurate enough for use in programming.

If you want analytic ways to obtain pi, look into the Dirichlet beta, eta and lambda functions. beta(1) = pi / 4 is probably the best one to go with although I do not know speed of convergence. Also look for the algorithm that is quartically convergent on pi.

Share this post


Link to post
Share on other sites
quote:
Original post by Thunder_Hawk
I was experimenting a little in calculus the other day, and I came up with:

π = 4*∫01sqrt(1-x2)dx

I didn''t check it, but I''d imagine it''s right.

Hmmm, that means that atan(1) = ∫01sqrt(1-x2)dx


I think you might have forgetten a 1 / there because the integeral of 1 / sqrt(1 - x ^ 2) is arctan of x if I remember correctly.

Share this post


Link to post
Share on other sites
quote:
Original post by vEEcEE
I''ve seen people use atan(1)*4 for PI


Except for the fact it''s really darn slow and innacurate (you have to do math at extremely high precision and with billions of terms to get a few digits)

Excellent reference: http://www.cygnus-software.com/misc/pidigits.htm

Share this post


Link to post
Share on other sites
quote:
Original post by Puzzler183
I think you might have forgetten a 1 / there because the integeral of 1 / sqrt(1 - x ^ 2) is arctan of x if I remember correctly.


Yes, you remembered correctly

Share this post


Link to post
Share on other sites
If you use degrees with your trigonometry functions (sine,...) you can do this:

Pi = n * sin(180/n)

the higher n is, the more exacter Pi will be calculated

QB 4 EVER

[edited by - akOOma on February 29, 2004 2:51:39 PM]

Share this post


Link to post
Share on other sites
atan(1)*4=3.14159265......

There is another algorithm I found once it lets you calculate pi to the 70,000 digit I forget whats it called though >.<

[edited by - DevLiquidKnight on February 29, 2004 2:08:06 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!