Numerical comparisons of matrices

I have a matrix which should be equal to a null matrix. However due to the numerical precision, a brutal equality test with a matrix initialized with zeros does not work.

How should I perform the numerical equality test (with a given threshold for the precision) ?

-

• Look at the Internal`$EqualTolerance (which is probably not the best idea in your case). - Note, also, that one can control the tolerance used by Chop[] through its second argument. See the docs for details. – Guess who it is. Oct 4 '12 at 10:03 Another possible route to check if the matrix mat is a null matrix: Chop[Norm[mat, 1]] == 0; only a null matrix has zero norm. – Guess who it is. Oct 4 '12 at 10:14 It might be good to not compare against zero but test if the norm is smaller than an epsilon. – user21 Oct 4 '12 at 11:44 Be careful. There does not exist any absolute universal test like this. The comparison of a matrix to zero needs to account for the matrices used to create it. As an example, emulate the SingularValueDecomposition help by creating a random matrix m with entries on the order of, say,$10^{12}\$, reconstruct m via its SVD, and subtract the reconstruction from m to see whether the two are equal. They're not--due to imprecision--but chop won't help. How much imprecision should one expect? Use the sizes of the eigenvalues of m (the diagonal of the SVD) to estimate the tolerance. –  whuber Oct 4 '12 at 14:44