[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] pi



At 12:41 PM -0700 8/12/99, Brian McNett wrote:
>Pi is an irrational number...

>Canonically, pi = atan2(1,1) * 4.0, which should produce pi to the
>accuracy of double floats.  If you need more accurate pi, you're probably
>doing something mathematically interesting.
>
>#!perl -w
>
>use strict;
>use vars qw($pi_approx $pi_better $pi);
>use constant PI => atan2(1,1) * 4.0;

[code snipped]

Of course if one is going to accept some level of approximation, how 
about just setting a constant to the value of pi that has the 
precision wanted? I.e., instead of spending cycles on a calculation 
(as nice as that one is), just type in the pi value:

use constant PI => atan2(1,1) * 4.0;  # .00001 secs*

use constant PI => 3.14159265358979323846264338327950;  # .0000001 secs*

*Time values estimated for illustration purposes only   ;-)

This discussion makes me think it would be very interesting to see an 
overlap of the pi culture and the Perl culture. Anybody out there?

Let's offer an irrational prize for the first one who can give us a 
Perl script that speaks pi out at the level of precision requested. 
Or maybe Kevin Reid could do something interesting visually...
- Bruce

_Bruce_Van_Allen___bva@cruzio.com__831_429_1688_V_
_PO_Box_839__Santa_Cruz_CA__95061__831_426_2474_W_

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org