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 d35d25cfdce763e5362ae7f8bbed4f752b9b0b4f Author: Dana Jacobsen <d...@acm.org> Date: Tue Apr 15 15:16:05 2014 -0700 Tighten nth_prime_{upper,lower} --- Changes | 2 ++ util.c | 5 ++++- xt/primecount-approx.t | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index c4caa69..34144a2 100644 --- a/Changes +++ b/Changes @@ -21,6 +21,8 @@ Revision history for Perl module Math::Prime::Util Cippola 1902 is still used for PP and large values, with a slightly more accurate third order correction. + - Tighten nth_prime_lower and nth_prime_upper for very small values. + 0.39 2014-03-01 diff --git a/util.c b/util.c index a33bcbf..f246c34 100644 --- a/util.c +++ b/util.c @@ -705,7 +705,7 @@ UV nth_prime_upper(UV n) else if (n >= 39017) /* Dusart 1999 page 14 */ upper = fn * (flogn + flog2n - 0.9484); else if (n >= 6) /* Modified from Robin 1983 for 6-39016 _only_ */ - upper = fn * ( flogn + 0.6000 * flog2n ); + upper = fn * ( flogn + 0.5982 * flog2n ) - 5; else upper = fn * ( flogn + flog2n ); @@ -742,6 +742,9 @@ UV nth_prime_lower(UV n) /* Dusart 2010 page 2, for all n >= 3 */ lower = fn * (flogn + flog2n - 1.0 + ((flog2n-2.10)/flogn)); + /* Tighten small values */ + if (n < 2679) lower = 1.003 * lower + 23; + else if (n < 14353) lower = 1.001 * lower + 21; return (UV) floorl(lower); } diff --git a/xt/primecount-approx.t b/xt/primecount-approx.t index e01d1ef..38a8dc6 100644 --- a/xt/primecount-approx.t +++ b/xt/primecount-approx.t @@ -139,7 +139,8 @@ foreach my $n (sort {$a <=> $b} keys %pivals) { cmp_ok( ''.prime_count_upper($n), '>=', $pin, "Pi($n) <= upper estimate" ); cmp_ok( ''.prime_count_lower($n), '<=', $pin, "Pi($n) >= lower estimate" ); # Result may be bigint, so turn into float for percentage comparison - my $approx = 0.0 + ''.prime_count_approx($n); + print "n = '$n'\n"; + my $approx = 0.0 + (''.prime_count_approx($n)); my $percent_limit = ($n > 1000000000000) ? 0.00005 : ($n > 10000000000) ? 0.0002 : ($n > 100000000) ? 0.002 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits