ConstantCalculus-CircleConstant

 view release on metacpan or  search on metacpan

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

714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
 
=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

921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
  # Calculate and print the value Pi.
  $tau = tau($places);
  print $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

1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
=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

1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
=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 )