ConstantCalculus-CircleConstant
view release on metacpan or search on metacpan
lib/ConstantCalculus/CircleConstant.pm view on Meta::CPAN
714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765L<CPAN bignum|https://metacpan.org/dist/bignum>
=head1 DESCRIPTION
The circle constant is a mathematical constant. There are two variants of the
circle constant. Most common is the use of Pi (Ï€) for the circle constant. More
uncommon is the use of Tau (Ï„) for the circle constant. The relation between
them is τ = 2 π. There can be found other denotations for the well known name
Pi. The names are Archimedes's constant or Ludolph's constant. The circle
constant is used in formulas across mathematics and physics.
The circle constant is the ratio of the circumference C of a circle to its
diameter d, which is π = C/d or τ = 2 C/d. It is an irrational number, which
means that it cannot be expressed exactly as a ratio of two integers. In
consequence of this, the decimal representation of a circle constant never
ends in there decimal places having a infinite number of places, nor enters
a permanently repeating pattern in the decimal places. The circle constant is
also a not algebraic transcendental number.
Over the centuries scientists developed formulas for approximating the circle
constant Pi. Chudnovsky's formula is one of them. A algorithm based on Chudnovsky's
formula can be used to calculate an approximation for Pi and also for Tau. The
advantage of the Chudnovsky formula is the good convergence. In contradiction
the convergence of the Leibniz formula is quit bad.
The challenge in providing an algorithm for the circle constant is that all
decimal places must be correct in terms of the formula. Based on the desired decimal
place number or precision, the number of places must be correct. The provided
algorithm takes care of this. At the moment the result of the implemented algorithm
was checked against the known decimal places of Pi up to 10000 places.
=head1 APPROXIMATIONS OF PI AND TAU
Fractions such as 22/7 or 355/113 can be used to approximate the circle constant
Pi, whereas 44/7 or 710/113 represent the approximation of the circle constant
Tau.
At the moment Chudnovsky's formula is fully implemented in the module to calculate
Pi as well as Tau. The algorithm from Borwein from 1989 is implemented for experimental
purposes. The most popular formula for calculating the circle constant is the Leibniz
formula.
=head1 IMPLEMENTATION
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
lib/ConstantCalculus/CircleConstant.pm view on Meta::CPAN
921922923924925926927928929930931932933934935936937938939940941942943944945
# Calculate and print the value Pi.
$tau
= tau(
$places
);
$tau
.
"\n"
;
=head1 MODULE METHODS
=head2 Main Methods
=head3 chudnovsky_algorithm()
Implementation of the Chudnovsky formula.
=head3 borwein25_algorithm()
Implementation of the Borwein 25 formula.
=head3 pi_borwein25()
Calculate Pi with the Borwein 25 algorithm.
=head3 tau_borwein25()
Calculate Tau with the Borwein 25 algorithm.
=head3 pi_chudnovsky()
lib/ConstantCalculus/CircleConstant.pm view on Meta::CPAN
104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070=head1 BUGS
Bugs are not known yet.
=head1 NOTES
The implemented chudnovsky algorithm is used in a representation where the
well known terms are optimised for calculation.
It seems that the Perl builtin function C<sqrt()> cannot used in general for
determining the value of Pi or Tau with respect to some calculation formulas.
Chudnovsky's formula is working using the Perl builtin function C<sqrt()>. In
contradiction Borwein25's formula fails in calculation using the Perl builtin
function C<sqrt()>.
Using a coded user defined subroutine for calculating of a square root,
Borwein25's could be used for the calculation.
=head1 OPEN ISSUE
Further calculations with higher precision are outstanding to check the
accuracy of the correctness of the last digits of the calculated circle
constant.
lib/ConstantCalculus/CircleConstant.pm view on Meta::CPAN
10821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116=back
=head2 Mathematical informations
=over 4
=item * Sources w.r.t. the circle constant Pi
=item * Sources w.r.t. the circle constant Tau
=item * Resources about the Leibniz formula
=item * Resources about the Chudnovsky formula
=item * Resources about Borwein's formulas
=back
=head2 Bibliography
=over 4
=item * David H. Bailey, The BBP Algorithm for Pi, September 17, 2006
=item * David H. Bailey, A catalogue of mathematical formulas involving π, with analysis, December 10, 2021
=item * David H. Bailey, Jonathan M. Borwein, Peter B. Borwein and Simon Plouffe, The Quest for Pi, June 25, 1996
=back
=head1 AUTHOR
Dr. Peter Netz, E<lt>ztenretep@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
( run in 0.485 second using v1.01-cache-2.11-cpan-0f795438458 )