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$.



How to estimate a specific infinite matrix sum
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.


