# What's the determinant of this $n$ by $n$ matrix?

I would like to know if there's some way of computing the determinant of the $$n$$-th order square matrix whose diagonal entries are $$1$$ while the rest equal some constant $$a$$, so

$$\begin{pmatrix} 1 & a & a & \cdots & a \\ a & 1 & a & \cdots & a \\ a & a & 1 & \cdots & a \\ \vdots& \vdots& \vdots & \ddots & \vdots\\ a & a & a & \cdots & 1 \\ \end{pmatrix}.$$

I tried computing some cases, so

• $$n=1$$ gives $$1$$,
• $$n=2$$ gives $$1-a^2$$,
• $$n=3$$ gives $$1-3a^2+2a^3$$,
• $$n=4$$ gives $$1-6a^2+8a^3-3a^4$$

and I noticed some patterns. First off, the 0th order on $$a$$ is always $$1$$ and the first is always $$0$$. The second is minus the $$n-1$$th triangular number and the $$n$$th is $$(-1)^{n-1}(n-1)$$.

With these, I thought I could maybe do some induction and compute the $$n$$th order determinant from the $$n-1$$th using minors or something, I think that's probably the best way to do it, but I get confused all the time and the expressions I get are very ugly. Can anyone give me a hint, please?

• Hint: use Lapace's formula in your induction process. Mar 13 '20 at 17:53
• If we have $a=0$ , the determinant is obviously always $1$. If we have $a=1$ , the detrminant is obviously $0$, hence all the polynomials must be divisible by $a-1$ Mar 13 '20 at 17:55

If we let $$A_{ij}=a+(1-a)\delta_{ij}$$ we see that $$A-(1-a)I$$ has rank $$1$$ so $$1-a$$ is an eigenvalue of $$A$$ with multiplicity $$n-1$$. Since the sum of all eigenvalues is $$\operatorname{Tr}A=n$$, the last eigenvalue is $$n-(n-1)(1-a)=1+(n-1)a$$ so the determinant is the product of all eigenvalues: $$\det A=(1-a)^{n-1}\left(1+(n-1)a\right)$$
Here is a general way how to solve these problems. Write $$A = \begin{pmatrix} 1 & a & a & \cdots & a \\ a & 1 & a & \cdots & a \\ a & a & 1 & \cdots & a \\ \vdots& \vdots& \vdots & \ddots & \vdots\\ a & a & a & \cdots & 1 \\ \end{pmatrix} = (1-a) E + a \begin{pmatrix} 1 \\1\\ \vdots\\ 1\\ \end{pmatrix}\cdot(1, 1, \cdots, 1)$$ with $$E$$ the unit matrix. By the matrix determinant lemma, we have $$\det (A) = (1 + a\frac{1}{1-a}(1, 1, \cdots, 1) \cdot E \cdot\begin{pmatrix} 1 \\1\\ \vdots\\ 1\\ \end{pmatrix} )(1-a)\det E \\ = (1-a)^n + a n (1-a)^{n-1} = (1-a)^{n-1} (1-a + a n)$$ and your results confirm with that.