# How to sum over $\mathbb{Z} \times \mathbb{Z} \setminus \{(0,0)\}$? [closed]

I want to sum over $$\mathbb{Z} \times \mathbb{ Z} \setminus \{(0,0)\}$$ . So, something like

Sum[f[m,n],{m,-Infinity,Infinity},{n,-Infinity,Infinity}]


but I want to exclude f[0,0] as infinities might appear.

Any suggestions?

• If f[0,0] is defined, then Sum[f[m,n],{m,-Infinity,Infinity},{n,-Infinity,Infinity}]-f[0,0]. If not, then try Sum[f[m,n]*(1-KroneckerDelta[m,,n],{m,-Infinity,Infinity},{n,-Infinity,Infinity}]. Apr 1, 2021 at 10:36
• Sadly it is not defined. Apr 1, 2021 at 10:38
• Can you remove the singularity (by adding $+i\eta$ in the denominator, for example)? Then, after analytic summing over the entire $\mathbb{Z}\times\mathbb{Z}$, subtract $f(0,0)$ and then take the limit $\eta\to0^+$. Apr 1, 2021 at 11:08
• Thanks, will try this; Apr 1, 2021 at 11:16
• @Roman: The same results are produced by your approach and mine for f[n_,k_]:=1/(n+I*k)^2, but my code seems faster. Apr 1, 2021 at 12:12

I suggest using a function

sumZZ0[f_, M_:Infinity] := (
Sum[f[n, k], {n, M}, {k, 0, M}]
+ Sum[f[k, -n], {n, M}, {k, 0, M}]
+ Sum[f[-n, -k], {n, M}, {k, 0, M}]
+ Sum[f[-k, n], {n, M}, {k, 0, M}]);


This code may or may not help you depending on which f[n,k] you want to sum. If the original sum is not absolutely convergent, then splitting the sum into four sums may not give correct results.

As a simple example, using sumZZ0[(#1 + #2 I)^-4 &] to evaluate the Eisenstein series $$G_4(i)$$ does not produce a useful result. However, the code

Sum[Piecewise[{{(n + k I)^-4, n^2 + k^2 != 0}, {0, True}}],
{n, -Infinity, Infinity}, {k, -Infinity, Infinity}]


does produce a useful result after a few seconds.

Still, an example that works is sumZZ0[x^(#1^2 + #2^2) &] which returns -1 + EllipticTheta[3, 0, x]^2 as it should in under a second. The code

 Sum[If[n == 0 && k == 0, 0, x^(n^2 + k^2)],
{n, -Infinity, Infinity}, {k, -Infinity, Infinity}]


takes much longer to produce the same result. Also, using the Piecewise method takes even longer.

• Sum[Piecewise[{{x^(m^2 + n^2), m^2 + n^2 != 0}, {0, True}}], {m, -Infinity, Infinity}, {n, -Infinity, Infinity}] also returns -1 + EllipticTheta[3, 0, x]^2., though slowly. This example is shooting a cannon at sparrows. Apr 2, 2021 at 13:46
• I'd like to add that -1 + EllipticTheta[3, 0, x]^2 is a formal result since the series under consideration diverges if Abs[x]>1. Apr 2, 2021 at 13:52
• In fact, this is my approach, onlly expressed by a complicated and uncommented code. I don't see any advantage. Apr 2, 2021 at 14:09

Instead of dealing with indices, try

Sum[Piecewise[{{f[m, n], m^2 + n^2 != 0}, {0, True}}], {m, -Infinity,  Infinity}, {n, -Infinity, Infinity}]


It should be noticed the notation n,k is preferable over n,m which are similar.

• Yes, it works in general. But, sadly not in my case... Other problems. Apr 1, 2021 at 12:01
Sum[If[n == 0 && m == 0,0, f[m,n]],{m,-Infinity,Infinity},{n,-Infinity,Infinity}]