Compute matrix determinant for matrix with $\lambda$ on diagonal and $\mu$ elsewhere Given $n\in \mathbb N$, how can I compute the determinant of $(a_{ij})_{1\leq i,j \leq n} \in \mathcal M_{n\times n}(\mathbb R)$ where, for each $1\leq i,j\leq n:$ $$a_{ij}= \begin{cases} \lambda &i=j \\ \mu & i\neq j \end{cases}$$
The only (or the only easy) way to do this I think involves using Laplace's formula, expanding along any row. But doing this everything gets too messy, I can't express it in a good way. I tried to get a recursive relation and prove it via induction but didn't get anywhere. Is there an easier way? Any hints appreciated.
 A: Let $A$ be the matrix:
$$\begin{pmatrix}
\lambda & \mu & \mu & \cdots & \mu \\
\mu & \lambda & \mu & \cdots & \mu \\
\mu & \mu & \lambda & \cdots & \mu \\
\vdots & \vdots & \vdots && \vdots \\
\mu & \mu & \mu & \cdots & \lambda \\
\end{pmatrix}$$

Consider:
$$\begin{pmatrix}
\lambda & \mu & \mu & \cdots & \mu \\
\mu & \lambda & \mu & \cdots & \mu \\
\mu & \mu & \lambda & \cdots & \mu \\
\vdots & \vdots & \vdots && \vdots \\
\mu & \mu & \mu & \cdots & \lambda \\
\end{pmatrix}
\begin{pmatrix}1\\1\\1\\\vdots\\1\end{pmatrix}
=
\begin{pmatrix}\lambda+(n-1)\mu\\\lambda+(n-1)\mu\\\lambda+(n-1)\mu\\\vdots\\\lambda+(n-1)\mu\end{pmatrix}
=
\left[\lambda+(n-1)\mu\right]
\begin{pmatrix}1\\1\\1\\\vdots\\1\end{pmatrix}$$
Hence, $\left[\lambda+(n-1)\mu\right]$ is an eigenvalue of $A$.

Consider:
$$\begin{pmatrix}
\lambda & \mu & \mu & \cdots & \mu \\
\mu & \lambda & \mu & \cdots & \mu \\
\mu & \mu & \lambda & \cdots & \mu \\
\vdots & \vdots & \vdots && \vdots \\
\mu & \mu & \mu & \cdots & \lambda \\
\end{pmatrix}
\begin{pmatrix}1\\0\\0\\\vdots\\-1\end{pmatrix}
=
\begin{pmatrix}\lambda-\mu\\0\\0\\\vdots\\\mu-\lambda\end{pmatrix}
=
\left[\lambda-\mu\right]
\begin{pmatrix}1\\0\\0\\\vdots\\-1\end{pmatrix}$$
Hence, $\left[\lambda-\mu\right]$ is an eigenvalue of $A$.
One can construct other eigenvalues using this method, so in total we will have $(n-1)$ eigenvalues which are $\left[\lambda-\mu\right]$.

$$\det A = \prod \lambda_k = \left[\lambda+(n-1)\mu\right]\left[\lambda-\mu\right]^{n-1}$$
A: Let $v$ be a column vector of ones. Then $vv^T$ is a matrix of ones, and the matrix of interest can be expressed as $\mu (vv^T)+(\lambda-\mu)I_n.$ The determinant of this rank-one matrix can then be found in a number of ways e.g. using the matrix determinant lemma, considering the eigenvalues, etc.
