Curious relation between $e$ and $\pi$ that produces almost integers I have seen in an article, without proof, that the following expression involving $e$ and $\pi$ is an almost integer very close to 1:
$ e^{-\frac{\pi}{9}} + e^{-4\frac{\pi}{9}} + e^{-9\frac{\pi}{9}} + e^{-16\frac{\pi}{9}} + e^{-25\frac{\pi}{9}} + e^{-36\frac{\pi}{9}} + e^{-49\frac{\pi}{9}} + e^{-64\frac{\pi}{9}} = 1.0000000000010504... $
Furthermore, I have read that the following "approximate theorem" holds
If $n$ is an odd square, then 
$\sum\limits_{k = 1}^{n-1} e^{-k^2\frac{\pi}{n}}$  
is an almost integer. By some experiments I see easily that the integer being approximated is 
($\sqrt{n} - 1)/2$
How to prove that this curious relation holds?
 A: This comes from the identity
$$ \sum_{m=-\infty}^\infty e^{-\pi m^2 x} = x^{-1/2} \sum_{n=-\infty}^\infty e^{-\pi n^2/x} $$
Take $x = 1/9$, and note that $\exp(-9 \pi n^2)$ is very small except for $n=0$, while $\exp(-\pi n^2/9)$ is small for $|n| > 8$.
A: Using the identity provided by Robert Israel (which can be derived using the Poisson summation formula), we have $$\sum_{k = -\infty}^{\infty}e^{-k^2\tfrac{\pi}{n}} = \sum_{k = -\infty}^{\infty}\sqrt{n}e^{-n\pi k^2}.$$
We can bound the second summation by: $$\sqrt{n} \le \displaystyle\sum_{k = -\infty}^{\infty}\sqrt{n}e^{-n\pi k^2} = \sqrt{n}+2\sqrt{n}\displaystyle\sum_{k = 1}^{\infty}e^{-n\pi k^2} \le \sqrt{n}+2\sqrt{n}\displaystyle\sum_{k = 1}^{\infty}e^{-n\pi k} = \sqrt{n} + \dfrac{2\sqrt{n}}{e^{n\pi}-1}.$$
Also, we can bound the tails of the first summation by:
$$2e^{-n\pi} \le \displaystyle\sum_{|k| \ge n}e^{-k^2\tfrac{\pi}{n}} = 2\displaystyle\sum_{k = n}^{\infty}e^{-k^2 \tfrac{\pi}{n}} \le 2\displaystyle\sum_{k = n}^{\infty}e^{-nk \tfrac{\pi}{n}} = \dfrac{2e^{-n\pi}}{1-e^{-\pi}}.$$
Hence, $$\displaystyle\sum_{k = -(n-1)}^{n-1}e^{-k^2\tfrac{\pi}{n}} = \sum_{k = -\infty}^{\infty}\sqrt{n}e^{-n\pi k^2} - \displaystyle\sum_{|k| \ge n}e^{-k^2\tfrac{\pi}{n}}$$ can be bounded by $$\sqrt{n}-\dfrac{2e^{-n\pi}}{1-e^{-\pi}} \le \displaystyle\sum_{k = -(n-1)}^{n-1}e^{-k^2\tfrac{\pi}{n}} \le \sqrt{n} + \dfrac{2\sqrt{n}}{e^{n\pi}-1}-2e^{-n\pi}.$$
To bound $\displaystyle\sum_{k = 1}^{n-1}e^{-k^2\tfrac{\pi}{n}}$, simply subtract $1$ (for the $k = 0$ term) and divide by $2$ (since the $-k$-th term and the $k$-th term are equal) to get 
$$\dfrac{\sqrt{n}-1}{2}-\dfrac{e^{-n\pi}}{1-e^{-\pi}} \le \displaystyle\sum_{k = 1}^{n-1}e^{-k^2\tfrac{\pi}{n}} \le \dfrac{\sqrt{n}-1}{2} + \dfrac{\sqrt{n}}{e^{n\pi}-1}-e^{-n\pi}.$$
Thus, the error in approximating $\dfrac{\sqrt{n}-1}{2}$ is at most $\max\left\{\dfrac{e^{-n\pi}}{1-e^{-\pi}},\dfrac{\sqrt{n}}{e^{n\pi}-1}-e^{-n\pi}\right\}$. For $n = 9$, this is roughly $1.051\times 10^{-12}$.
