Talk:Harmonic series: Difference between revisions

From Rosetta Code
Content added Content deleted
(Added noted about required accuracy.)
 
(Oops, forgot to sign.)
 
Line 27: Line 27:
cf h[12366] = 9.9999621479216
cf h[12366] = 9.9999621479216
</pre>
</pre>
--PureFox (talk) 10:58, 27 May 2021 (UTC)

Latest revision as of 11:07, 27 May 2021

Note for those whose languages lack fast 'big rational' arithmetic

Even for the stretch goal, it is accurate enough to use 64-bit floating point arithmetic, rather than big rational arithmetic (which takes 'forever' in Wren), to calculate the first harmonic number greater than the given integer.

This is easily tested by examining the terms previous to the ones which this approach gives. Apart from the first one, it will be seen that these are all 'well below' the integers involved to 14 digit accuracy.

The first harmonic number to exceed the following integers is:
integer =  1  -> n =      2  ->  harmonic number =  1.500000 (to 6dp)
cf h[1] = 1
integer =  2  -> n =      4  ->  harmonic number =  2.083333 (to 6dp)
cf h[3] = 1.8333333333333
integer =  3  -> n =     11  ->  harmonic number =  3.019877 (to 6dp)
cf h[10] = 2.9289682539683
integer =  4  -> n =     31  ->  harmonic number =  4.027245 (to 6dp)
cf h[30] = 3.9949871309204
integer =  5  -> n =     83  ->  harmonic number =  5.002068 (to 6dp)
cf h[82] = 4.9900200799091
integer =  6  -> n =    227  ->  harmonic number =  6.004367 (to 6dp)
cf h[226] = 5.999961422002
integer =  7  -> n =    616  ->  harmonic number =  7.001274 (to 6dp)
cf h[615] = 6.9996507205108
integer =  8  -> n =  1,674  ->  harmonic number =  8.000486 (to 6dp)
cf h[1673] = 7.9998882004307
integer =  9  -> n =  4,550  ->  harmonic number =  9.000208 (to 6dp)
cf h[4549] = 8.9999882827113
integer = 10  -> n = 12,367  ->  harmonic number = 10.000043 (to 6dp)
cf h[12366] = 9.9999621479216

--PureFox (talk) 10:58, 27 May 2021 (UTC)