Find pi which is the area of a unit circle. Integrate over the first quadrant and scale for remaining quadrants.
Recreated in coffeescript:
sq = (x) -> x*x sqrt = (x) -> Math.sqrt(x) area = 0 dx = .0000001 for x in [0..1] by dx area += sqrt(1-sq(x)) console.log area*4*dx
Produces this output:
3.141592854156842
Compare this to the published value of pi:
3.141592653589793
The IBM 360 that ran my original IITRAN program was not nearly as fast as modern javascript. Nor was the floating point as accurate. I was not able to achieve this accuracy.
I did try several step sizes (dx). I found that although I saw improvements they were modest. I adjusted the permissible program runtime so I could try even smaller steps only to find that the result lost accuracy. It also wasted money that didn't come out of my pocket, but I always felt bad about that.
.
π rears its head, again and again. pdf
I'm from Indiana where we always chuckled about the state legislating the value of Pi. Now in a six-part post Brian Marick recounts his contemplation of this struggle with the rule of law. mastodon
The Chudnovsky algorithm is a fast method for calculating the digits of π, based on Ramanujan's π formulae. Published by the Chudnovsky brothers in 1988, it was used to calculate π to a billion decimal places. wikipedia