Rank of a Matrix
The number of linearly independent columns of a matrix $A \in \mathbb{R}^{m \times n}$ equals the number of linearly independent rows and is called the rank of $A$ and is denoted by $rk(A)$.
- $rk(A) = rk(A^T)$, i.e., the column rank equals the row rank.
- The columns of $A \in \mathbb{R}^{m \times n}$ span a subspace $U \subseteq \mathbb{R}^m$ with $dim(U) =rk(A)$. Later we will call this subspace the image or range. A basis of $U$ can be found by applying Gaussian elimination to $A $ to identify the pivot columns.
- The rows of $A \in \mathbb{R}^{m \times n}$ span a subspace $W \in \mathbb{R}^n$ with $dim(W) =rk(A)$. A basis of W can be found by applying Gaussian elimination to $A^T$.
- For all $A \in \mathbb{R}^{n \times n}$ it holds that $A$ is regular (invertible) if and only if $rk(A) = n$.
- For all $A \in \mathbb{R}^{m \times n}$ and all $ b \in \mathbb{R}^m$ it holds that the linear equation system $Ax = b$ can be solved if and only if $ rk(A) = rk(A|b)$, where $A|b$ denotes the augmented system.
- For $A \in \mathbb{R}^{m \times n}$ the subspace $U \subseteq \mathbb{R}^n$ of solutions for $Ax = 0$ possesses dimension $n - rk(A)$. Later, we will call this subspace the kernel or the null space.
- A matrix $A \in \mathbb{R}^{m \times n}$ has full rank if its rank equals the largest possible rank for a matrix of the same dimensions. This means that the rank of a full-rank matrix is the lesser of the number of rows and columns, i.e.,$rk(A) = min(m, n)$. A matrix is said to be rank deficient if it does not have full rank.
Example:
$A=\displaystyle \left[\begin{matrix}1 & 0 & 1\\0 & 1 & 1\\0 & 0 & 0\end{matrix}\right]$
A has two linearly independent rows/columns so that $rk(A) = 2$.
find the rank
$A=\displaystyle \left[\begin{matrix}1 & 2 & 1\\-2 & -3 & 1\\3 & 5 & 0\end{matrix}\right]$
$A=\displaystyle \left[\begin{matrix}1 & 2 & 1\\-2 & -3 & 1\\3 & 5 & 0\end{matrix}\right]$
We can use Gaussian elimination to determine the rank
import sympy as sp
import numpy as np
row1=[1,2,1]
row2=[-2,-3,1]
row3=[3,5,0]
M = sp.Matrix((row1,row2,row3))
print("Coefficient Matrix")
display(M)
print(" Echelon Form")
display(M.echelon_form())
O/P
Coefficient Matrix
$\displaystyle \left[\begin{matrix}1 & 2 & 1\\-2 & -3 & 1\\3 & 5 & 0\end{matrix}\right]$
Echelon Form
$\displaystyle \left[\begin{matrix}1 & 2 & 1\\0 & 1 & 3\\0 & 0 & 0\end{matrix}\right]$
Here, we see that the number of linearly independent rows and columns is 2, such that $rk(A) = 2.$
determinent
An intuition for rank is to consider it the number of dimensions spanned by all of the vectors within a matrix. For example, a rank of 0 suggest all vectors span a point, a rank of 1 suggests all vectors span a line, a rank of 2 suggests all vectors span a two-dimensional plane. The rank is estimated numerically, often using a matrix decomposition method. A common approach is to use the Singular-Value Decomposition or SVD for short. NumPy provides the matrix rank() function for calculating the rank of an array. It uses the SVD method to estimate the rank. The example below demonstrates calculating the rank of a matrix with scalar values and another vector with all zero values.
# vector rank
from numpy import array
from numpy.linalg import matrix_rank
# rank
v1 = array([1,2,3])
print("v1");
print(v1)
vr1 = matrix_rank(v1)
print("Rank of v1")
print(vr1)
# zero rank
v2 = array([0,0,0,0,0])
print("v2")
print(v2)
vr2 = matrix_rank(v2)
print("Rank of v2")
print(vr2)
o/p:
v1
[1 2 3]
Rank of v1
1
v2
[0 0 0 0 0]
Rank of v2
0
# matrix rank
from numpy import array
from numpy.linalg import matrix_rank
# rank 0
M0 = array([[0,0],[0,0]])
mr0 = matrix_rank(M0)
print("M0 and Rank of M0")
print(M0)
print(mr0)
# rank 1
M1 = array([[1,2],[1,2]])
mr1 = matrix_rank(M1)
print("M1 and Rank of M1")
print(M1)
print(mr1)
# rank 2
M2 = array([[1,2],[3,4]])
mr2 = matrix_rank(M2)
print("M2 and Rank of M2")
print(M2)
print(mr2)
o/p:
M0 and Rank of M0
[[0 0]
[0 0]]
0
M1 and Rank of M1
[[1 2]
[1 2]]
1
M2 and Rank of M2
[[1 2]
[3 4]]
2
Rank and determinant using sympy
import sympy
M=sympy.Matrix([[1,2],[4,5]])
display(M)
print("determinent")
print(sympy.det(M))
print("rank")
print(sympy.Matrix.rank(M))
o/p
$\displaystyle \left[\begin{matrix}1 & 2\\4 & 5\end{matrix}\right]$determinent
-3
rank
2
Example ( University question)
Find the rank of the matrix
$A=\begin{bmatrix}1 & 2 & 3\\
2 &3 & 4\\
3 & 5 & 7
\end{bmatrix}$
Do the elementary row operations and convert into echelon form
$R_2=R_2-2R_1$
$R_3=R_3-3R_1$
$A=\begin{bmatrix}
1 & 2 & 3\\
0 &-1 & -2\\
0 & -1 & -2
\end{bmatrix}$
1 & 2 & 3\\
0 &-1 & -2\\
0 & -1 & -2
\end{bmatrix}$
$A=\begin{bmatrix}
1 & 2 & 3\\
0 &-1 & -2\\
0 & 0 & 0
\end{bmatrix}$
From the echelon form the number of non zero rows is 2 . So the rank is 2.
Example:
Comments
Post a Comment