Skip to content

Commit

Permalink
Improve bounds near 0
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Mar 22, 2024
1 parent 05500f6 commit 0889676
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/RiemannR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ T initialNthPrimeApprox(T x)
template <typename T>
T RiemannR(T x)
{
if (x < T(0.1))
if (x < T(1e-5))
return 0;

T epsilon = std::numeric_limits<T>::epsilon();
Expand Down Expand Up @@ -240,12 +240,12 @@ T RiemannR(T x)
template <typename T>
T RiemannR_inverse(T x)
{
if (x < 1)
return 0;

T t = initialNthPrimeApprox(x);
T old_term = std::numeric_limits<T>::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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0889676

Please sign in to comment.