# Determinant of a block matrix with many $-1$'s

For an array $$(n_1,...,n_k)$$ of non-negative integers and non-zero reals $$a_1,...,a_k$$, define a block matrix $$M$$ of size $$n=n_1+\cdots+n_k$$ as follows: The main diagonal has blocks of sizes $$n_i$$ and shapes $$M_i=J_{n_i}+a_i I_{n_i}=\begin{pmatrix} a_i+1&1&\cdots&1\\ 1&a_i+1&\ddots&\vdots\\ \vdots&\ddots&\ddots&1\\ 1&1&1&a_i+1\\ \end {pmatrix}$$ and all the other entries are $$-1$$.
Experimentally I have found $$\det(M)= \prod_{i=1}^k a_i^{n_i}\sum_{j=0}^k(2-j)2^{j-1}e_j =\prod a_i^{n_i}(1+e_1-4e_3-16e_4-48e_5-\cdots),$$ where $$e_j$$ is the $$j^{th}$$ elementary symmetric function of $$\dfrac{n_1}{a_1},\dots,\dfrac{n_k}{a_k}$$.
It should be a bit technical but not too hard to prove that by induction, but is there a more elegant way?

We have $$M = D - e e^T$$, where $$D$$ is a block diagonal matrix with main diagonals equal to $$D_i = \mathrm{diag}(a_i) + 2 J_i$$, and $$e$$ is all ones vector with suitable dimention. By Matrix determinant lemma we have $$\det(M) = (1- e^TD^{-1}e) \det(D)$$ and $$\det(D) = \prod_i\det(D_i) = \prod_i (1+ 2\frac{n_i}{a_i})a_i^{n_i}$$ Also, by Sherman–Morrison formula, we have

$$D_i^{-1} = \mathrm{diag}(a_i^{-1}) - \frac{2\mathrm{diag}(a_i^{-1})J_i\mathrm{diag}(a_i^{-1})}{1+2 n_i/a_i}$$. So,

$$1-e^TD^{-1}e = 1- \sum_i\frac{n_i}{a_i} + \sum_i \frac{2(n_i/a_i)^2}{1+2 n_i/a_i} = \sum_i \frac{1+ n_i/a_i}{1+2n_i/a_i}$$ Therefore $$\det(M) = (\sum_i \frac{1+ n_i/a_i}{1+2n_i/a_i}) \prod_i (1+ 2\frac{n_i}{a_i})a_i^{n_i} \\= \prod_{i=1}^k a_i^{n_i} \sum_{j=0}^k (2-j)2^{j-1}e_j$$

To complete Mahdi's answer, it suffices to show $$(1-\sum_i\frac{x_i}{1+2x_i})\prod_i(1+2x_i)=\sum_{j\ge 0} (2-j)2^{j-1}e_j.$$ Clearly $$\prod_i(1+ax_i)=\sum_{j\ge 0} a^je_j$$, which explains the $$2^je_j$$ term on the RHS.

Consider $$\frac{\partial}{\partial t}\prod_i(1+x_i+tx_i)|_{t=1}$$. On the one hand it is $$\sum_ix_i\prod_{k\neq i}(1+2x_k)$$ by product rule, which appears on the LHS. On the other hand it is $$\frac{\partial}{\partial t}\sum_{j\ge 0} (1+t)^{j}e_j|_{t=1}=\sum_{j\ge 0}j2^{j-1}e_j$$, which appears on the RHS.

Alternatively, one may just inspect the eigenvalues (whose product is the determinant).

Clearly, all the vectors whose support lies in the $$i$$th block, and whose coordinates sum up to $$0$$, are eigenvectors with eigenvalue $$a_i$$; hence $$a_i$$ is the eigenvalue with multiplicity (at least) $$n_i-1$$.

An invariant complement to the sum of already found subspaces is the set $$V$$ of all block-constant vectors; so we need to check the determinant of the restriction onto $$V$$. A natural base in $$V$$ consists of the vectors havig ones in the $$i$$th block, and zeroes elsewhere. The matrix in this base is $$A=\left( \begin{array}{ccccccccc} n_1+a_1& -n_2& -n_2& \cdots& -n_k\\ -n_1& n_2+a_2& -n_3& \cdots& -n_k\\ -n_1& -n_2& n_3+a_3& \cdots& -n_k\\ \vdots& \vdots& \vdots& \ddots& \vdots\\ -n_1& -n_2& -n_3& \cdots& n_k+a_k \end{array} \right),$$ whose determinant is $$n_1n_2\dots n_k$$ times the determinant of $$B=\left( \begin{array}{ccccccccc} 1+a_1/n_1& -1& -1& \cdots& -1\\ -1& 1+a_2/n_2& -1& \cdots& -1\\ -1& -1& 1+a_3/n_3& \cdots& -1\\ \vdots& \vdots& \vdots& \ddots& \vdots\\ -1& -1& -1& \cdots& 1+a_k/n_k \end{array} \right).$$ Its determinant may be computed either directly, or via the same Matrix determinant lemma, yielding $$\det B=\prod_{i=1}^k\left(2+\frac{a_i}{n_i}\right) -\sum_{i=1}^k \prod_{\textstyle{1\leq j\leq k\atop j\neq i}} \left(2+\frac{a_j}{n_j}\right).$$ After substituting into $$\det M=\det B\cdot \prod_{i=1}^k n_ia_i^{n_i-1}$$ and expanding the brackets, we get the desired result. (Although, I would admit, the form it has been obtained in does not look much worse for me.)