ConstantCalculus-CircleConstant

 view release on metacpan or  search on metacpan

lib/ConstantCalculus/CircleConstant.pm  view on Meta::CPAN


To be able to deal with large numbers pre decimal point and after the decimal point
as needed, the Perl module C<bignum> is used. The main subroutine argument is the 
number of places, which should be calculated for the circle constant.        

If terms and precision is not given, both are estimated from the given number of
places. This will result in a value of Pi, which is accurate to the requested 
places. If places, terms and/or precision is given, the behaviour of the algorithm
can be studied with respect to terms and/or precision.  

The number of iterations is calculated using the knowledge, that each iteration
should result in e.g. 14 new digits after the decimal point. So the value for the 
calculation of the number of terms is set to e.g. 14.  To make sure that reverse as
less as possible digits are changed, the number of terms to calculated is uneven.
So the sign of the term to add is negative after the decimal point.

To prevent rounding errors in the last digit, the precision is a factor of e.g. 14
higher than the requested number of places. The correct number of places is realised
by truncating the calculated and possibly rounded value of Pi to the requested number
of places.      

lib/ConstantCalculus/CircleConstant.pm  view on Meta::CPAN

=head3 modexp()

The subroutine returns the result of a modular exponentiation. A modular 
exponentiation is an exponentiation applied over a modulus. The result
of the modular exponentiation is the remainder when an integer b (base) 
is exponentiated by e (exponent) and divided by a positive integer m
(modulus).

=head3 estimate_terms()

Estimates the terms or iterations to get the correct number of place.

=head3 truncate_places()

Truncate the number of places to a given value.

=head1 MODULE EXPORT

=head2 Generic export

=over 4



( run in 0.695 second using v1.01-cache-2.11-cpan-96521ef73a4 )