[Math] the determinant of the sum of a diagonal matrix and a matrix of ones

determinantmatrices

Given a square matrix, all elements outside of the main diagonal being equal to $1,$ what is its determinant?

Best Answer

Let the matrix be \begin{align} A & = \begin{bmatrix} d_1 & 1 & 1 & \cdots & 1\\ 1 & d_2 & 1 & \cdots & 1\\ 1 & 1 & d_3 & \cdots & 1\\ \vdots & \vdots & \vdots & \ddots & \vdots\\ 1 & 1 & 1 & \cdots & d_n \end{bmatrix}\\ & = \begin{bmatrix} d_1-1 & 0 & 0 & \cdots & 0\\ 0 & d_2-1 & 1 & \cdots & 0\\ 0 & 0 & d_3-1 & \cdots & 0\\ \vdots & \vdots & \vdots & \ddots & \vdots\\ 0 & 0 & 0 & \cdots & d_n-1 \end{bmatrix}+ \begin{bmatrix} 1\\ 1\\ 1\\ \vdots\\ 1 \end{bmatrix} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 \end{bmatrix}\\ & = D+uu^T \end{align} where $D=\begin{bmatrix} d_1-1 & 0 & 0 & \cdots & 0\\ 0 & d_2-1 & 1 & \cdots & 0\\ 0 & 0 & d_3-1 & \cdots & 0\\ \vdots & \vdots & \vdots & \ddots & \vdots\\ 0 & 0 & 0 & \cdots & d_n-1 \end{bmatrix}$ and $u^T=\begin{bmatrix} 1 & 1 & 1 & \cdots & 1 \end{bmatrix}$.

From Sylvester determinant theorem, we have $$\det(D+uu^T) = \det(D)\det(I+D^{-1}uu^T) = \det(D) \det(I_{1 \times 1} + u^TD^{-1}u)$$

This gives us that the determinant is $$\prod_{k=1}^n (d_k-1)\left(1+\sum_{i=1}^n\dfrac1{d_i-1}\right) = \prod_{k=1}^n (d_k-1) + \sum_{i=1}^n \prod_{\overset{k=1}{k \neq i}}^n (d_k-1)$$

Related Question