NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Friday April 21, 2006
11:05 AM
Don't Memorize Pi
There's no need to memorize the digits of Pi. Just remember -1.
#!/usr/bin/perl
use Math::Complex;
use constant PI => -1 * log(-1) * sqrt(-1);
printf "Pi is %.12f\n", PI;
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Same thing only different (Score:1)
pi = 2*(pi/2) = 2*atan( 1/0 ) = 2*atan(+Inf) (Score:1)
A more boring alternative... (Score:1)
use Math::Trig;
printf "Pi is %.12f\n", pi;
Re:A more boring alternative... (Score:2)
If you want a few more digits... (Score:1)
Re:If you want a few more digits... (Score:2)
Re:If you want a few more digits... (Score:1)
Yeah, I knew that. So it was in a way an answer even more boring than the post I replied to :-) Nothing exciting like using :-)
log(-1) = -πi. But, having worked on the module, I just had to mention itRe:If you want a few more digits... (Score:2)
My personal favorite... (Score:2)
When I need to approximate PI, I just remember the sequence [1 1 3 3 5 5], rearranging its two halves to get:
which is correct to the first seven decimal places.
That's sufficiently accurate to compute the circumference of the Earth from its radius with an error of about 3 metres (out of 40 million metres). Close enough for most e
Re:My personal favorite... (Score:2)
Pi and e deeply interwoven (Score:1)
Bill
# I had a sig when sigs were cool
use Sig;