How to solve a homogenous system Ax = 0
, when A
is any m * n
matrix (not necessarily a square one) in R?
# A=[-0.1 0.1]= 1x2 matrix; x=2x1 to be found; 0: 1x1 zero matrix
A <- t(matrix(c(-0.1,0.1)))
This question seems to be equivalent of finding the kernel (null space) of an Rn -> Rm
(can't do superscript; sorry) linear transformation.
We can eye-spot it,
x = (a, a)
, wherea
is an arbitrary value.A classic / text-book solution
The following function
NullSpace
finds the null space ofA
using the above theory. In case 1, the null space is trivially zero; while in cases 2 to 4 a matrix is returned whose columns span the null space.With your example matrix, it correctly returns the null space.
We can also try a random example.
Finding orthonormal basis
My function
NullSpace
returns an non-orthogonal basis for the null space. An alternative is to apply QR factorization tot(A)
(transpose of A), get the rankr
, and retain the final(n - r)
columns of theQ
matrix. This gives an orthonormal basis for the null space.The
nullspace
function frompracma
package is an existing implementation. Let's take matrixA2
above for a demonstration.Appendix: Markdown (needs MathJax support) for the pictures