# Strange behaviour of infinite sum (H[n]- Series[H[n]])

Bug report filed 14.01.2020 A support case was created with the ID [CASE:4371991]

EDIT

It is easy to show that the workaround "limit of finite sum" proposed in the solution by user64494 leads to correct results for all cases shown here.

This points to a bug in Sum[...,{n,1,inf}].

Original post

A strange observation can be made looking at infinite sum over the difference between the harmonic number and some terms of its asymptotic series

a=Series[HarmonicNumber[n], {n, \[Infinity], 4}] // Normal
(* EulerGamma + Log[n] + 1/(2 n) - 1/(12 n^2) + 1/(120 n^4)  *)


Consider the following expressions and system reactions

s1 = Sum[HarmonicNumber[n] - (EulerGamma + Log[n] + 1/(2 n)), {n,
1, \[Infinity]}]
(* 1/2 (1+EulerGamma-Log[2]-Log[\[Pi]]) *)


Ok, convergence to the correct value. Now we try to improve the approximation

s2 = Sum[HarmonicNumber[
n] - (EulerGamma + Log[n] + 1/(2 n) - 1/(12 n^2)), {n,
1, \[Infinity]}]


"Sum::div: "Sum does not converge. "

Strange: a better approximation leads to divergence of the sum

s3 = Sum[HarmonicNumber[
n] - (EulerGamma + Log[n] + 1/(2 n) - 1/(12 n^2) + 1/(
120 n^4)), {n, 1, \[Infinity]}]


"Sum::div: "Sum does not converge. "

Similarly, divergence to 4th second order.

s4 = Sum[HarmonicNumber[n] - (EulerGamma + Log[n] + 1/(2 n) - (0*1)/(12 n^2) + 1/(120 n^4)), {n, 1, \[Infinity]}]
(* 1/2+EulerGamma/2-\[Pi]^4/10800+1/2 (-Log[2]-Log[\[Pi]]) *)


Strange: taking the 4th order and dropping the 2nd order leads to convergence to the correct value

This is version 10.0. In 8.0 s4 is also divergent.

Mathematica 12.0 also claims the divergence of s2. I think the defect under consideration is not hard in view of a workaround

Sum[HarmonicNumber[n] - (EulerGamma + Log[n] + 1/(2 n) - 1/(12 n^2)), {n, 1, a},
Assumptions -> a > 1]


1/12 (-12-12 a-12 a EulerGamma-6 HarmonicNumber[a]+12 HarmonicNumber[1+a]+12 a HarmonicNumber[1+a]+HarmonicNumber[a,2]-12 Log[Pochhammer[1,a]])

Limit[%, a -> Infinity]


1/72 (36 + 36 EulerGamma + [Pi]^2 - 36 Log[2 [Pi]])

• @ user64494 +1 for the proposal which narows down the location of the bug. I have taken the freedom to incorporate your workaround as in EDIT in m OP. – Dr. Wolfgang Hintze Jan 14 at 13:01