3

So I have a matrix X and I want to know a basis for its nullspace. I've seen the suggestion that QR decomposition will give this where, if X is m × n then Q will be m × n and if you write Q = [Q1, Q2] where Q1 is m × m then Q2 will have columns as a basis for the nullspace of X. However, my X is 4 × 4 so Q will be the same, and then you can't split it into any proper pieces, so I don't seem to be able to find vectors in the nullspace.

Am I misunderstanding how to get a basis for the nullspace from QR decomposition, or will it just not work for square matrices that have non-trivial kernels?

Also, is there a way to more efficiently or directly find a basis for the null space?

Here is the actual full code I'm running:

import sympy as sp

c1 = [2, 0, 0, 0]
c2 = [1, 2, 0, 0]
c3 = [0, 1, 2, 0]
c4 = [0, 0, 0, 3]
ul = [1, 1, 1, 1]

A = sp.Matrix([ sp.Matrix(c1).T, sp.Matrix(c2).T, sp.Matrix(c3).T, sp.Matrix(c4).T ]).T
u = sp.Matrix(ul)

M = u.row_join(A*u).row_join(A**2*u).row_join(A**3*u).row_join(A**4*u)

coefs = M.rref()[0].col(4)

x = sp.Symbol('x')
p = 1
for i in range(4):
    p = p - coefs[3-i]*x**(i+1)

sol = sp.solve(p,x)

Qs = []

for i in range(2):
    Q,R = ((A-sol[i]*sp.eye(4)).T).QRdecomposition()
    Qs.append(Q)
matsjoyce
  • 5,744
  • 6
  • 31
  • 38
Addem
  • 3,635
  • 3
  • 35
  • 58
  • Relevant: http://scicomp.stackexchange.com/questions/2510/null-space-of-a-rectangular-dense-matrix – NPE Oct 28 '14 at 21:18
  • 2
    Also: http://stackoverflow.com/questions/2181418/computing-the-null-space-of-a-matrix-as-fast-as-possible. In particular, note the "rank `n`" bit: if your matrix is full rank, its nullspace consists just of the zero vector. – NPE Oct 28 '14 at 21:20
  • @NPE, that link seems to say that this procedure will not give results for a 4x4 matrix with rank 3, for instance. In that link the number of columns has to be the same as the rank of the matrix. In that matrix, would you need to delete a linearly dependent column for the procedure to work? Then the null space would be a space in 3-dimensional space ... which seems un-ideal. – Addem Oct 29 '14 at 14:45

0 Answers0