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?
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)$$