# Section 4.9 $\quad$ Rank of a Matrix

>**Definition** Let
\begin{equation*}
  A =
  \left[
    \begin{array}{cccc}
      a_{11} & a_{12} & \cdots & a_{1n} \\
      a_{21} & a_{22} & \cdots & a_{2n} \\
      \vdots & \vdots & \ddots & \vdots \\
      a_{m1} & a_{m2} & \cdots & a_{mn} \\
    \end{array}
  \right]
\end{equation*}
be an $m\times n$ matrix.
- The rows of $A$, <br /><br />
- The columns of $A$, <br /><br />

**Remark** If $A$ and $B$ are row equivalent matrices, then<br /><br /><br /><br /><br /><br /><br />

We can use this remark to find a basis for a subspace spanned by a given set of vectors.

### Example 1

Find a basis for the subspace $V$ of $\mathbb{R}_5$ that is spanned by $S = \{\mathbf{v}_1,\mathbf{v}_2,\mathbf{v}_3,\mathbf{v}_4\}$ where
\begin{equation*}
   \mathbf{v}_1 = [1~ -2~ 0 ~ 3~ -4],~~~
   \mathbf{v}_2 = [3~ 2~ 8 ~ 1~ 4],~~~
   \mathbf{v}_3 = [2~ 3~ 7 ~ 2~ 3],~~~
   \mathbf{v}_4 = [-1~ 2~ 0 ~ 4~ 3],~~~
\end{equation*}


```python
from sympy import *

A = Matrix([[1, -2, 0, 3, -4], [3, 2, 8, 1, 4], [2, 3, 7, 2, 3], [-1, 2, 0, 4, 3]]);

A.rref()
```




    (Matrix([
     [1, 0, 2, 0, 0],
     [0, 1, 1, 0, 0],
     [0, 0, 0, 1, 0],
     [0, 0, 0, 0, 1]]), [0, 1, 3, 4])



**Remark**
- <br /><br />
- <br /><br />

### Example 2

Let $V$ be the subspace of Example $1$. Given that the vector $\mathbf{v} = [5~~4~~14~~6~~3]$ is in $V$, write $\mathbf{v}$ as a linear combinations of the base determined by Example $1$.


```python
from sympy import *

A = Matrix([[1, -2, 0, 3, -4], [3, 2, 8, 1, 4], [2, 3, 7, 2, 3], [-1, 2, 0, 4, 3]]);
B = A.rref()[0].T;
x1, x2, x3, x4 = symbols('x1 x2 x3 x4');
x = Matrix([x1, x2, x3, x4]);
Bx = B.dot(x);

solve(Matrix(Bx) - Matrix([5, 4, 14, 6, 3]))
```




    [{x3: 6, x2: 4, x4: 3, x1: 5}]



>**Definition** The dimension of the row (column) space of $A$ is called <br /><br /><br /><br />

**Remark** If $A$ and $B$ are row equivalent,<br /><br /><br /><br />

### Example 3

Compute the row rank of $A$ given by
\begin{equation*}
  A =
  \left[
    \begin{array}{ccccc}
      1 & -2 & 0 & 3 & -4 \\
      3 & 2 & 8 & 1 & 4 \\
      2 & 3 & 7 & 2 & 3 \\
      -1& 2 & 0 & 4 & -3 \\
    \end{array}
  \right]
\end{equation*}


```python
from sympy import *

A = Matrix([[1, -2, 0, 3, -4], [3, 2, 8, 1, 4], [2, 3, 7, 2, 3], [-1, 2, 0, 4, -3]]);

A.rank()
```




    3



### Example 4

Compute the column rank of $A$ in Example 3.


```python
from sympy import *

A = Matrix([[1, -2, 0, 3, -4], [3, 2, 8, 1, 4], [2, 3, 7, 2, 3], [-1, 2, 0, 4, -3]]);

A.rank()
```




    3



>**Theorem** Let $A$ be an $m\times n$ matrix. Then<br /><br /><br /><br />

31b0c6e13e910cfe7aac45343394cbd481411da5
ipynb
Jupyter Notebook
Jupyter_Notes/Lecture23_Sec4-9_RankMatrixPart1.ipynb
xiuquan0418/MAT341
2fb7ec4e5f0771f10719cb5e4a00a7ab07c49b59
MIT
Jupyter_Notes/Lecture23_Sec4-9_RankMatrixPart1.ipynb
xiuquan0418/MAT341
2fb7ec4e5f0771f10719cb5e4a00a7ab07c49b59
MIT
Jupyter_Notes/Lecture23_Sec4-9_RankMatrixPart1.ipynb
xiuquan0418/MAT341
2fb7ec4e5f0771f10719cb5e4a00a7ab07c49b59
MIT
Qwen/Qwen-72B
1. YES
2. YES