# coding: utf-8 # # Computing the Nullspace # In[16]: import numpy as np import numpy.linalg as la # In[17]: n = 5 np.random.seed(25) A = np.random.randn(n, n) # Decrease the rank A[4] = A[0] + 5 * A[2] A[1] = 3 * A[0] -2 * A[3] # In[18]: from m_echelon import m_echelon # In[29]: M, U = m_echelon(A.T) # In[30]: la.norm( M.dot(A.T) - U) # In[31]: U.round(3) # Now define `NUT` as vectors spanning the nullspace of $N(U^T)$. # In[32]: NUT = np.eye(n)[:, 3:] NUT # Check that it's actually a nullspace: # In[33]: U.T.dot(NUT) # Now define `NA` as some vectors spanning $N(A)$: # In[34]: NA = M.T.dot(NUT) # And check: # In[35]: A.dot(NA) # In[ ]: