Python Pi

As is my wont, I calculate pi. It’s considerably more efficient than my last effort, though that’s to be expected given the methodology.

As I mentioned earlier, I’ve been playing with Python, and I’ve a long-standing tradition, dating back to high school, of calculating pi when I’m starting to learn a new computer language.

That ugly-looking

d = math.sqrt((c*c) + pow((1 - math.sqrt(1-(c*c))),2))

just applies the Pythagorean theorem to ever-smaller triangular slices of a circle, until the outer hypotenuses very closely match the perimeter of the circle. I never quite remember the details, so I’ve always got to work out the geometry again when I try this, but it’s pretty straightforward once I get over the lazies.