NSum returns the wrong value
NSum returns the wrong value
The following infinite sum should have the value 2:
In[]:=
two[n_]:=NSum,{k,n}
16-32k-4(4k-3)(16-1)
k
(-1)
2
k
(2k-1)(4k-3)(16-1)
2
k
In[]:=
two[1]
Out[]=
2.93333
In[]:=
two[10000]
Out[]=
2.00015
In[]:=
two[∞]
Out[]=
2.00025
I compute this sum with Python:
In[]:=
def two(n):
s = 0.0
for k in range(1,n+1):
s += (16-32*k-4*(-1)**k*(4*k-3)*(16*k*k-1))/((2*k-1)*(4*k-3)*(16*k*k-1))
return s
s = 0.0
for k in range(1,n+1):
s += (16-32*k-4*(-1)**k*(4*k-3)*(16*k*k-1))/((2*k-1)*(4*k-3)*(16*k*k-1))
return s
Out[]=
ExternalFunction
In[]:=
two(1)
Out[]=
2.93333
In[]:=
two(10000)
Out[]=
1.9999
In[]:=
two(1000000)
Out[]=
2.
As you see, I get the correct result in python.