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) ?
Chop[]through its second argument. See the docs for details. – J. M.'s missing motivation Oct 04 '12 at 10:03matis a null matrix:Chop[Norm[mat, 1]] == 0; only a null matrix has zero norm. – J. M.'s missing motivation Oct 04 '12 at 10:14SingularValueDecompositionhelp by creating a random matrixmwith entries on the order of, say, $10^{12}$, reconstructmvia its SVD, and subtract the reconstruction frommto see whether the two are equal. They're not--due to imprecision--butchopwon't help. How much imprecision should one expect? Use the sizes of the eigenvalues ofm(the diagonal of the SVD) to estimate the tolerance. – whuber Oct 04 '12 at 14:44Norm[mat] == Max[SingularValueList[mat]]... you and ruebenko are right, maybe machine epsilon times the norm of some convenient matrix might be a better comparison... – J. M.'s missing motivation Oct 04 '12 at 15:17