# Determinant of matrix with constant lines apart diagonal

I would like to compute the determinant of a matrix with the following structure: $$$$\begin{pmatrix} D_1 & l_1 & l_1 &\cdots & l_1 \\ l_2 & D_2 & l_2 &\cdots & l_2 \\ l_3 & \cdots & D_3 &\cdots & l_3 \\ l_4 & \cdots & l_4 & D_4 & l_4 \\ l_5 & \cdots & \cdots & l_5 & D_5 \\ \end{pmatrix}$$$$ That is, it is constant on each line apart from the diagonal. $$l_i, D_i \in \mathbb R^+$$.

Is there a way to make use of such symmetric structure to simplify the calculation of the determinant?

• What's $l_i$ and $D_i$? Block matrices or constants? Any particular value? Apr 28 '20 at 7:16
• they are real numbers. specifying any value would add confusion, as the entries are related to physical quantities
– Graz
Apr 28 '20 at 7:20
• also, they are positive
– Graz
Apr 28 '20 at 7:21

One has :

$$\begin{pmatrix} D_1 & l_1 & l_1 &\cdots & l_1 \\ l_2 & D_2 & l_2 &\cdots & l_2 \\ l_3 & \cdots & D_3 &\cdots & l_3 \\ l_4 & \cdots & l_4 & D_4 & l_4 \\ l_5 & \cdots & \cdots & l_5 & D_5 \\ \end{pmatrix}=$$ $$\begin{pmatrix} D_1-l_1 & & && \\ & D_2-l_2 & && \\ & & D_3-l_3 && \\ & & & D_4-l_4 & \\ & & & & D_5-l_5 \\ \end{pmatrix}+\begin{pmatrix} l_1\\ l_2\\ l_3\\ l_4\\ l_5 \\ \end{pmatrix} \begin{pmatrix} 1&1&1&1&1 \end{pmatrix}$$

Now apply the matrix-determinant lemma :

$$\displaystyle \det \left(\mathbf {A} +\mathbf {uv} ^{\textsf {T}}\right)=\left(1+\mathbf {v} ^{\textsf {T}}\mathbf {A} ^{-1}\mathbf {u} \right)\,\det \left(\mathbf {A} \right)$$

dealing with the determinant of a rank-one update to a matrix.

finally giving

$$\displaystyle (1 + \sum_{i=1}^n \frac{l_i}{D_i - l_i}) \prod_{i=1}^n (D_i - l_i) = \prod_{i=1}^n (D_i - l_i) + \sum_{i=1}^n l_i \prod_{j \ne i} (D_j - l_j)$$

as explicited by @math54321 who has pointed the fact that it isn't necessary to assume that the diagonal matrix with diagonal elements $$D_i-l_i$$ is invertible ; the non-inversibility case can be treated by using a slightly different version of the matrix-determinant lemma which is

$$\displaystyle \det \left(\mathbf {A} +\mathbf {uv} ^{\textsf {T}}\right)=\det \left(\mathbf {A} \right)+\mathbf {v} ^{\textsf {T}}\mathrm {adj} \left(\mathbf {A} \right)\mathbf {u}$$

• Should that $-$ be a $+$? Apr 28 '20 at 7:48
• You are right. I fix it. Thank you. Apr 28 '20 at 7:49
• Note that the formula in this case is $\displaystyle (1 + \sum_{i=1}^n \frac{l_i}{D_i - l_i}) \prod_{i=1}^n (D_i - l_i) = \prod_{i=1}^n (D_i - l_i) + \sum_{i=1}^n l_i \prod_{j \ne i} (D_j - l_j)$, which (one can check) works even if some $D_i = l_i$. Apr 28 '20 at 19:13
• @math54321 You are perfectly right. I should have mentionned that there is a second version of the formula (present in the Wikipedia article) that can be used when the matrix is not invertible. Apr 29 '20 at 7:21