I was asked to evaluate the determinant of the I was asked to evaluate the determinant of the $n$x$n$ matrix
$$ A=
\begin{bmatrix}
x & 2 & 2 & \cdots & 2 \\
2 & x & 2 & \cdots & 2 \\
2 & 2 & x & \cdots & 2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
2 & 2 & 2 & \cdots & x \\
\end{bmatrix}
$$
I tried starting from a 1x1 matrix to 5x5 matrix, and saw the pattern
$$\det{A}=(x-2)^{n-1}(x+2(n-1)).$$
Now I need to prove that this is the case for any nxn matrix of type A, so I tried using induction.The base case (n=1) holds.
$$A=
\begin{bmatrix}
x
\end{bmatrix}
$$
And clearly $\det{A}=x$ using both the definition of a determinant and the explicit formula above.
So now assume it holds for any $n$, and test for $n+1$.
$$\det{A}=(x-2)^n(x+2n).$$
What do I do now? 
 A: First subtract the last row from the first $n-1$ rows. Then add first $n-1$ columns to the last one. 
\begin{align}
\det A &= \begin{vmatrix}
x & 2 & 2 & \cdots & 2 \\
2 & x & 2 & \cdots & 2 \\
2 & 2 & x & \cdots & 2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
2 & 2 & 2 & \cdots & x \\
\end{vmatrix} \\
&= \begin{vmatrix}
x-2 & 0 & 0 & \cdots & 2-x \\
0 & x-2 & 0 & \cdots & 2-x \\
0 & 0 & x-2 & \cdots & 2-x \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
2 & 2 & 2 & \cdots & x \\
\end{vmatrix} \\
&= \begin{vmatrix}
x-2 & 0 & 0 & \cdots & 0 \\
0 & x-2 & 0 & \cdots & 0 \\
0 & 0 & x-2 & \cdots & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
2 & 2 & 2 & \cdots & x + 2(n-1) 
\end{vmatrix}\\
&= (x-2)^{n-1}(x-2(n-1))
\end{align}
The resulting determinant is lower-triangular so it is equal to the product of diagonal elements.
A: We add all rows to the first one, then factor $x+2(n-1)$ from this first row, than use it (doubled) to eliminate in the other rows. With this strategy we are done quickly:
$$
\begin{aligned}
\det A
&=
\begin{vmatrix}
x & 2 & 2 & \cdots & 2 \\
2 & x & 2 & \cdots & 2 \\
2 & 2 & x & \cdots & 2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
2 & 2 & 2 & \cdots & x \\
\end{vmatrix}
\\
&=
\begin{vmatrix}
x+2(n-1) & x+2(n-1) & x+2(n-1) & \cdots & x+2(n-1) \\
2 & x & 2 & \cdots & 2 \\
2 & 2 & x & \cdots & 2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
2 & 2 & 2 & \cdots & x \\
\end{vmatrix}
\\
&=
(x+2(n-1))
\begin{vmatrix}
1 & 1 & 1 & \cdots & 1 \\
2 & x & 2 & \cdots & 2 \\
2 & 2 & x & \cdots & 2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
2 & 2 & 2 & \cdots & x \\
\end{vmatrix}
\\
&=
(x+2(n-1))
\begin{vmatrix}
1 & 1 & 1 & \cdots & 1 \\
2-2 & x-2 & 2-2 & \cdots & 2-2 \\
2-2 & 2-2 & x-2 & \cdots & 2-2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
2-2 & 2-2 & 2-2 & \cdots & x-2 \\
\end{vmatrix}
\\
&=
(x+2(n-1))
\begin{vmatrix}
1 & 1 & 1 & \cdots & 1 \\
0 & x-2 & 0 & \cdots & 0 \\
0 & 0 & x-2 & \cdots & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
0 & 0 & 0 & \cdots & x-2 \\
\end{vmatrix}
\\
&=(x+2(n-1))(x-2)^{n-1}\ .
\end{aligned}
$$
A: One way to proceed is to find the eigenvalues of $A$.
The matrix $$ A - (x-2)I = \begin{bmatrix}2 & 2 & \cdots & 2 \\ 2 & 2 & \cdots & 2 \\ \vdots & \vdots & \ddots & \vdots \\ 2 & 2 & \cdots & 2\end{bmatrix}$$ has rank $1$, which tells us that $x-2$ is an eigenvalue with multiplicity $n-1$. To find the remaining eigenvalue, there are two approaches: we can


*

*spot the eigenvector $\mathbf v = (1,1,\dots,1)^{\mathsf T}$, and notice that $A\mathbf v = (x + 2(n-1))\mathbf v$, or

*use the fact that $\operatorname{tr}(A) = nx$ is the sum of all the eigenvalues, and therefore the remaining eigenvalue is $nx - (n-1)(x-2) = x + 2(n-1)$.


Either way, now that we know all the eigenvalues, we conclude that $\det(A)$ is the product of all of them:
$$
   \det(A) = (x-2)^{n-1} (x + 2(n-1)).
$$
