nullspace.RdKernel of the linear map defined by matrix M.
nullspace(M)
null(M)The kernel (aka null space/nullspace) of a matrix M is the set of
all vectors x for which Ax=0. It is computed from the
QR-decomposition of the matrix.
null is simply an alias for nullspace – and the Matlab name.
If M is an n-by-m (operating from left on
m-dimensional column vectors), then N=nullspace(M) is a
m-by-k matrix whose columns define a (linearly independent)
basis of the k-dimensional kernel in R^m.
If the kernel is only the null vector (0 0 ... 0), then NULL will
be returned.
As the rank of a matrix is also the dimension of its image, the following relation is true:
m = dim(nullspace(M)) + rank(M)
Trefethen, L. N., and D. Bau III. (1997). Numerical Linear Algebra. SIAM, Philadelphia.
The image of M can be retrieved from orth().
M <- matrix(1:12, 3, 4)
Rank(M) #=> 2
#> [1] 2
N <- nullspace(M)
# [,1] [,2] [,3]
# [1,] 0.4082483 -0.8164966 0.4082483
M
#> [,1] [,2] [,3] [,4]
#> [1,] 1 4 7 10
#> [2,] 2 5 8 11
#> [3,] 3 6 9 12
M1 <- matrix(1:6, 2, 3) # of rank 2
M2 <- t(M1)
nullspace(M1) # corresponds to 1 -2 1
#> [,1]
#> [1,] 0.4082483
#> [2,] -0.8164966
#> [3,] 0.4082483
nullspace(M2) # NULL, i.e. 0 0
#> NULL
M <- magic(5)
Rank(M) #=> 5
#> [1] 5
nullspace(M) #=> NULL, i.e. 0 0 0 0 0
#> NULL