I'm calculating the Madelung constant
$$\alpha = -\sum_{n_1,n_2,n_3}{\frac{(-1)^{n_1+n_2+n_3}}{(n_1^2+n_2^2+n_3^2)^{1/2}}}$$
Where $n_1,n_2,n_3$ are any element in the integer domain and they can't be zero simutaneously. How can I do this in Mathematica? Thanks!
Answer
These sums are conditionally convergent, so you have to specify a summation order that suits your purpose. See Wikipedia. Since the question seems to be focused on the issue of dropping a term in a sum, here is one way of doing it, without making any claim that the resulting sum is of any use:
Chop[NSum[
If[i == j == k == 0, 0,
(-1)^(i + j + k)/Sqrt[i^2 + j^2 + k^2]],
{i, -Infinity, Infinity}, {j, -Infinity, Infinity}, {k, -Infinity, Infinity},
Method -> "AlternatingSigns"]]
Comments
Post a Comment