Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Mar 18, 2024
1 parent 3cbee9a commit 2fa7306
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/RiemannR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,14 @@ T RiemannR_inverse(T x)
// the precision of the libc math functions is very limited.
for (int i = 0; i < 100; i++)
{
T term = (RiemannR(t) - x) / RiemannR_prime(t);
T term;

if (x < 1e10)
// Converges faster for small x
term = (RiemannR(t) - x) / RiemannR_prime(t);
else
// Converges faster for large x
term = (RiemannR(t) - x) / std::log(t);

// Not converging anymore
if (std::abs(term) >= std::abs(old_term))
Expand Down

0 comments on commit 2fa7306

Please sign in to comment.