\[\mathbf{det(A)} = 0.\left|\begin{matrix} 5 & 2 & 4 \\ 3 & 1 & 2 \\ 5 & 2 & 1 \end{matrix}\right| + 1.\left|\begin{matrix} 2 & 3 & 2 \\ 3 & 1 & 2 \\ 5 & 2 & 1 \end{matrix}\right| + 0.\left|\begin{matrix} 2 & 3 & 2 \\ 5 & 2 & 4 \\ 5 & 2 & 1 \end{matrix}\right| + 3.\left|\begin{matrix} 2 & 3 & 2 \\ 5 & 2 & 4 \\ 3 & 1 & 2 \end{matrix}\right| = \]
\[0.\mathbf{det(W)} + 1.\mathbf{det(X)} + 0.\mathbf{det(Y)} + 3.\mathbf{det(Z)} = \]
\[\mathbf{where}\] \[\mathbf{W}=\left[\begin{matrix} 5 & 2 & 4 \\ 3 & 1 & 2 \\ 5 & 2 & 1 \end{matrix}\right]; \mathbf{X}=\left[\begin{matrix} 2 & 3 & 2 \\ 3 & 1 & 2 \\ 5 & 2 & 1 \end{matrix}\right]; \mathbf{Y}=\left[\begin{matrix} 2 & 3 & 2 \\ 5 & 2 & 4 \\ 5 & 2 & 1 \end{matrix}\right]; \mathbf{Z}=\left[\begin{matrix} 2 & 3 & 2 \\ 5 & 2 & 4 \\ 3 & 1 & 2 \end{matrix}\right] \]
\[(0.3) + (1.17) + (0.33) + (3.4) = 0 + 17 + 0 + 12 = 29\]
A <- matrix(c(2, 0, 3, 2, 5, 1, 2, 4, 3, 0, 1, 2, 5, 3, 2, 1), nrow = 4, ncol = 4, byrow = TRUE)
d <- det(A)
print (d)
## [1] 29