26 const double beta = 0.40580406331047491619301581522449851;
34 const double euler_gamma = 0.577215664901532860606512090082402431042;
46 const int round = fegetround();
48 fesetround(FE_UPWARD);
51 const double bound = ((std::log(static_cast<double>(
square(a*2 + 1))
52 / static_cast<double>((b*2 + 1)*2))
54 - (0.5/(static_cast<double>(
square(b) + b) + alpha)
55 - 1.0/(
static_cast<double>(
square(a) + a) + beta)) / 24.0);
67 const int round = fegetround();
69 fesetround(FE_UPWARD);
75 const double bound = (
is_even(n)
76 ? ((std::log(static_cast<double>(
square(n*2 + 1))
77 / static_cast<double>((n + 1)*2))
79 - (1.0/(static_cast<double>(
square(n + 1)) + alpha_bis)
80 - 0.5/(
static_cast<double>(
square(n) + n) + beta)) / 12)
81 : ((std::log(static_cast<double>(
square(n*2 + 1))
82 / static_cast<double>(n*2))
84 - (1.0/(static_cast<double>(
square(n)) + alpha_bis)
85 - 0.5/(
static_cast<double>(
square(n) + n) + beta)) / 12));
98 const int round = fegetround();
100 fesetround(FE_UPWARD);
103 const double bound = (std::log(static_cast<double>(a*2 + 1)
104 / static_cast<double>(b*2 + 1))
105 - (1.0/(
static_cast<double>(
square(b) + b) + alpha)
106 - 1.0/(
static_cast<double>(
square(a) + a) + beta)) / 24);
118 const int round = fegetround();
120 fesetround(FE_DOWNWARD);
123 const double bound = (std::log(static_cast<double>(n) + 0.5)
125 + 1.0/((
static_cast<double>(
square(n) + n) + alpha)*24));
137 const int round = fegetround();
139 fesetround(FE_UPWARD);
142 const double bound = (std::log(static_cast<double>(n) + 0.5)
144 + 1.0/((
static_cast<double>(
square(n) + n) + beta)*24));
156 for (
nat_type i = 1; i <= to_n; i += 2) {
157 sum +=
static_cast<nat_type>(std::floor(static_cast<double>(n)/static_cast<double>(i)));
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
double harmonic_lower_bound(nat_type n)
Return a lower bound of H_n.
constexpr bool is_even(nat_type n)
Return true iff n is even.
double diff_half_harmonic_upper_bound(nat_type a, nat_type b)
Return an upper bound of H_a - 1/2 H_b.
A lot of functions and stuffs to deal the sigma_odd problem and related stuffs.
Function to calculate harmonic number H_n = 1 + 1/2 + 1/3 + 1/4 + ... + 1/n and some variants and upp...
nat_type sum_floor_n_harmonic_odd(nat_type n, nat_type to_n)
Return floor(n/1) + floor(n/3) + floor(n/5) + floor(n/7) + ... + (n/to_n or floor(1/(to_n-1))).
constexpr double square(double x)
Return x*x.
Functions in link with divisor notion: sum of divisors, factorization, GCD, coprime, ...
double harmonic_upper_bound(nat_type n)
Return an upper bound of H_n.
const double euler_gamma
The Euler-Mascheroni constant 0.577215664901532860606512090082402431042... (rounded to an upper bound...
double diff_harmonic_upper_bound(nat_type a, nat_type b)
Return an upper bound of H_a - H_b.