How to calculate the determinant of $4 \times 4$ matrix with a variable on the diagonal? I need to calculate the determinant of the following $4 \times 4$ matrix:
\begin{bmatrix}x&1&1&1\\1&x&1&1\\1&1&x&1\\1&1&1&x\end{bmatrix}
I heard there is a way by separating the matrix into blocks, but I couldn't succeed in doing that.
 A: Useful trick - if the sum of each row of the matrix is the same (in this case - $x+3$), then you can simplify the determinant via the following elementary operations:

*

*Add all columns to the first column.


*Subtract the first row from all rows.
In your case:
$$\begin{vmatrix}x&1&1&1\\1&x&1&1\\1&1&x&1\\1&1&1&x\end{vmatrix}
=\begin{vmatrix}x+3&1&1&1\\x+3&x&1&1\\x+3&1&x&1\\x+3&1&1&x\end{vmatrix}
=\begin{vmatrix}x+3&1&1&1\\0&x-1&0&0\\0&0&x-1&0\\0&0&0&x-1\end{vmatrix}$$
Your matrix is now triangular, and the determinant is the product of diagonal elements.
A: Alternative:
$A=\begin{bmatrix}x&1&1&1\\1&x&1&1\\1&1&x&1\\1&1&1&x\end{bmatrix}$
Since each row sum is $x+3$ , it's an eigenvalue of $A$ $($ see here $) $
It is clear that if $x=1$ , then $A$ will be a rank $1$ matrix.
Hence $x-1$ is an eigenvalue as $\det(A-(x-1) I) =0$
Infact Eigen space corresponding to $x-1$ has dimension $3$ as
$A-(x-1)I=\begin{bmatrix}1&1&1&1\\1&1&1&1\\1&1&1&1\\1&1&1&1\end{bmatrix}$
has $3$ dimensional null space.
Hence Algebraic multiplicity of $(x-1) $ is $3$ $($ as it is bigger than geometric multiplicity and no. of distinct eigen values can't exceed $4$ $) $
Now $\det(A) =\Pi_{\lambda\in \operatorname{spec}{A}} \space {\lambda}=(x-1)^3(x+3)$
(determinant is the product of all eigenvalues )
A: In the special case $$
\left( {\begin{array}{*{20}c}
   A & B  \\
   B & A  \\
\end{array}} \right)
$$
where $A,B$ are $2×2$ blocks you can use the formula
$$
\det \left( {\begin{array}{*{20}c}
   A & B  \\
   B & A  \\
\end{array}} \right) = \det \left( {A - B} \right)\det \left( {A + B} \right)
$$
In our case you have
$$
\det \left( {A - B} \right) = \det \left( {\begin{array}{*{20}c}
   {x - 1} & 0  \\
   0 & {x - 1}  \\
\end{array}} \right) = (x - 1)^2 
$$
while
$$
\det \left( {A + B} \right) = \det \left( {\begin{array}{*{20}c}
   {x + 1} & 2  \\
   2 & {x + 1}  \\
\end{array}} \right) = x^2  + 2x - 3 = \left( {x - 1} \right)\left( {x + 3} \right)
$$
whence
$$
\det \left( {\begin{array}{*{20}c}
   A & B  \\
   B & A  \\
\end{array}} \right) = \left( {x - 1} \right)^3 \left( {x + 3} \right)
$$
