I want to evaluate the following double summation

Sum[(-1)^(i + j + i*j)*Exp[-Pi/2*( i^2 + j^2)], {i, -Infinity, 
  Infinity}, {j, -Infinity, Infinity}]

I am really new both in using Mathematica and in doing mathematics using computer. I don't know if there is some special technics to deal with these kind of summations (Lattice sums) in Mathematica.

When I evaluate the former expression, Mathematica refuses to evaluate it and just reprint it in the output.

Theoretically, the expected value is 0.


2 Answers 2



You can try out numerical summation NSum,

NSum[(-1)^(i + j + i*j)*Exp[-Pi/2*(i^2 + j^2)], {i, -Infinity, Infinity},
 {j, -Infinity, Infinity}]

which after some warnings gives an output,

-2.22045*10^-16 - 1.04284*10^-68 I

If we increase the WorkingPrecision, will be able to get the desired result,

NSum[(-1)^(i + j + i*j)*Exp[-Pi/2*(i^2 + j^2)], {i, -Infinity, Infinity}, 
{j, -Infinity, Infinity}, Method -> "AlternatingSigns", WorkingPrecision -> 30]




As suggested by @AccidentalFourierTransform, we "can use the option, Method -> "AlternatingSigns" to speed up the computation and remove the warnings".


Maple's sum(sum(f(k,l), k=m..n),l=m..n) command is able to directly compute the double sum,

Sum(Sum((-1)^(i + j + i*j)*exp(-Pi/2*( i^2 + j^2)), i=-infinity..infinity),


  • $\begingroup$ Thank you both for the quick feedback. Now using the numerical approach, is there a way to test if the actual limit is 0? $\endgroup$ Commented Feb 26, 2017 at 17:05
  • $\begingroup$ @AymaneFihadi What you mean by actual limit? $\endgroup$
    – zhk
    Commented Feb 26, 2017 at 17:08
  • $\begingroup$ @ As I mentioned in my question, the limit of the above series is 0. I want to test that using Mathematica. By your valuable answer, we get that the limit value is around 0, as far as I understand there is possibly a way to make sure that this limit is actually 0 ? $\endgroup$ Commented Feb 26, 2017 at 17:17
  • $\begingroup$ @AymaneFihadi Rationalize[0.*10^-30]=0. BTW, Maple also gives zero. $\endgroup$
    – zhk
    Commented Feb 26, 2017 at 17:19
  • $\begingroup$ OK, Thank you very much. I will tag this answer as Accepted later, in the hope if there is some other insight concerning doing lattice sums in general. $\endgroup$ Commented Feb 26, 2017 at 17:24

It is possible to do this sum in MA. Let us look at the function and its domain:

fig1 = MatrixPlot[Table[(-1)^(i + j + i j) Exp[-Pi/2*(i^2 + j^2)], {i, -10, 10}, {j, -10, 10}]];
fig2 = MatrixPlot[ Table[(-1)^(i + j + i j) , {i, -10, 10}, {j, -10, 10}]];
fig = GraphicsRow[{fig1, fig2}]

enter image description here

This suggests to split the sum as follows:

r1 = Sum[Exp[-Pi/2*((2 ki)^2 + (2  kj)^2)], {ki, -Infinity, Infinity}, {kj, -Infinity, Infinity}]
(*EllipticTheta[3, 0, E^(-2 Pi)]^2*)
r2 = Sum[Exp[-Pi/2*((2 ki + 1)^2 + (2  kj + 1)^2)], {ki, -Infinity, Infinity}, {kj, -Infinity, Infinity}]
 (*EllipticTheta[2, 0, E^(-2 Pi)]^2*)
r3 = Sum[Exp[-Pi/2*((2 ki)^2 + (2  kj + 1)^2)], {ki, -Infinity, Infinity}, {kj, -Infinity, Infinity}]
 (*EllipticTheta[2, 0, E^(-2 Pi)] EllipticTheta[3, 0, E^(-2 Pi)]*)

At the end we can numerically verify a nice identity between the elliptic functions

$\vartheta _3\left(0,e^{-2 \pi }\right){}^2-\vartheta _2\left(0,e^{-2 \pi }\right){}^2-2 \vartheta _3\left(0,e^{-2 \pi }\right) \vartheta _2\left(0,e^{-2 \pi }\right)=0$

  N[r1 - r2 - 2 r3]//Chop
  • $\begingroup$ Thank you very much, This is a nice idea. when I was trying to calculate this by pen, I was doing the same splitting of the lattice. btw when I said its theoretically 0, they link it with sigma of Weierstrass, and use some sophisticated argument, it is not direct. $\endgroup$ Commented Feb 28, 2017 at 10:20
  • $\begingroup$ From formula 8 and 14 here, we find that $$\frac{\vartheta _2\left(0,e^{-2 \pi}\right)^2}{\vartheta _3\left(0,e^{-2 \pi}\right)^2}=3-2\sqrt 2$$ With this, the last identity in this answer can be easily verified. $\endgroup$ Commented Oct 4, 2018 at 9:35
  • $\begingroup$ @J.M.issomewhatokay. Nice find ! $\endgroup$
    – yarchik
    Commented Oct 4, 2018 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.