For running an N-Body simulation it is required to calculate the force between every pair of massive bodies. The force applied on body $a$ from body $b$ is calculated as follows: $$F_{ab} = -G\frac{m_am_b}{|r_{ab}|^2}\hat{r}_{ab}$$ Where $r$ is the vector from body $a$ to body $b$.
After summing the force of every body on the body $a$ we can calculate the velocity and update the location of body $a$ in space.
Now say we limit the 3D space inside a cube of width $w$, and make the world seamless so that every body that was at say $\begin{bmatrix}x_0\\y_0\\z_0\end{bmatrix}$ now repeats as follows: $$\begin{bmatrix}x_0+wi\\y_0+wj\\z_0+wk\end{bmatrix} \,;\, i,j,k \in \mathbb{Z}$$
Now for calculating force of body $b$ on body $a$ we have the following formula: $$\begin{align} F_{ab} &= -\sum_{i=-\infty}^{+\infty}{\sum_{j=-\infty}^{+\infty}{\sum_{k=-\infty}^{+\infty}{G\frac{m_am_b}{|r_{ab}|^2}\hat{r}_{ab}}}} \\\\ &= -Gm_am_b\sum_{i=-\infty}^{+\infty}{\sum_{j=-\infty}^{+\infty}{\sum_{k=-\infty}^{+\infty}{\frac{\hat{r}_{ab}}{|r_{ab}|^2}}}} \\\\ &= -Gm_am_b\sum_{i=-\infty}^{+\infty}{\sum_{j=-\infty}^{+\infty}{\sum_{k=-\infty}^{+\infty}{\frac{r_{ab}}{|r_{ab}|^3}}}} \\\\ &= -Gm_am_b\sum_{i=-\infty}^{+\infty}{\sum_{j=-\infty}^{+\infty}{\sum_{k=-\infty}^{+\infty}{\frac{\begin{bmatrix}x_b-x_a+wi\\y_b-y_a+wj\\z_b-z_a+wk\end{bmatrix}}{\biggl((x_b-x_a+wi)^2+(y_b-y_a+wj)^2+(z_b-z_a+wk)^2\biggr)^{3/2}}}}} \\\\ &= -Gm_am_b\sum_{i=-\infty}^{+\infty}{\sum_{j=-\infty}^{+\infty}{\sum_{k=-\infty}^{+\infty}{\frac{\begin{bmatrix}\Delta{x}+wi\\\Delta{y}+wj\\\Delta{z}+wk\end{bmatrix}}{\biggl((\Delta{x}+wi)^2+(\Delta{y}+wj)^2+(\Delta{z}+wk)^2\biggr)^{3/2}}}}} \end{align}$$
Now the questions are:
- Does such summation converge?
- Can this summation be simplified to a closed form formula?