Calculate 500 digits of pi
Golfscript - 29 chars
6666,-2%{2+.2/@*\/9)499?2*+}*
I will post analysis later
Mathematica (34 chars): (without "cheating" with trig)
N[2Integrate[[1-x^2]^.5,-1,1],500]
So, to explain the magic here:
Integrate[function, lower, upper]
gives you the area under the curve "function" from "lower" to "upper". In this case, that function is [1-x^2]^.5
, which is a formula that describes the top half of a circle with radius 1. Because the circle has a radius of 1, it does not exist for values of x lower than -1 or higher than 1. Therefore, we are finding the area of half of a circle. When we multiply by 2, then we get the area inside of a circle of radius 1, which is equal to pi.
Python (83 chars)
P=0
B=10**500
i=1666
while i:d=2*i+1;P=(P*i%B+(P*i/B+3*i)%d*B)/d;i-=1
print'3.%d'%P