How to calculate this determinant? [duplicate]

How to calculate this determinant?

$$A=\begin{bmatrix}n-1&k&k&k&\ldots& k\\k&n-1&k&k&\ldots &k\\\ldots&\ldots&\ldots &&\ldots\\\\k&k&k&k&\ldots &n-1\\ \end{bmatrix}_{n\times n}$$

where $n,k\in \Bbb N$ are fixed.

I tried for $n=3$ and got the characteristic polynomial as $(x-2-k)^2(x-2+2k).$

How to find it for general $n\in \Bbb N$?


Here I've followed the same initial step as K. Miller. Instead of using a determinant identity I examine the eigenvalues $A$ and consider their product.

If $J$ denotes the $n\times n$ matrix of all $1$'s, then then eigenvalues of $J$ are $0$ with multiplicity $n-1$ and $n$ with multiplicity $1$. This can be seen by noting that $J$ has $n-1$ dimensional kernel and trace $n$.

Your matrix $A$ is exactly $kJ+(n-k-1)I$ where $I$ denotes the $n\times n$ identity matrix. The eigenvalues of $A$ are therefore $n-k-1$ with multiplicity $n-1$ and $nk+n-k-1$ with multiplicity $1$. The determinant of $A$ is then $(nk+n-k-1)(n-k-1)^{n-1}$.


You can write $A = (n-k-1)I + kee^T$, where $e$ is the $n$-vector of all ones. Now use the matrix determinant lemma which states that

$$ \det(B + uv^T) = (1 + v^TB^{-1}u)\det(B) $$

for $B$ an invertible square matrix. Applying this result to $A$, we find that

$$ \det(A) = (n - k - 1)^n\left(1 + \frac{kn}{n-k-1}\right) = (n-1)(k+1)(n-k-1)^{n-1}. $$


Here is another method using only rows and columns manipulations. Less smart than previous answers but less demanding in prior knowledge.

First let's replace the first column by the sum of all colums: $$\begin{bmatrix}n-1&k&\ldots& k\\k&n-1&\ldots &k\\\ldots&\ldots&\ldots &\ldots\\\\k&k&\ldots &n-1\\ \end{bmatrix} = \left(n-1 + (n-1) \cdot k \right)\begin{bmatrix}1&k&k&\ldots &k\\ 1&n-1&k&\ldots &k\\ \ldots&\ldots&\ldots &\ldots&\ldots\\ \\1&k&k&\ldots &n-1\\ \end{bmatrix} $$ Now let's subtract the first row from all the other ones. It remains: $$ (n-1) (k+1)\begin{bmatrix}1&k&k&\ldots &k\\ 0&n-1-k&0&\ldots &0\\ \ldots&\ldots&\ldots &\ldots&\ldots\\ \\0&0&0&\ldots &n-1-k\\ \end{bmatrix} = (n-1) (k+1) (n-1-k)^{n-1} $$