4
$\begingroup$

I was trying to compute the following sum:

$$\phi(x,y)=\frac{1}{4\pi^2}\sum_{(n,m)\neq(0,0)}\frac{1}{n^2+m^2}\exp(i(nx+my))$$ where the range of indices is, say, $-10\leq n, \,m\leq 10$.

But I don't know how to "encode" the condition $(n,m)\neq(0,0)$ into Mathematica. I tried this:

phi[x, y] = (1/(4 Pi^2)) Sum[(1/(n^2 + m^2))*Exp[I*(n*x + m*y)], {n, -10, 10}, 
                             {m, -10, 10}, n^2+m^2>0]

but it didn't work.

Thanks for any help!


Thanks everyone. I tried to use If statement inside the Sum command, and it worked. Here it is:

phi[x, y] = 1/(4 Pi^2) Sum[ If[0 < n^2 + m^2, 1/(n^2 + m^2) Exp[I*(n*x + m*y)], 0], 
             {n, -10, 10}, {m, -10, 10}]
$\endgroup$
  • 3
    $\begingroup$ {n, DeleteCases[Range[-10, 10], 0]} ? $\endgroup$ – Algohi Apr 7 '16 at 20:39
  • 1
    $\begingroup$ You could just put an If statement inside your sum: If[n^2 + m^2 == 0, 0, ...]. $\endgroup$ – wxffles Apr 7 '16 at 20:50
6
$\begingroup$

One can reformulate slightly

nmx = 3
1/π^2 Sum[1/(n^2 + m^2) Cos[n x] Cos[m x], {n, 1, nmx}, {m, 1, mmx}]

Interestingly, when x=$\pi$ the sum with infinite limits can be computed

1/π^2 Sum[1/(n^2 + m^2) Cos[n π] Cos[m π], {n, 1, ∞}, {m, 1, ∞}]
(*1/12 1/π^2 (π^2 - π Log[8])*)
$\endgroup$
  • $\begingroup$ Hi yarchik, what does nmx do here? I think we still have $(n,m)=(0,0)$ here, which is not what I want. $\endgroup$ – mori39 Apr 8 '16 at 2:32
  • 2
    $\begingroup$ @mori, look at the limits of yarchik's sum carefully, and recall the exponential formula for cosine. $\endgroup$ – J. M. will be back soon Apr 8 '16 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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