Numpy returns nonzero determinant for singular matrices

57 Views Asked by At

I have a function coef_matrix(L) that returns a square array whose elements are -1, 0 or 1 for which I expect that the columns (or rows) are not all linearly independent. Indeed, for all inputs I tested, the matrix rank calculated through numpy.linalg.matrix_rank() is equal to the matrix dimension minus 2 (e.g., the rank is 52 for a 54 x 54 matrix). Therefore, the returned matrices are singular. However, the determinant evaluates to nonzero values using numpy.linalg.det(). For the 54 x 54 matrix, it evaluates to -1.046741523862728e-26, which could lead me to think that this is zero apart from numerical error as suggested here for a very similar problem. But for higher dimenions not only the value gets markedly different from zero but it increases very fast: -7.450540694504111 for 294 x 294, -6.775526088295892e+24 for 486 x 486, and goes to -inf for dimensions greater than ~3000.

I'm very confident that the rank evaluation is correct as I have explicitly found the two linearly dependent columns for smaller cases. Does anyone know any reason that might explain this possible error for calculating the determinant with numpy.linalg.det()?

0

There are 0 best solutions below