2

I am using Mathematica 8.0.1.0. I defined the following function for use in an answer on math.SE:

`f[j_] := Sum[1/(j-2k+1)/4^k, {k, 0, Floor[j/2]}]`

I then used this function in

`NSum[(-1)^i f[i], {i, 0, 7}, WorkingPrecision -> 20]`

I was expecting a positive answer, but got `-0.83296130952380952381`

, whereas

`N[f[0]-f[1]+f[2]-f[3]+f[4]-f[5]+f[6]-f[7], 20]`

gives `0.83296130952380952381`

which is the answer I expected.

If I define the function as

`f[j_] := Evaluate[Sum[1/(j-2k+1)/4^k, {k, 0, Floor[j/2]}]]`

then `f[0]`

yields `1/8 (4 ArcTanh[1/2] - 4 (2 + ArcTanh[1/2]))`

which simplifies to `-1`

. This is very surprising since `f[0]`

is a sum of positive values. In fact, `Simplify[f[k]]`

gives the negative of what the answer should be, at least for the integers `k`

that I have tried. This possibly narrows down where the problem lies when I use the original function in `NSum`

Is this a problem with version 8.0.1.0, or is this reproducible in more recent versions of Mathematica?

There is a second problem when I use the original function in

`NSum[(-1)^k f[k], {k, 0, 7}, WorkingPrecision -> 20]`

I get the errors

`Power::infy: Infinite expression 1/0 encountered. >>`

and

`NSum::nsnum: Summand (or its derivative) (-1)^k f[k] is not numerical at point k = 0. >>`

I don't understand these errors. I thought the local variable names were treated as if used in `Block`

, so I don't see why the `k`

in the definition of the function should interfere.

1Looks like a bug in

`Sum`

(for`f[j]`

). I get the negative sum in V11.2. – Michael E2 – 2018-03-03T20:21:06.997@MichaelE2: Thanks for the verification! I was getting a similar negative result for another sum yesterday, so I was worried my computer was possessed. – robjohn – 2018-03-03T20:37:14.770