[libmath-prime-util-perl] 25/43: Add PP twin_prime_count_approx

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:53:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.40
in repository libmath-prime-util-perl.

commit 61eb52f379716fe2b301577290c5aaa17c8a4317
Author: Dana Jacobsen <dana at acm.org>
Date:   Wed Apr 2 21:49:33 2014 -0700

    Add PP twin_prime_count_approx
---
 lib/Math/Prime/Util/PP.pm   | 7 +++++++
 lib/Math/Prime/Util/PPFE.pm | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index 9e7fd2e..a2c843b 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -1349,6 +1349,13 @@ sub twin_prime_count {
   $sum;
 }
 
+sub twin_prime_count_approx {
+  my($n) = @_;
+  my $logn = log($n);
+  my $li2 = ExponentialIntegral($logn) + 2.8853900817779268147198494 - ($n/$logn);
+  return int(1.32032363169373914785562422 * $li2 + 0.5);
+}
+
 sub nth_twin_prime {
   my($n) = @_;
   my($nth, $p, $p2) = (0, 0, 3);
diff --git a/lib/Math/Prime/Util/PPFE.pm b/lib/Math/Prime/Util/PPFE.pm
index f8d1938..77d917d 100644
--- a/lib/Math/Prime/Util/PPFE.pm
+++ b/lib/Math/Prime/Util/PPFE.pm
@@ -116,6 +116,11 @@ sub twin_prime_count {
   }
   return Math::Prime::Util::PP::twin_prime_count($low,$high);
 }
+sub twin_prime_count_approx {
+  my($n) = @_;
+  _validate_positive_integer($n);
+  return Math::Prime::Util::PP::twin_prime_count_approx($n);
+}
 sub nth_twin_prime {
   my($n) = @_;
   _validate_positive_integer($n);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list