1

I am using the pracma package, which contains the function nullspace(), returning normalized basis vectors of the Null(A):

> require(pracma)
> (A = matrix(c(1,2,3,4,5,6), nrow=2, byrow=T))
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
> nullspace(A)
           [,1]
[1,]  0.4082483
[2,] -0.8164966
[3,]  0.4082483

which is perfectly fine. However (don't ask), I want to quickly check the values I'd get if I were to produce the reduced row echelon form:

> rref(A)
     [,1] [,2] [,3]
[1,]    1    0   -1
[2,]    0    1    2

and from there "manually" figure out the null space as

N(A) = [1, -2, 1]'

Yes, the latter is a scalar multiple of the former:

> c(1,-2,1)/nullspace(A)
        [,1]
[1,] 2.44949
[2,] 2.44949
[3,] 2.44949

but I'd still like to get the latter, non-normalized form of a basis of the null space, as though the values were directly obtained from the reduced row echelon matrix.

Antoni Parellada
  • 4,253
  • 6
  • 49
  • 114

1 Answers1

1

You may want to try

B = rref(A)
solve(B[,1:2], -B[,3])

This gives you the combination your need for the first two columns to get one unit of the third column. Just add one to get your result.

Similarly for the case where size of null space is larger than one.

yulunz
  • 133
  • 1
  • 6