C36 Find the rank and nullity of the matrix A
\[\mathbf{A} = \left[\begin{array} {rrr} 1 & 2 & 1 & 1 & 1 \\ 1 & 3 & 2 & 0 & 4 \\ 1 & 2 & 1 & 1 & 1 \\ \end{array}\right]\]
rankA = number of pivots in the row echelon form of A.
Let’s substract 2nd and 3rd row with 1st row values
\[\mathbf{A} = \left[\begin{array} {rrr} 1 & 2 & 1 & 1 & 1 \\ 0 & 1 & 1 & -1 & 3 \\ 0 & 0 & 0 & 0 & 0 \\ \end{array}\right]\]
Since, the last row is zero, we need to modify first row, divide by 2 (1/2 or half)
\[\mathbf{A} = \left[\begin{array} {rrr} 0.5 & 1 & 0.5 & 0.5 & 0.5 \\ 0 & 1 & 1 & -1 & 3 \\ 0 & 0 & 0 & 0 & 0 \\ \end{array}\right]\]
Now, substract pivot row from 1st row
\[\mathbf{A} = \left[\begin{array} {rrr} 0.5 & 0 & -0.5 & 1.5 & 2.5 \\ 0 & 1 & 1 & -1 & 3 \\ 0 & 0 & 0 & 0 & 0 \\ \end{array}\right]\]
Then double the value of 1st row
\[\mathbf{A} = \left[\begin{array} {rrr} 1 & 0 & -1 & 3 & 5 \\ 0 & 1 & 1 & -1 & 3 \\ 0 & 0 & 0 & 0 & 0 \\ \end{array}\right]\]
rankA + nullityA = number of columns of A.
\(r(A)+n(A) = n\)
Solution:
\[ r(A) = 2 \\ n = 5 \\ n(A) = n - r(A) \\ n(A) = 5 -2 \\ n(A) = 3\]
The rank of the given matrix is 2 and the nullity is 3.
#Also, tried some Quick r functions (https://www.statmethods.net/advstats/matrix.html)
#QR decomposition of A.
# Finding the rank of A
A <- matrix(c(1,2,1,1,1,
1,3,2,0,4,
1,2,1,1,1), 3, byrow=T)
print(A)
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 2 1 1 1
## [2,] 1 3 2 0 4
## [3,] 1 2 1 1 1
#rank of A
qr(A)$rank
## [1] 2
# information on the pivoting strategy used.
qr(A)$pivot
## [1] 1 2 3 4 5
#number of columns of A
ncol(A)
## [1] 5
#Calculating nullity of A
nullityA = ncol(A) - qr(A)$rank
nullityA
## [1] 3