TITLE: How to estimate a specific infinite matrix sum
QUESTION [6 upvotes]: Let $M$ be an $n$ by $n$ matrix with each diagonal element equal to $k$ and each non-diagonal element equal to $k-1$ where $n$ and $k$ are positive integers. Let $k < n$ and we can assume both $k$ and $n$ are large.
What is
$$S_{M,k} = \sum_{x \in \mathbb{Z}^n} e^{-x^T M x}\;?$$
Is there some way to estimate this sum?
This was also posted to https://math.stackexchange.com/questions/1741157/how-to-estimate-a-specific-infinite-sum a few days ago.
Added examples
If $k=1$ we know $S_{M,1} \approx (\sqrt{\pi} +2\sqrt{n}e^{-\pi^2})^n \approx 1.7726372048^n$.  I don't know a closed form approximation for any other value of $k$.
For $n=12$ and $k = 1, \dots, 12$ using computer code to approximate the sum we get $ 962.58329951, 267.409968069, 196.186732001, 171.404195004, 162.313077353, 158.96911585, 157.738949838, 157.286397212, 157.119912408, 157.058666071, 157.036134803, 157.027846013$.
In general it seems numerically that for every fixed $n$, $S_{M,k}$ converges fairly quickly to some value as $k$ increases towards $n$.

REPLY [4 votes]: Let $s = k-1$, and write $x^T M x = \|x\|^2 + s (e \cdot x)^2$ where $e = (1,\ldots,1)$.  Let $P_j = \{x \in \mathbb Z^n: e \cdot x = j\}$. Each $P_j$ is a translate of $P_0$, which is a subgroup of $\mathbb Z^n$.  Then
$$S_{M,k} = \sum_{j\in \mathbb Z} e^{-s j^2} \sum_{x \in P_j} e^{-\|x\|^2} = \sum_{j \in \mathbb Z} e^{-s j^2} T(j)$$
where $T(j) = \sum_{x \in P_j} e^{-\|x\|^2}$.
Now $P_{j+n} = e + P_j$, and if $x \in P_j$ we have $\|e + x\|^2 = n + 2 j + \|x\|^2$.  Thus
$$T(n+j) = e^{-n-2j} T(j)$$
so that $$T(mn + j) = e^{-m^2 n - 2 mj} T(j)$$
We just have to compute (or approximate) $T(0), \ldots, T(n-1)$, and 
then
$$\eqalign{S_{M,k} &= \sum_{j=0}^{n-1} \sum_{m \in \mathbb Z} e^{-s(j+mn)^2} e^{-m^2n-2mj} T(j)  = \sum_{j=0}^{n-1} e^{-sj^2} T(j) \sum_{m \in \mathbb Z}
e^{-(n^2s+n) m(m+2j/n)}\cr
&= \sum_{j=0}^{n-1} e^{-sj^2} T(j) \theta_3(i(ns+1)j, \exp(-n^2 s))}  $$ 
where $\theta_3$ is a Jacobi theta function.