From 08896769659975f1f9288ccbc58f57cd1558b9e2 Mon Sep 17 00:00:00 2001 From: Kim Walisch Date: Fri, 22 Mar 2024 19:28:43 +0100 Subject: [PATCH] Improve bounds near 0 --- src/RiemannR.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/RiemannR.cpp b/src/RiemannR.cpp index 5d58ce5a9..da733b0cc 100644 --- a/src/RiemannR.cpp +++ b/src/RiemannR.cpp @@ -201,7 +201,7 @@ T initialNthPrimeApprox(T x) template T RiemannR(T x) { - if (x < T(0.1)) + if (x < T(1e-5)) return 0; T epsilon = std::numeric_limits::epsilon(); @@ -240,12 +240,12 @@ T RiemannR(T x) template T RiemannR_inverse(T x) { + if (x < 1) + return 0; + T t = initialNthPrimeApprox(x); T old_term = std::numeric_limits::infinity(); - if (x < 3) - return t; - // The condition i < ITERS is required in case the computation // does not converge. This happened on Linux i386 where // the precision of the libc math functions is very limited. @@ -274,8 +274,6 @@ namespace primesieve { long double RiemannR(long double x) { - if (x <= 100) - return ::RiemannR((float) x); if (x <= 1e8) return ::RiemannR((double) x); else @@ -284,8 +282,6 @@ long double RiemannR(long double x) long double RiemannR_inverse(long double x) { - if (x <= 100) - return ::RiemannR_inverse((float) x); if (x <= 1e8) return ::RiemannR_inverse((double) x); else