How to calculate the determinant of all-ones matrix minus the identity? [duplicate]

How do I calculate the determinant of the following $n\times n$ matrices

$$\begin {bmatrix} 0 & 1 & \ldots & 1 \\ 1 & 0 & \ldots & 1 \\ \vdots & \vdots & \ddots & \vdots \\ 1 & 1 & ... & 0 \end {bmatrix}$$

and the same matrix but one of columns replaced only with $1$s?

In the above matrix all off-diagonal elements are $1$ and diagonal elements are $0$.


$$D_n(a,b)= \begin{vmatrix} a & b & b & b \\ b & a & b & b \\ b & b & a & b \\ b & b & b & a \end{vmatrix}$$ ($n\times n$-matrix).

$$D_n(a,b)= \begin{vmatrix} a & b & b & b \\ b & a & b & b \\ b & b & a & b \\ b & b & b & a \end{vmatrix}$$

$$=[a+(n-1)b] \begin{vmatrix} 1 & 1 & 1 & 1 \\ b & a & b & b \\ b & b & a & b \\ b & b & b & a \end{vmatrix}$$ $$=[a+(n-1)b] \begin{vmatrix} 1 & 1 & 1 & 1 \\ 0 & a-b & 0 & 0 \\ 0 & 0 & a-b & 0 \\ 0 & 0 & 0 & a-b \end{vmatrix}$$ $$=[a+(n-1)b](a-b)^{n-1} $$

(In the first step we added the remaining rows to the first row and then "pulled out" constant out of the determinant. Then we subtracted $b$-multiple of the first row from each of the remaining rows.)

You're asking about $D_n(0,1)=(-1)^{n-1}(n-1)$.


If you replace one column by 1's, you can use this result to get the following. (I've computed it for $n=4$, but I guess you can generalize this for arbitrary $n$.)

$$ \begin{vmatrix} 1 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \\ \end{vmatrix} = \begin{vmatrix} 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \\ \end{vmatrix} + \begin{vmatrix} 1 & 0 & 0 & 0 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \\ \end{vmatrix}= \begin{vmatrix} 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \\ \end{vmatrix} + \begin{vmatrix} 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \end{vmatrix} $$

Note that both these determinants are of the type you already handled in the first part.


Here's an approach using Sylvester's determinant theorem, which says that for any rectangular matrices of mutually transposed shapes $A\in\mathrm M_{n,m}(K)$ and $B\in \mathrm M_{m,n}(K)$ one has $$\det(I_n+AB)=\det(I_m+BA).$$

If $N$ is your matrix then $-N=I_n-AB$ where $A\in\mathrm M_{n,1}(K)$ is a one column all-one matrix and $B$ is its transpose. Then $$ \det(N)=(-1)^n\det(-N)=(-1)^n\det(I_1-BA)=(-1)^n(1-n). $$


I will compute the determinant of the matrix $$ A = \left( \begin {matrix} b & a & \ldots & a \\ a & b & \ddots & \vdots \\ \vdots & \ddots & \ddots & a \\ a & \cdots & a & b \end {matrix} \right), $$ where $a, b \in \mathbb{K}$. To obtain your case, put $a=1$ and $b=0$.

First proof. This works if $\mathrm{char}(\mathbb{K}) = 0$ or $n$ is prime to $\mathrm{char}(\mathbb{K}) > 0$. If $a =0$, then $\det A = b^n$. Suppose $a \neq 0$ and consider the vector $v = (1, \dots, 1) \in \mathbb{K}^n$; it is clear that $v$ is an eigenvector of $A$ with eigenvalue $\alpha = (n-1) a + b$. Now consider $\beta = b-a$. $\beta$ is an eigenvalue of $A$ because $$ B = A - \beta I_n = \left( \begin {matrix} a & a & \ldots & a \\ a & a & \ldots & a \\ \vdots & \vdots & \ddots & \vdots \\ a & a & ... & a \end {matrix} \right) $$ has rank $1$.

Let $E_\alpha, E_\beta \subseteq \mathbb{K}^n$ the eigenspaces of $A$ of the eigenvalues $\alpha, \beta$. We have $\alpha \neq \beta$, $E_\alpha \cap E_\beta = \{ 0 \}$ and $\dim E_\beta = n-1$, thus $\mathbb{K}^n = E_\alpha \oplus E_\beta$ and $E_\alpha = \langle v \rangle$. This proves that $A$ is similar to the matrix $\mathrm{diag}(\alpha, \beta, \dots, \beta)$, therefore $\det A = \alpha \beta^{n-1} = [(n-1)a +b] (b-a)^{n-1}$. (Notice that this formula holds also when $a=0$.)

Second proof. The characteristic polynomial of the matrix $B = A - (b-a) I$ is $$ \chi_B(t) = (-t)^n + c_{n-1} (-t)^{n-1} + \cdots + c_1(-t) + c_0, $$ where $c_i$ is the sum of the principal $(n-i)$-minors of $B$. It is clear that all principal minors of $B$ are zero, except on $1$-minors. Thus $$ \chi_B(t) = (-t)^n + na (-t)^{n-1}. $$ From $A = B + (b-a) I$, we have $\chi_A(t) = \chi_B(t-b+a)$. Thus $\det A = \chi_A(0) = \chi_B(a-b) = (b-a)^n + na (b-a)^{n-1}$.

Now consider the matrix $$ C = \left( \begin {matrix} a & a & \ldots & a \\ a & b & \ddots & \vdots \\ \vdots & \ddots & \ddots & a \\ a & \cdots & a & b \end {matrix} \right). $$ For every $i=2,\dots,n$, replace the $i$th row $C_i$ of $C$ with $C_i - C_1$, where $C_1$ is the first row of $C$. Obtain $$ \det C = \det \left( \begin{matrix} a & a & a & \cdots & a \\ 0 & b-a & 0 & \cdots & 0 \\ 0 & 0 & b-a & \ddots & 0 \\ \vdots & \vdots & \ddots & \ddots & 0 \\ 0 & 0 & \cdots & 0 & b-a \end{matrix} \right) = a (b-a)^{n-1}. $$


Let us denote $A_n$ to be that matrix of order $ n \times n $.

Subtract each of the columns multiplied by $1/(n-2)$ from the first column. You determinant then becomes:

$ |A_n|= \left| \begin {matrix} \frac {n-1}{n-2} & 1 & \ldots & 1 \\ 0 & 0 & \ldots & 1 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 1 & ... & 0 \end {matrix} \right| = \frac{n-1}{n-2}|A_{n-1}| $

Inductively you get that $|A_n| = \frac{n-1}{n-2} \frac{n-2}{n-3}...\frac{2}{1}|A_2|=(n-1)|A_2| $.

Yet $|A_2|=-1 $ so you get that $|A_n|=1-n$.


Replace the first 0 with $x$ and the other zeros with $y$.

Now, your determinant is a polynomial in $x$ and $y$ with dominant term $xy^{n-1}$.

If $y=1$, then $n-1$ rows are equal which immediately gives $n-2$ independent kernel vectors, so $(y-1)^{n-2}$ divides the determinant. If $x=(n-1)/(y+n-2)$, then the sum of the $n-1$ bottom lines is a multiple of the first line, so $(x(y+n-2)-(n-1)$ divides the determinant.

Therefore, the determinant is $(x(y+n-2)-(n-1))(y-1)^{n-2}$.

Let $x=y=0$ to get $(-1)^{n-1}(n-1)$.

Let $x=1$ and $y=0$ to get $(-1)^{n-1}$.