Calculating PI to n-decimal places anyone?

Started by
9 comments, last by shadow12345 19 years, 7 months ago
Hey I would like to know of a method to calculate PI to n-decimal places. Does anyone know a way an algorithm to do this? (PS: Please try and use as simple terms as I am still in highschool as it were(Standard 9/Grade 11). This is not homework!) Thank you in advance.
"..."
Advertisement
the only method i know i to do the following.

PI = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11... ad infinitum.

in order to calculate PI to an arbitrary digit this way youd need arbitrary + something accurate floats though, and besides i doubt this is the fastest way.

id recommend mathworld, its bound to have a detailled explanation on this stuff.
The problem with most methods is that they can converge quite slowly. I think some of the greatest methods for "fastest" methods for finding PI to any decimal place were perhaps due to Ramanujan. (feel free to correct me, i'm not saying i KNOW this to be in fact true, it's just my impression from reading stuff)

Take a look at the following links. They might get you going on some methods. The first link might be a little hard for you to read since you're still in highschool, bu the others are more "light".

http://en.wikipedia.org/wiki/Pi#Numerical_approximations_of_.26pi.3B

http://mathforum.org/library/drmath/view/58286.html

http://www.lbl.gov/Science-Articles/Archive/pi-algorithm.html
(http://www.lacim.uqam.ca/~plouffe/articles/Miraculous.pdf)
Why do you want to be able to do this, could you not find a value off the internet and store it in a constant?

IIRC:

pi = circumference of a circle/diameter of a circle

so you could draw yourself a circle and measure the circ and diameter and the bung them in the formula.
Quote:Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!
Thanks. I have the answer I needed to know

I just wanted to know the answer, in order to know it and then program it. I don't even care how fast it is. There is no point in having the fastest as the record is 51,539,600,000 decimal digits of PI. This is easy to program in java as there are classes which can handle numbers with any number of digits.
(BigInteger and BigDecimal)

Thanks.
"..."
Quote:
PI = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11... ad infinitum.


Note that this is:

4 * arctan(1)

in radian mode of course
Why don't alcoholics make good calculus teachers?Because they don't know their limits!Oh come on, Newton wasn't THAT smart...
Quote:Original post by shadow12345
Quote:
PI = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11... ad infinitum.


Note that this is:

4 * arctan(1)

in radian mode of course


and your point being?

there are numerous ways to calculate Pi, the problem is finding one with arbitrary accuracy.
http://3.141592653589793238462643383279502884197169399375105820974944592.com/

From this thread.
.:<<-v0d[KA]->>:.
The relevance is that arctan(x)=x-x^3/3+x^5/5-x^7/7+... so if you plug x=1 in all the x^n's become 1. That can lead you to p(n)=(8/[(4n-1)*(4n-3)]) * ([192n-44]/[5^(4n-1)] - [114240n-28559]/[239^(4n-1)]) by using it for 4*arctan(1/5)-arctan(1/239). That expansion will get you about three digits per term which is a little faster.
Keys to success: Ability, ambition and opportunity.
If you have a way of calculating Sin() to arbitrary precision, which isnt all that hard (taylor expansion..) then this handy algorithm works quite well:

x[0] = 3
x[n+1] = x[n] + sin(x[n])

x starts as a first rough guess and converges on pi pretty rapidly.. 3 iterations will fill a 64-bit IEEE float with pi

certainly not the fastest method, but a lot faster than the 'old school' expansion methods - and its quite simple.

- Rockoon


This topic is closed to new replies.

Advertisement