HP Forums
(12C) Find the Nth Harmonic number - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Find the Nth Harmonic number (/thread-18281.html)



(12C) Find the Nth Harmonic number - Gamo - 04-20-2022 01:03 PM

Information about Harmonic Number

https://en.wikipedia.org/wiki/Harmonic_number

Instead of calculating the sum of the reciprocals of the first N natural numbers

n
1 + Σ (1/x) with this summation its easy to do on some calculator that already
x=2

have this Summation Function with this program the computation speed

is fast since it doesn't have to continue sum up all the needed reciprocals from 2 up to N

----------------------------------------------------
Example: Find 50th of the Harmonic Number

50 [R/S] display answer ≈ 4.499

----------------------------------------------------
Program:
Code:

STO 0
1/x
ENTER ENTER ENTER  // press [ENTER] three times
120
1/x

x
12
1/x
-
x
2
1/x
+
x
.5772156649  // this is Euler's Constant
+
RCL 0
LN
+

Gamo

Remark:
The Summation Formular above can be use to test on Casio fx-911ex as shown above.


RE: (12C) Find the Nth Harmonic number - Albert Chan - 04-20-2022 07:04 PM

There was a thread about Harmonic numbers, Cut the cards

lua> n = 50
lua> x = n+0.5
lua> gamma = 0.5772156649015329

H(n) = Ψ(n+1) + gamma = Ψ((x=n+0.5) + 0.5) + gamma

(08-28-2020 09:26 PM)Albert Chan Wrote:  \(\qquad\qquad\exp( \psi(x+1/2)) = x
+\frac{1}{24 \cdot x
+\Large\frac{1}{\frac{10}{37} \cdot x
+\frac{1}{\frac{689976}{74381} \cdot x \;
+\; \cdots}}} \)

lua> h = log(x + 1/(24*x + 3.7/x)) + gamma
lua> h
4.499205338329271

Inverse-Harmonic, from h=H(n), to recover n

lua> k = exp(h - gamma)
lua> k - 1/(24*k + 2.7/k) - .5
49.99999999999862

There is a reason "recover" constant is 2.7. See if you can figure it out ...
Hint: 2.7 = 3.7 - 1