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?
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.
$\endgroup$
Commented
Apr 2, 2021 at 13:46
-1 + EllipticTheta[3, 0, x]^2
is a formal result since the series under consideration diverges if Abs[x]>1
.
$\endgroup$
Commented
Apr 2, 2021 at 13:52
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.
You can do
Sum[If[n == 0 && m == 0,0, f[m,n]],{m,-Infinity,Infinity},{n,-Infinity,Infinity}]
f[0,0]
is defined, thenSum[f[m,n],{m,-Infinity,Infinity},{n,-Infinity,Infinity}]-f[0,0]
. If not, then trySum[f[m,n]*(1-KroneckerDelta[m,,n],{m,-Infinity,Infinity},{n,-Infinity,Infinity}]
. $\endgroup$f[n_,k_]:=1/(n+I*k)^2
, but my code seems faster. $\endgroup$