Loading [MathJax]/extensions/tex2jax.js
Parallel numerical verification of the σ_odd problem  October 6, 2018
All Classes Namespaces Files Functions Variables Typedefs Macros
harmonic.hpp
Go to the documentation of this file.
1 /* -*- coding: latin-1 -*- */
2 /** \file common/sigmaodd/harmonic.hpp (February 14, 2018)
3  * \brief
4  * Function to calculate harmonic number
5  * H_n = 1 + 1/2 + 1/3 + 1/4 + ... + 1/n
6  * and some variants and upper bounds.
7  *
8  * http://mathworld.wolfram.com/HarmonicNumber.html
9  *
10  * GPLv3 --- Copyright (C) 2017, 2018 Olivier Pirson
11  * http://www.opimedia.be/
12  */
13 
14 #ifndef PROGS_SRC_COMMON_SIGMAODD_HARMONIC_HPP_
15 #define PROGS_SRC_COMMON_SIGMAODD_HARMONIC_HPP_
16 
17 #include "helper.hpp"
18 
19 
20 namespace sigmaodd {
21 
22  /* **********
23  * Constant *
24  ************/
25  /** \brief
26  * The Euler-Mascheroni constant 0.577215664901532860606512090082402431042...
27  * (rounded to an upper bound in double)
28  * http://mathworld.wolfram.com/Euler-MascheroniConstant.html
29  */
30  extern const double euler_gamma;
31 
32 
33 
34  /* ************
35  * Prototypes *
36  **************/
37 
38  /** \brief
39  * Return an upper bound of H_a - 1/2 H_b.
40  *
41  * Use Chen 2016 inequalities: https://link.springer.com/article/10.1007%2Fs11075-016-0116-9
42  *
43  * H_a - 1/2 H_b
44  * < 1/2 ln( (2a+1)^2 / (2(2b+1)) ) + gamma/2 + 1/(24 (a^2 + a + beta)) - 1/(48 (b^2 + b + alpha))
45  *
46  * @param a >= 1
47  * @param b >= 1
48  *
49  * @return an upper bound of H_a - 1/2 H_b
50  */
51  double
53 
54 
55  /** \brief
56  * Return an upper bound of H_n - 1/2 H_k with k = floor(n/2).
57  *
58  * Use Chen 2016 inequalities: https://link.springer.com/article/10.1007%2Fs11075-016-0116-9
59  *
60  * H_n - 1/2 H_k
61  * < 1/2 ln( (2n+1)^2 / (2(n+1)) ) + gamma/2
62  * + 1/(24 (n^2 + n + beta)) - 1/(12 ((n+1)^2 + alpha_bis)) if n even
63  *
64  * H_n - 1/2 H_k
65  * < 1/2 ln( (2n+1)^2 / (2n)) ) + gamma/2
66  * + 1/(24 (n^2 + n + beta)) - 1/(12 (n^2 + alpha_bis)) if n odd
67  *
68  * @param n >= 1
69  *
70  * @return an upper bound of H_n - 1/2 H_{n/2}
71  */
72  double
74 
75 
76  /** \brief
77  * Return an upper bound of H_a - H_b.
78  *
79  * Use Chen 2016 inequalities: https://link.springer.com/article/10.1007%2Fs11075-016-0116-9
80  *
81  * H_a - H_b < ln((2a + 1)/(2b + 1)) + 1/(24 (a^2 + a + beta)) - 1/(24 (b^2 + b + alpha))
82  *
83  * @param a >= 1
84  * @param b >= 1
85  *
86  * @return an upper bound of H_a - H_b
87  */
88  double
90 
91 
92  /** \brief
93  * Return the harmonic number H_n = 1/1 + 1/2 + 1/3 + 1/4 + ... + 1/n.
94  *
95  * H_0 = 0
96  *
97  * http://mathworld.wolfram.com/HarmonicNumber.html
98  *
99  * @return the harmonic number H_n
100  */
101  constexpr
102  double
103  harmonic(nat_type n);
104 
105 
106  /** \brief
107  * Return 1/2 + 1/4 + 1/6 + 1/8 + ... + (1/n or 1/(n-1)).
108  */
109  constexpr
110  double
112 
113 
114  /** \brief
115  * Return 1/1 + 1/3 + 1/5 + 1/7 + ... + (1/n or 1/(n-1)).
116  */
117  constexpr
118  double
120 
121 
122  /** \brief
123  * Return a lower bound of H_n.
124  *
125  * Use Chen 2016 inequalities: https://link.springer.com/article/10.1007%2Fs11075-016-0116-9
126  *
127  * ln(n + 1/2) + gamma + 1/(24 (n^2 + n + alpha)) < H_n
128  *
129  * @return an upper bound of H_n
130  */
131  double
133 
134 
135  /** \brief
136  * Return an upper bound of H_n.
137  *
138  * Use Chen 2016 inequalities: https://link.springer.com/article/10.1007%2Fs11075-016-0116-9
139  *
140  * H_n <= ln(n + 1/2) + gamma + 1/(24 (n^2 + n + beta))
141  *
142  * @return an upper bound of H_n
143  */
144  double
146 
147 
148  /** \brief
149  * Return floor(n/1) + floor(n/3) + floor(n/5) + floor(n/7) + ... + (n/to_n or floor(1/(to_n-1))).
150  */
151  nat_type
153 
154 } // namespace sigmaodd
155 
156 
157 #include "harmonic__inline.hpp"
158 
159 #endif // PROGS_SRC_COMMON_SIGMAODD_HARMONIC_HPP_
unsigned long nat_type
Type for natural number used in all code, on 64 bits.
Definition: sigmaodd.cl:22
Define type and some generic functions.
double harmonic_lower_bound(nat_type n)
Return a lower bound of H_n.
Definition: harmonic.cpp:115
double diff_half_harmonic_upper_bound(nat_type a, nat_type b)
Return an upper bound of H_a - 1/2 H_b.
Definition: harmonic.cpp:42
A lot of functions and stuffs to deal the sigma_odd problem and related stuffs.
Definition: divisors.cpp:22
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))).
Definition: harmonic.cpp:153
constexpr double harmonic_even(nat_type n)
Return 1/2 + 1/4 + 1/6 + 1/8 + ... + (1/n or 1/(n-1)).
constexpr double harmonic(nat_type n)
Return the harmonic number H_n = 1/1 + 1/2 + 1/3 + 1/4 + ... + 1/n.
double harmonic_upper_bound(nat_type n)
Return an upper bound of H_n.
Definition: harmonic.cpp:134
constexpr double harmonic_odd(nat_type n)
Return 1/1 + 1/3 + 1/5 + 1/7 + ... + (1/n or 1/(n-1)).
const double euler_gamma
The Euler-Mascheroni constant 0.577215664901532860606512090082402431042... (rounded to an upper bound...
Definition: harmonic.cpp:34
double diff_harmonic_upper_bound(nat_type a, nat_type b)
Return an upper bound of H_a - H_b.
Definition: harmonic.cpp:94