Say, $A$ is an $ n\times n $ matrix over $\Bbb R$, with
$$ A_{ij} = \begin{cases} a \qquad \text{if } i=j\\ b \qquad \text{otherwise.} \end{cases} $$
How do we compute the determinant of this symmetrix matrix $A$?
Say, $A$ is an $ n\times n $ matrix over $\Bbb R$, with
$$ A_{ij} = \begin{cases} a \qquad \text{if } i=j\\ b \qquad \text{otherwise.} \end{cases} $$
How do we compute the determinant of this symmetrix matrix $A$?
If the first row is the vector $\bf v$ and it's DFT (discrete fourier-transform) is $\bf w$, then the determinant is $\prod_i {\bf w}_i$. This is true for any circulant matrix as it's eigenvalues coincide with those fourier coefficients $$\lambda_i = {\bf w}_i$$ together with the fact that the determinant equals the product of eigenvalues $$\det({\bf A}) = \prod_i \lambda_i({\bf A})$$So this can be used for a wider class of matrices as long as we can compute the Fourier transform.
We can write $A=B-(b-a)I$, where $B$ is the matrix with all entries equal to $b$.
Therefore, $\det A=(-1)^n\chi(b-a)$, where $\chi$ is the characteristic polynomial of $B$.
Since $B$ has rank $1$, we have $\chi(x)=x^n-tr(B)x^{n-1}=x^n-nbx^{n-1}$ (see this for instance, or use induction in this simpler case).
Finally,
$\det A = (-1)^n\chi(b-a)=$
$\qquad=(-1)^n((b-a)^n-nb(b-a)^{n-1})$
$\qquad=(a-b)^n+nb(a-b)^{n-1}$
$\qquad =(a-b)^{n-1}(a+(n-1)b)$