Consider the following experiment:
n = 100; %

Note that for large matrices, the determinant A * A will be too large to be represented in double numbers and will return Inf . However, we only need the log of the determinant, and there are other approaches for finding this result, which saves the calculations on a logarithmic scale.
In the comments, @yoda suggested using the eigenvalues detA2(i) = real(sum(log(eig(A^2)))); I also found a publication in FEX that have a similar implementation (using LU or Cholesky decomposition)
source share