Suppose that in a nxn grid, we choose a lattice point and took the sum of the distances from that point to every other lattice point in the grid (including the edge points) and then divide the sum by n^2. We then do the same thing so that the "center" is at another point and do this for all points in the grid and take the average. Let a_n be defined as the average for the nxn grid multiplied by 2/n. I ran a python script and from the first 75 terms in this sequence, it looks like it's converging to 1.043 or it's just diverging very slowly. Does the sequence converge and is there a way to find an explicit formula for a_n?
def center_Distance(n,m, x, y):
total = 0
for i in range(n):
for j in range(m):
total += ((x-i)**2 + (y-j)**2)**0.5
return total/(n*m)
li = []
mi = []
M = 75
for i in range(1, M):
#li will contain the sum of the distances for each center
li = []
for k in range(i):
for m in range(i):
li.append(center_Distance(i, i, k, m))
# find average of li and multiply by 2/i
total = 2*sum(li)/(len(li)*i)
print(total)