Smart method for computing the determinant of the matrix defined by $A_{ii}=a+b$ and $A_{ij}=a$? We are given the following $n\times n$ matrix, whose terms are:

*

*$a+b$ for the terms in the diagonal ($i=j$).

*$a$ for the rest of the elements.

I know we can simply compute this and try to find a pattern, but is there a faster way? Maybe using some properties of the determinant of a matrix?
 A: Let  $\mathbf e_i$ denote the $i$th standard base vector and $\mathbf j=\sum\mathbf e_i$ denote the "all-ones" vector.
Clearly, $A\mathbf j=(b+na)\mathbf j$, so $\mathbf j$ is an eigenvector of eigenvalue $b+na$.
Also $A\mathbf e_i=b\mathbf e_i+a\mathbf j$ so that for $2\le i\le n$, $A(\mathbf e_i-\mathbf e_1)=b(\mathbf e_i-\mathbf e_1)$, i.e., we know $n-1$ linearly independent eigenvectors of eigenvalue $b$.
All in all, we have found a basis consisting of eigenvectors an know their eigenvalues, and can
conclude that $$\det A=(b+na)\cdot b^{n-1}.$$
A: The given matrix may be written as $bI_n+\mathbf a\mathbf1^T$ where $\mathbf x$ denotes a vector consisting of $n$ copies of $\mathbf x$. The matrix determinant lemma gives the required determinant as
$$(1+\mathbf 1^T(I_n/b)\mathbf a)\det bI_n=(1+na/b)b^n=b^n+nab^{n-1}$$
A: You can use the matrix determinant lemma.
You have
$$C = b I + a {\bf u}  {\bf u}^t$$
where ${ \bf u}$ a all-ones column vector.
Then $$\det(C) = (1 + a {\bf u}^t({b}I)^{-1}  {\bf u}) \det(b I) $$
Can you go on from here?
A: \begin{align*}
& \begin{vmatrix}
a + b & a     & a     & \cdots & a \\
a     & a + b & a     & \cdots & a \\
a     & a     & a + b & \cdots & a\\
\vdots & \vdots & \vdots & \ddots & \vdots \\
a     & a     & a     & \cdots &a + b 
\end{vmatrix} \\
= & \begin{vmatrix}
na + b & na + b   & na + b     & \cdots & na + b \\
a     & a + b & a     & \cdots & a \\
a     & a     & a + b & \cdots & a\\
\vdots & \vdots & \vdots & \ddots & \vdots \\
a     & a     & a     & \cdots &a + b 
\end{vmatrix} \\
= & (na + b)\begin{vmatrix}
1 & 1   & 1     & \cdots & 1 \\
a     & a + b & a     & \cdots & a \\
a     & a     & a + b & \cdots & a\\
\vdots & \vdots & \vdots & \ddots & \vdots \\
a     & a     & a     & \cdots &a + b 
\end{vmatrix} \\
= & (na + b)\begin{vmatrix}
1 & 1   & 1     & \cdots & 1 \\
0     & b & 0    & \cdots & 0 \\
0     & 0    & b & \cdots & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
0     & 0    & 0   & \cdots & b 
\end{vmatrix} \\
=& (na + b)b^{n - 1}
\end{align*}
Can you figure out what operations I used in each step?
