<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Linear Algebra Review Notes
Step1:  Gaussian Elimination
one way to solve $ Ax = b $
For example
Step2:  Gaussian-Jordan Elimination
one way to find $A^{-1}$
For example
Step3:  Column space
All linear combinations of columns
$ Ax = b $ is solvable if and only if b is in the column space of A
Nullspace
Solutions about Ax = 0
Solutions about Ax = b
Rank
It is the number of pivots
It can tell the number of independent columns
It is the dimension of column space, row space and nullspace
For example
Step4:  Projection Matrix
$ P = A(A^TA)^{-1}A^T$ 
Transpose
$A^T (i,j) = A(j,i)$
For example
<ASSISTANT_TASK:>
Python Code:
import numpy as np
Explanation: Linear Algebra Review Notes
End of explanation
A = np.array([[1,1,1], [3,1,2], [2,3,4]])
b = np.array([6, 11, 20])
A
b
x = np.linalg.solve(A, b)
x
Explanation: Gaussian Elimination
one way to solve $ Ax = b $
For example:  
$ \begin{bmatrix}1 & 1 & 1 \ 3 & 1 & 2 \ 2 & 3 & 4 \ \end{bmatrix} \begin{bmatrix}x_1 \ x_2 \ x_3 \ \end{bmatrix} = \begin{bmatrix} 6 \ 11 \ 20 \ \end{bmatrix},\; A = \begin{bmatrix}1 & 1 & 1 \ 3 & 1 & 2 \ 2 & 3 & 4 \ \end{bmatrix},\; x = \begin{bmatrix}x_1 \ x_2 \ x_3 \ \end{bmatrix},\; b = \begin{bmatrix} 6 \ 11 \ 20 \ \end{bmatrix}$
$ [A, b] =  \begin{bmatrix}1 & 1 & 1 & 6\ 3 & 1 & 2 & 11\ 2 & 3 & 4 & 20\ \end{bmatrix}$
row2 - row1 * 3: $ \begin{bmatrix}1 & 1 & 1 & 6\ 0 & -2 & -1 & -7\ 2 & 3 & 4 & 20\ \end{bmatrix} $
row3 - row1 * 2: $ \begin{bmatrix}1 & 1 & 1 & 6\ 0 & -2 & -1 & -7\ 0 & 1 & 2 & 8\ \end{bmatrix} $
exchange row2 with row3: $ \begin{bmatrix}1 & 1 & 1 & 6\ 0 & 1 & 2 & 8\ 0 & -2 & -1 & -7\ \end{bmatrix} $
row1 - row2: $ \begin{bmatrix}1 & 0 & -1 & -2\ 0 & 1 & 2 & 8\ 0 & -2 & -1 & -7\ \end{bmatrix} $
row3 + row2 * 2: $ \begin{bmatrix}1 & 0 & -1 & -2\ 0 & 1 & 2 & 8\ 0 & 0 & 3 & 9\ \end{bmatrix} $
divide row3 by 3: $ \begin{bmatrix}1 & 0 & -1 & -2\ 0 & 1 & 2 & 8\ 0 & 0 & 1 & 3\ \end{bmatrix} $
row1 + row3: $ \begin{bmatrix}1 & 0 & 0 & 1\ 0 & 1 & 2 & 8\ 0 & 0 & 1 & 3\ \end{bmatrix} $
row2 - row3 * 2: $ \begin{bmatrix}1 & 0 & 0 & 1\ 0 & 1 & 0 & 2\ 0 & 0 & 1 & 3\ \end{bmatrix} $
$ x = \begin{bmatrix} x_1 \ x_2 \ x_3 \ \end{bmatrix} = \begin{bmatrix} 1 \ 2 \ 3 \ \end{bmatrix}$
End of explanation
A = np.matrix([[1,1,1], [3,1,2], [2,3,4]])
A
np.linalg.inv(A)
Explanation: Gaussian-Jordan Elimination
one way to find $A^{-1}$
For example:  
$ A = \begin{bmatrix}1 & 1 & 1 \ 3 & 1 & 2 \ 2 & 3 & 4 \ \end{bmatrix} $
$ [A, I] =  \begin{bmatrix}1 & 1 & 1 & 1 & 0 & 0\ 3 & 1 & 2 & 0 & 1 & 0\ 2 & 3 & 4 & 0 & 0 & 1\ \end{bmatrix}$
row2 - row1 * 3: $ \begin{bmatrix}1 & 1 & 1 & 1 & 0 & 0\ 0 & -2 & -1 & -3 & 1 & 0\ 2 & 3 & 4 & 0 & 0 & 1\ \end{bmatrix} $
row3 - row1 * 2: $ \begin{bmatrix}1 & 1 & 1 & 1 & 0 & 0\ 0 & -2 & -1 & -3 & 1 & 0\ 0 & 1 & 2 & -2 & 0 & 1\ \end{bmatrix} $
exchange row2 with row3: $ \begin{bmatrix}1 & 1 & 1 & 1 & 0 & 0\ 0 & 1 & 2 & -2 & 0 & 1\ 0 & -2 & -1 & -3 & 1 & 0\ \end{bmatrix} $
row1 - row2: $ \begin{bmatrix}1 & 0 & -1 & 3 & 0 & -1\ 0 & 1 & 2 & -2 & 0 & 1\ 0 & -2 & -1 & -3 & 1 & 0\ \end{bmatrix} $
row3 + row2 * 2: $ \begin{bmatrix}1 & 0 & -1 & 3 & 0 & -1\ 0 & 1 & 2 & -2 & 0 & 1\ 0 & 0 & 3 & -7 & 1 & 2\ \end{bmatrix} $
divide row3 by 3: $ \begin{bmatrix}1 & 0 & -1 & 3 & 0 & -1\ 0 & 1 & 2 & -2 & 0 & 1\ 0 & 0 & 1 & -\frac{7}{3} & \frac{1}{3} & \frac{2}{3} \ \end{bmatrix} $
row1 + row3: $ \begin{bmatrix}1 & 0 & 0 & \frac{2}{3} & \frac{1}{3} & -\frac{1}{3}\ 0 & 1 & 2 & -2 & 0 & 1\ 0 & 0 & 1 & -\frac{7}{3} & \frac{1}{3} & \frac{2}{3}\ \end{bmatrix} $
row2 - row3 * 2: $ \begin{bmatrix}1 & 0 & 0 & \frac{2}{3} & \frac{1}{3} & -\frac{1}{3}\ 0 & 1 & 0 & \frac{8}{3} & -\frac{2}{3} & -\frac{1}{3}\ 0 & 0 & 1 & -\frac{7}{3} & \frac{1}{3} & \frac{2}{3}\ \end{bmatrix} $
End of explanation
A = np.matrix([[1,2,2],[2,4,1],[3,6,4]])
A
np.linalg.matrix_rank(A)
Explanation: Column space
All linear combinations of columns
$ Ax = b $ is solvable if and only if b is in the column space of A
Nullspace
Solutions about Ax = 0
Solutions about Ax = b
Rank
It is the number of pivots
It can tell the number of independent columns
It is the dimension of column space, row space and nullspace
For example:
$ A = \begin{bmatrix}
       1 & 2 & 2 \
       2 & 4 & 1 \
       3 & 6 & 4 \
       \end{bmatrix}$
row2 - row1 * 2 : $\begin{bmatrix}
                    1 & 2 & 2 \
                    0 & 0 & -3 \
                    3 & 6 & 4 \
                    \end{bmatrix}$
row3 - row1 * 3 : $\begin{bmatrix}
                    1 & 2 & 2 \
                    0 & 0 & -3 \
                    0 & 0 & -2 \
                    \end{bmatrix}$
row3 - row2 * 3/2 : $ \begin{bmatrix}
                       1 & 2 & 2 \
                       0 & 0 & -3 \
                       0 & 0 & 0 \
                       \end{bmatrix} $
So, $ rank(A) = 2 $
End of explanation
A = np.matrix([[1,2,3], [4,5,6], [7,8,9]])
A
A.transpose()
A.T
Explanation: Projection Matrix
$ P = A(A^TA)^{-1}A^T$ 
Transpose
$A^T (i,j) = A(j,i)$
For example:
$ A = \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \ 7 & 8 & 9 \ \end{bmatrix} ,\; A^T = \begin{bmatrix}1 & 4 & 7 \ 2 & 5 & 8 \ 3 & 6 & 9 \ \end{bmatrix}$
End of explanation
<END_TASK>