Finding the zero space of a matrix with QR factorization

So, I have a matrix X

and I want to know the base for its nullspace. I've seen the suggestion that QR decomposition will give this where, if X

- m Γ— n

, then it Q

will m Γ— n

, and if you write where is , then will have columns as a base for zero space . However, mine is equal , so it will be the same, and then you won't be able to break it down into any correct parts, so I can't seem to find vectors in zero space.Q = [Q1, Q2]

Q1

m Γ— m

Q2

X

X

4 Γ— 4

Q

I don't understand how to get the base for nullspace from QR decomposition, or this just won't work for square matrices with non-trivial kernels?

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

Here is the real complete 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)

      

+3


source to share





All Articles