Research Article | | Peer-Reviewed

### Maximizing Efficiency in the Computation of Generalized Harmonic Numbers Through Recursive Binary Splitting

Received: 22 January 2024     Accepted: 2 April 2024     Published: 21 April 2024
Abstract

In this article, an efficient algorithm is implemented in Mathematica for the exact calculation of Generalized Harmonic Numbers (GHN). This is achieved through the combination of two methods. The first method is binary division, where terms formed by the powers of the reciprocals of odd and even numbers are summed separately. The second method is a recursive function that iterates the same sequence of operations until all calculations are completed. Within each cycle, the algorithm processes half of the remaining terms, a feature that significantly improves its efficiency. The computer code is notably concise, consisting of only 11 lines, depending on how they are counted. A remarkable event occurs when the argument is a power of two, as the code condenses into a single line. The most distinctive feature of this algorithm lies in the fact that to calculate the GHN for an argument ‘n’, it requires only the terms formed by the reciprocals of odd numbers. This provides a clear advantage over algorithms that use the complete numerical sequence of the reciprocals of all numbers from 1 to n. An intriguing aspect of this algorithm, is the unexpected discontinuity in the powers of two within the denominators of the common factors across each layer. Contrary to expected, these do not form a continuous sequence from 0 to number of layers − 1.

 Published in Pure and Applied Mathematics Journal (Volume 13, Issue 1) DOI 10.11648/j.pamj.20241301.12 Page(s) 9-16 Creative Commons This is an Open Access article, distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution and reproduction in any medium or format, provided the original work is properly cited. Copyright Copyright © The Author(s), 2024. Published by Science Publishing Group
Keywords

Generalized Harmonic Numbers, Recursive Function, Binary Splitting

References
 [1] Dunham, W. Journey through Genius: Great Theorems of Mathematics. New York, NY: John Wiley & Sons, Inc; 1990, 300 pp. [2] Burić, T., Elezović, N. Approximants of the Euler– Mascheroni constant and harmonic numbers. Applied Mathematics and Computation. 2013, 222(2013). URL [3] Bil, R., Laue, H. Investigations About the Euler– Mascheroni Constant and Harmonic Numbers. Analysis. 2016, 36(4). URL [4] Arakawa, T., Ibukiyama, T., Kaneko, M. Bernoulli Numbers and Zeta Functions. New York, NY: Springer-Verlag; 2014, 274 pp. URL [5] Debnath, L. A. A Brief History of the Most Remarkable Numbers e, i and γ in Mathematical Sciences with Applications. International Journal of Applied and Computational Mathematics. 2015, 1(2015). URL [6] Dence, T. P., Dence, J. B. A Survey of Euler’s Constant. Mathematics Magazine. 2009, 82(4). URL [7] Havil, J. Gamma: Exploring Euler’s Constant. Princeton, New Jersey: Princeton University Press; 2003, 300 pp. [8] Mariconda C., Tonolo A. Discrete Calculus: Methods for Counting. Cham, Switzerland: Springer International Publishing; 2016, 659 pp. URL [9] Sondow, J., Weisstein, E. W. Harmonic Number. Available from: [10] Debnath, L. A. A Brief History of the Most Remarkable Numbers π, g and δ in Mathematical Sciences with Applications. International Journal of Mathematical Education in Science and Technology. 2015, 46(6). URL [11] Costabile, F., Dell’Accio, F., Gualtieri, M. I. A New Approach to Bernoulli Polynomials. Rendiconti di Matematica . 2006, 26(2006). URL [12] Conway, J. H., Guy, R. K. The Book of Numbers. New York, NY: Springer-Verlag; 1996, 310 pp. URL [13] Villarino, M-B. Ramanujan’s Harmonic Number Expansion Into Negative Powers of a Triangular Number. Journal of Inequalities in Pure and Applied Mathematics. 2008, 9(2008). URL [14] Johansson F. How (not) to compute harmonic numbers. Available from: [15] Choi, J., Chen, C. P. Certain Relationships Among Polygamma Functions, Riemann Zeta Function and Generalized Zeta Function. Journal of Inequalities and Applications. 2013, 75(2013). URL
• APA Style

Palacios-Vélez, O. L., Pedraza-Oropeza, F. J. A. (2024). Maximizing Efficiency in the Computation of Generalized Harmonic Numbers Through Recursive Binary Splitting. Pure and Applied Mathematics Journal, 13(1), 9-16. https://doi.org/10.11648/j.pamj.20241301.12

ACS Style

Palacios-Vélez, O. L.; Pedraza-Oropeza, F. J. A. Maximizing Efficiency in the Computation of Generalized Harmonic Numbers Through Recursive Binary Splitting. Pure Appl. Math. J. 2024, 13(1), 9-16. doi: 10.11648/j.pamj.20241301.12

AMA Style

Palacios-Vélez OL, Pedraza-Oropeza FJA. Maximizing Efficiency in the Computation of Generalized Harmonic Numbers Through Recursive Binary Splitting. Pure Appl Math J. 2024;13(1):9-16. doi: 10.11648/j.pamj.20241301.12

• ```@article{10.11648/j.pamj.20241301.12,
author = {Oscar Luis Palacios-Vélez and Felipe José Antonio Pedraza-Oropeza},
title = {Maximizing Efficiency in the Computation of Generalized Harmonic Numbers Through Recursive Binary Splitting},
journal = {Pure and Applied Mathematics Journal},
volume = {13},
number = {1},
pages = {9-16},
doi = {10.11648/j.pamj.20241301.12},
url = {https://doi.org/10.11648/j.pamj.20241301.12},
eprint = {https://article.sciencepublishinggroup.com/pdf/10.11648.j.pamj.20241301.12},
abstract = {In this article, an efficient algorithm is implemented in Mathematica for the exact calculation of Generalized Harmonic Numbers (GHN). This is achieved through the combination of two methods. The first method is binary division, where terms formed by the powers of the reciprocals of odd and even numbers are summed separately. The second method is a recursive function that iterates the same sequence of operations until all calculations are completed. Within each cycle, the algorithm processes half of the remaining terms, a feature that significantly improves its efficiency. The computer code is notably concise, consisting of only 11 lines, depending on how they are counted. A remarkable event occurs when the argument is a power of two, as the code condenses into a single line. The most distinctive feature of this algorithm lies in the fact that to calculate the GHN for an argument ‘n’, it requires only the terms formed by the reciprocals of odd numbers. This provides a clear advantage over algorithms that use the complete numerical sequence of the reciprocals of all numbers from 1 to n. An intriguing aspect of this algorithm, is the unexpected discontinuity in the powers of two within the denominators of the common factors across each layer. Contrary to expected, these do not form a continuous sequence from 0 to number of layers − 1.},
year = {2024}
}
```
• ```TY  - JOUR
T1  - Maximizing Efficiency in the Computation of Generalized Harmonic Numbers Through Recursive Binary Splitting
AU  - Oscar Luis Palacios-Vélez
AU  - Felipe José Antonio Pedraza-Oropeza
Y1  - 2024/04/21
PY  - 2024
N1  - https://doi.org/10.11648/j.pamj.20241301.12
DO  - 10.11648/j.pamj.20241301.12
T2  - Pure and Applied Mathematics Journal
JF  - Pure and Applied Mathematics Journal
JO  - Pure and Applied Mathematics Journal
SP  - 9
EP  - 16
PB  - Science Publishing Group
SN  - 2326-9812
UR  - https://doi.org/10.11648/j.pamj.20241301.12
AB  - In this article, an efficient algorithm is implemented in Mathematica for the exact calculation of Generalized Harmonic Numbers (GHN). This is achieved through the combination of two methods. The first method is binary division, where terms formed by the powers of the reciprocals of odd and even numbers are summed separately. The second method is a recursive function that iterates the same sequence of operations until all calculations are completed. Within each cycle, the algorithm processes half of the remaining terms, a feature that significantly improves its efficiency. The computer code is notably concise, consisting of only 11 lines, depending on how they are counted. A remarkable event occurs when the argument is a power of two, as the code condenses into a single line. The most distinctive feature of this algorithm lies in the fact that to calculate the GHN for an argument ‘n’, it requires only the terms formed by the reciprocals of odd numbers. This provides a clear advantage over algorithms that use the complete numerical sequence of the reciprocals of all numbers from 1 to n. An intriguing aspect of this algorithm, is the unexpected discontinuity in the powers of two within the denominators of the common factors across each layer. Contrary to expected, these do not form a continuous sequence from 0 to number of layers − 1.
VL  - 13
IS  - 1
ER  - ```
Author Information
• Hidrosciences Department, Graduate College, Montecillo, Mexico

• Hidrosciences Department, Graduate College, Montecillo, Mexico

• Sections