Skip to main content

Row space, Column space and Null space

Row Space

The span of row vectors of any matrix, represented as a vector space is called row space of that matrix.
or
If we represent individual row as a vector, then the vector space formed by set of linear combination of all those vectors will be called row space of that matrix.

Assuming a 3x3 matrix $A=\begin{bmatrix}
1& 2 & 3 \\
4 &5& 6\\
7& 8& 9
\end{bmatrix}$


Then the row space is Span of these row vectors .
$Span( v1,v2,v3)$
where $v1=(1,2,3), v2=(4,5,6),v3=(7,8,9)$

If there are linearly depended vectors, we have to avoid those vectors.Linearly independent vectors can be found by converting the vectors into row reduced echelon form.For example consider

$A=\begin{bmatrix}
1& 2 & 3 \\
2 &4& 6\\
1& 1& 0
\end{bmatrix}$


After row reduction
$A=\begin{bmatrix}
1& 0 & -3 \\
0 &1& 3\\
0& 0& 0
\end{bmatrix}$


So the row space is the span of $[1,0,-3]$ and $[0,1,3]$.

Note: we can find transpose of $A$ and do the row reduction and get the pivot column which corresponds to the basis of the row space of the matrix.

Column Space

Similar to row space, column space is a vector space formed by set of linear combination of all column vectors of the matrix.

We can find the linearly independent vectors by row reduction and find the columns corresponds to the pivot column.

$A=\begin{bmatrix}
1& 2 & 3 \\
2 &4& 6\\
1& 1& 0
\end{bmatrix}$

After row reduction 
$A=\begin{bmatrix}
1& 0 & -3 \\
0 &1& 3\\
0& 0& 0
\end{bmatrix}$

The first and second columns are the pivot column.So the column space is the span of  $[1,2,1]$ and  $[2,4,1]$. the third column is a dependent column which is a linear combination of first two.

Both of these spaces have same dimension (same number of independent vectors) and that dimension is equal to rank of matrix.

Because, rank of matrix is maximum number of linearly independent vectors in rows or columns and dimension is maximum number of linearly independent vectors in a vector space (like column space or row space).

Rows and columns of a matrix have same rank so the have same dimension.

Null space

We are familiar with matrix representation of system of linear equations.
$Ax=0$


Here $A$ is coefficient matrix, $x$ is variable vector and 0 represents a vector of zeros.We can also find it’s solution (values of variables for which the equation above is satisfied) using Gaussian Elimination algorithm.


If we take a set of all possible solution vectors (all possible values of $x$), then the vector space formed out of that set will be called null space.
Or
Null space contains all possible solutions of a given system of linear equations.Taking an example
Solution vector of system of linear equations above is
So this system of linear equations has two vectors in null space.[0,0] and [2,1].
Null space contains all the linear combinations of solution.Null space always contains zero vector.
Red line represents the null space of system of linear equations

Nullity

Dimension of null space is called nullity.
Nullity of the system above is 1.

Index theorem(Rank Nullity Theorem): For an $m \times n$  matrix  $A$,

$rank(A) + nullity(A) = n$

Null Space ( Python code)
from sympy import Matrix
M = Matrix([[1, 3, 0], [-2, -6, 0], [3, 9, 6]])
M.nullspace()
[Matrix([
[-3],
[ 1],
[ 0]])]

Finding nullity ( python code)
from sympy import Matrix
A = [[1, 2, 0], [2, 4, 0], [3, 6, 1]]
A = Matrix(A)
# Number of Columns
NoC = A.shape[1]

# Rank of A
rank = A.rank()

# Nullity of the Matrix
nullity = NoC - rank

print("Nullity : ", nullity)

Find a basis for the row space, column space and null space of the matrix given below ( university qn)

$A=\begin{bmatrix}
1& 3 & 0 \\
0 &0 & 1\\
0& 0& 0 \\
0 & 0 & 0
\end{bmatrix}$

The basis for the row space of $A$ is the two independent rows $(1,3,0)$ and $(0,0,1)$
The basis  for the column space of $A$ corresponds to the two pivot columns $(1,0,0,0)$ and $(0,1,0,0)$
The basis for the null space of $A$ is $(3,-1,0)$



Comments

Popular posts from this blog

Mathematics for Machine Learning- CST 284 - KTU Minor Notes - Dr Binu V P

  Introduction About Me Syllabus Course Outcomes and Model Question Paper Question Paper July 2021 and evaluation scheme Question Paper June 2022 and evaluation scheme Overview of Machine Learning What is Machine Learning (video) Learn the Seven Steps in Machine Learning (video) Linear Algebra in Machine Learning Module I- Linear Algebra 1.Geometry of Linear Equations (video-Gilbert Strang) 2.Elimination with Matrices (video-Gilbert Strang) 3.Solving System of equations using Gauss Elimination Method 4.Row Echelon form and Reduced Row Echelon Form -Python Code 5.Solving system of equations Python code 6. Practice problems Gauss Elimination ( contact) 7.Finding Inverse using Gauss Jordan Elimination  (video) 8.Finding Inverse using Gauss Jordan Elimination-Python code Vectors in Machine Learning- Basics 9.Vector spaces and sub spaces 10.Linear Independence 11.Linear Independence, Basis and Dimension (video) 12.Generating set basis and span 13.Rank of a Matrix 14.Linear Mapping and Matri

1.1 Solving system of equations using Gauss Elimination Method

Elementary Transformations Key to solving a system of linear equations are elementary transformations that keep the solution set the same, but that transform the equation system into a simpler form: Exchange of two equations (rows in the matrix representing the system of equations) Multiplication of an equation (row) with a constant  Addition of two equations (rows) Add a scalar multiple of one row to the other. Row Echelon Form A matrix is in row-echelon form if All rows that contain only zeros are at the bottom of the matrix; correspondingly,all rows that contain at least one nonzero element are on top of rows that contain only zeros. Looking at nonzero rows only, the first nonzero number from the left pivot (also called the pivot or the leading coefficient) is always strictly to the right of the  pivot of the row above it. The row-echelon form is where the leading (first non-zero) entry of each row has only zeroes below it. These leading entries are called pivots Example: $\begin

4.3 Sum Rule, Product Rule, and Bayes’ Theorem

 We think of probability theory as an extension to logical reasoning Probabilistic modeling  provides a principled foundation for designing machine learning methods. Once we have defined probability distributions corresponding to the uncertainties of the data and our problem, it turns out that there are only two fundamental rules, the sum rule and the product rule. Let $p(x,y)$ is the joint distribution of the two random variables $x, y$. The distributions $p(x)$ and $p(y)$ are the corresponding marginal distributions, and $p(y |x)$ is the conditional distribution of $y$ given $x$. Sum Rule The addition rule states the probability of two events is the sum of the probability that either will happen minus the probability that both will happen. The addition rule is: $P(A∪B)=P(A)+P(B)−P(A∩B)$ Suppose $A$ and $B$ are disjoint, their intersection is empty. Then the probability of their intersection is zero. In symbols:  $P(A∩B)=0$  The addition law then simplifies to: $P(A∪B)=P(A)+P(B)$  wh