Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Feb 10, 2024
1 parent 83e0e92 commit 96505d5
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/RiemannR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,15 @@ long double RiemannR_prime(long double x)

for (int k = 1; k < 128 && std::abs(old_sum - sum) >= epsilon; k++)
{
long double k_inv = 1.0L / (long double) k;
term *= logx * k_inv;
term *= logx / k;
old_sum = sum;
sum += term * zetaInv[k];
}

// For k >= 128, approximate zeta(k + 1) by 1
for (int k = 128; std::abs(old_sum - sum) >= epsilon; k++)
{
long double k_inv = 1.0L / (long double) k;
term *= logx * k_inv;
term *= logx / k;
old_sum = sum;
sum += term;
}
Expand Down Expand Up @@ -259,19 +257,17 @@ long double RiemannR(long double x)

for (int k = 1; k < 128 && std::abs(old_sum - sum) >= epsilon; k++)
{
long double k_inv = 1.0L / (long double) k;
term *= logx * k_inv;
term *= logx / k;
old_sum = sum;
sum += term * k_inv * zetaInv[k];
sum += term / k * zetaInv[k];
}

// For k >= 128, approximate zeta(k + 1) by 1
for (int k = 128; std::abs(old_sum - sum) >= epsilon; k++)
{
long double k_inv = 1.0L / (long double) k;
term *= logx * k_inv;
term *= logx / k;
old_sum = sum;
sum += term * k_inv;
sum += term / k;
}

return sum;
Expand Down

0 comments on commit 96505d5

Please sign in to comment.