How to correctly calculate the sum of this series with Mathematica?

The Mathematica code

ComplexExpand[Sum[(Integrate[1/Gamma[s]*x^(s - 1)*Exp[-x]/(1 + Exp[-2  x]) /.
s -> 4  n + 1, {x, 0, Infinity}]) -
Integrate[
1/Gamma[s]*x^(s - 1)*Exp[-x]/(1 + Exp[-2  x]) /.
s -> 4  n + 3, {x, 0, Infinity}], {n, 0, Infinity}] //FullSimplify]


outputs (\[Pi] Cosh[\[Pi]/2])/(2 (1 + Cosh[\[Pi]])) in 14.0 on Windows 10. Its numeric value equals 0.31301. This is not in accordance with the value of the fifth partial sum

Sum[(Integrate[1/Gamma[s]*x^(s-1)*Exp[-x]/(1+Exp[-2  x])/. s->4  n+1,{x,0,Infinity}])-
Integrate[1/Gamma[s]*x^(s-1)*Exp[-x]/(1+Exp[-2  x])/. s->4  n+3,{x,0,Infinity}],{n,0,5}]//N


-0.18699

It should be noticed that the series under consideration converges very quickly. The result by hand can be found here.

• Note that a much simpler way to get the same (wrong) result is to use Sum[(-1)^n DirichletBeta[2 n + 1], {n, 0, ∞}]. Feb 9 at 17:49
• It looks like something weird is going on for n = 1. For example: Sum[DirichletBeta[n], {n, 0, ∞}] stays unevaluated, while FullSimplify@Sum[DirichletBeta[n], {n, 1, ∞}] gives -(Log[2]/2) even though $\beta(x)$ is strictly increasing function. And if you want to do a simple finite sum: NSum[DirichletBeta[n], {n, 0, 2}], it complains ... Feb 9 at 18:46
• @Domen: I treat DirichletBeta as a label only. Feb 9 at 18:55

Numerically I also get the negative result.

nIntegrate[ff_, aa_, nn_?NumberQ] :=
NIntegrate[ff /. n -> nn, aa]

NSum[(nIntegrate[
1/Gamma[s]*x^(s - 1)*Exp[-x]/(1 + Exp[-2   x]) /.
s -> 4   n + 1, {x, 0, 200}, n] -
nIntegrate[
1/Gamma[s]*x^(s - 1)*Exp[-x]/(1 + Exp[-2   x]) /.
s -> 4   n + 3, {x, 0, 200}, n]), {n, 0, 20}]

(* Out[7]= -0.18699 *)


Switching the Sum and Integrate order gives the result that is 1/2 larger.

ss =
Sum[(1/Gamma[s]*x^(s - 1)*Exp[-x]/(1 + Exp[-2   x]) /.
s -> 4   n + 1) - (1/Gamma[s]*x^(s - 1)*
Exp[-x]/(1 + Exp[-2   x]) /. s -> 4   n + 3), {n, 0, Infinity}]

(* Out[8]= (E^x Cos[x])/(1 + E^(2 x)) *)

ii = Integrate[ss, {x, 0, Infinity}]

(* Out[14]= 1/4 \[Pi] Sech[\[Pi]/2] *)

N[ii]

(* Out[15]= 0.31301 *)


This appears to be incorrect however, since it disagrees with a numeric approximation.

nSum[ff_, aa_, xx_?NumberQ] := NSum[ff /. x -> xx, aa]

NIntegrate[
nSum[(1/Gamma[s]*x^(s - 1)*Exp[-x]/(1 + Exp[-2   x]) /.
s -> 4   n + 1) - (1/Gamma[s]*x^(s - 1)*
Exp[-x]/(1 + Exp[-2   x]) /. s -> 4   n + 3), {n, 0, 20},
x], {x, 0, 1000}]

(* Out[20]= -0.18699 *)

• I realize this does not answer the question. My point was to show how the wrong answer could arise and to verify numerically that it's wrong and the claimed result is correct. Feb 9 at 17:52