Is e-10 small enough to be considered zero, is it e-16, or some other value?
Or does it depend on the software package, or the application? Is there a general limit in numerical resolution below which there is no point in considering the output any more informative than zero?
EDIT:
Here is the source of the question: I posted this on MathSE, and what was supposed to be a "cheap computational proof" of the null spaces came out like this:
In Matlab:
A = [1 3; 1 2; 1 -1; 2 1];
rank(A);
[U,S,V] = svd(A);
left_null_A = transpose(U);
rows = (rank(A) + 1): size(left_null_A,1);
left_null_A = left_null_A(rows,:)
(left_null_A(1,:) + left_null_A(2,:)) * A
%ans =
% -7.2164e-016 5.5511e-017
and
B = transpose(A);
rank(B);
[U,S,V] = svd(B);
right_null_B = transpose(V);
rows = (rank(B) + 1): size(right_null_B,1);
right_null_B(rows,:)
right_null_B = transpose(right_null_B(rows,:))
B * (right_null_B(:,1) + right_null_B(:,2))
%ans =
% -7.7716e-016
% 2.7756e-016
In Python:
import numpy as np
A = np.matrix([[1,3], [1,2], [1, -1], [2,1]])
rank = np.linalg.matrix_rank(A)
U, s, V = np.linalg.svd(A, full_matrices = True)
t_U_A = np.transpose(U)
nrow = t_U_A.shape[0]
left_null_A = t_U_A[rank:nrow,:]
np.dot((left_null_A[0,:] + left_null_A[0,:]), A)
# Out[2]: matrix([[ -4.44089210e-16, -2.10942375e-15]])
and
B = np.transpose(A)
rank = np.linalg.matrix_rank(B)
U, s, V = np.linalg.svd(B, full_matrices = True)
t_V_B = np.transpose(V)
ncols = t_V_B.shape[1]
right_null_B = t_V_B[:,rank:ncols]
np.dot(B, (right_null_B[:,0] + right_null_B[:,1]))
# Out[3]:
# matrix([[ -2.77555756e-16],
# [ -1.38777878e-15]])
In R:
A = matrix(c(1,1,1,2,3,2,-1,1), ncol = 2)
r = qr(A)$rank # Rank 2
SVD.A = svd(A, nu = nrow(A))
SVD.A$u
t.U.A = t(SVD.A$u)
(left_null = t.U.A[(r + 1):nrow(t.U.A),])
colSums(left_null) %*% A
# [,1] [,2]
#[1,] 1.110223e-16 1.054712e-15
and
B = t(A)
r = qr(B)$rank # Naturally it will also have rank 2.
SVD.B = svd(B, nv = ncol(B))
SVD.B$v
(right_null = SVD.B$v[ ,(r + 1):ncol(B)])
B %*% rowSums(right_null)
# [,1]
#[1,] 1.110223e-16
#[2,] 1.665335e-16
Very small numbers, indeed, but can I say they are 0 without resorting to the mathematics behind the calculations?