```python
import numpy as np
import numpy.linalg as linalg
from sympy import Matrix
```


```python
a = [[1,2], [3,4]]
```


```python
a
```




    [[1, 2], [3, 4]]




```python
a = np.array(a)
```


```python
a
```




    array([[1, 2],
           [3, 4]])




```python
a.shape
```




    (2, 2)




```python
mtx = Matrix(a)
```


```python
mtx.rref()
```




    (Matrix([
     [1, 0],
     [0, 1]]),
     (0, 1))




```python
a
```




    array([[1, 2],
           [3, 4]])




```python
linalg.inv(a)
```




    array([[-2. ,  1. ],
           [ 1.5, -0.5]])




```python
a
```




    array([[1, 2],
           [3, 4]])




```python
mtx.inv()
```




$\displaystyle \left[\begin{matrix}-2 & 1\\\frac{3}{2} & - \frac{1}{2}\end{matrix}\right]$




```python
mtx_b = Matrix([[3,1], [2,1]])
```


```python
mtx_b
```




$\displaystyle \left[\begin{matrix}3 & 1\\2 & 1\end{matrix}\right]$




```python
mtx_b.inv()
```




$\displaystyle \left[\begin{matrix}1 & -1\\-2 & 3\end{matrix}\right]$




```python
mtx_b.shape
```




    (2, 2)




```python
a.shape
```




    (2, 2)




```python
mtx_b.adjoint()
```




$\displaystyle \left[\begin{matrix}3 & 2\\1 & 1\end{matrix}\right]$




```python
mtx.det()
```




$\displaystyle -2$




```python
mtx.cofactor_matrix()
```




$\displaystyle \left[\begin{matrix}4 & -3\\-2 & 1\end{matrix}\right]$




```python
mtx_b
```




$\displaystyle \left[\begin{matrix}3 & 1\\2 & 1\end{matrix}\right]$




```python
mtx_b_inv = mtx_b.inv()
```


```python
mtx_b_inv
```




$\displaystyle \left[\begin{matrix}1 & -1\\-2 & 3\end{matrix}\right]$




```python
I = mtx_b * mtx_b_inv
```


```python
I
```




$\displaystyle \left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right]$




```python
I_ = mtx_b_inv * mtx_b
```


```python
I_
```




$\displaystyle \left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right]$




```python
I == I_
```




    True




```python
mtx_c = Matrix([[3,1,-1], [2,-2,0],[1,2,-1]])
```


```python
mtx_c

```




$\displaystyle \left[\begin{matrix}3 & 1 & -1\\2 & -2 & 0\\1 & 2 & -1\end{matrix}\right]$




```python
cofactor = mtx_c.cofactor_matrix()
```


```python
cofactor
```




$\displaystyle \left[\begin{matrix}2 & 2 & 6\\-1 & -2 & -5\\-2 & -2 & -8\end{matrix}\right]$




```python
mtx_c.cofactorMatrix()
```




$\displaystyle \left[\begin{matrix}2 & 2 & 6\\-1 & -2 & -5\\-2 & -2 & -8\end{matrix}\right]$




```python
mtx_c.adjoint()
```




$\displaystyle \left[\begin{matrix}3 & 2 & 1\\1 & -2 & 2\\-1 & 0 & -1\end{matrix}\right]$




```python
cofactor.transpose()
```




$\displaystyle \left[\begin{matrix}2 & -1 & -2\\2 & -2 & -2\\6 & -5 & -8\end{matrix}\right]$




```python
mtx_c.adjugate()
```




$\displaystyle \left[\begin{matrix}2 & -1 & -2\\2 & -2 & -2\\6 & -5 & -8\end{matrix}\right]$




```python
a = Matrix([[1,2], [3,4]])
b = Matrix([[5,6], [7,8]])
```


```python
a
```




$\displaystyle \left[\begin{matrix}1 & 2\\3 & 4\end{matrix}\right]$




```python
b
```




$\displaystyle \left[\begin{matrix}5 & 6\\7 & 8\end{matrix}\right]$




```python
c = a * b
```


```python
c
```




$\displaystyle \left[\begin{matrix}19 & 22\\43 & 50\end{matrix}\right]$




```python
c.det()
```




$\displaystyle 4$




```python
a.det() * b.det()
```




$\displaystyle 4$




```python
inv = a.adjugate()/a.det()
```


```python
inv
```




$\displaystyle \left[\begin{matrix}-2 & 1\\\frac{3}{2} & - \frac{1}{2}\end{matrix}\right]$




```python
a.inv()
```




$\displaystyle \left[\begin{matrix}-2 & 1\\\frac{3}{2} & - \frac{1}{2}\end{matrix}\right]$




```python
a
```




$\displaystyle \left[\begin{matrix}1 & 2\\3 & 4\end{matrix}\right]$




```python
a.rref()
```




    (Matrix([
     [1, 0],
     [0, 1]]),
     (0, 1))




```python
a.echelon_form()
```




$\displaystyle \left[\begin{matrix}1 & 2\\0 & -2\end{matrix}\right]$




```python
a.rref()
```




    (Matrix([
     [1, 0],
     [0, 1]]),
     (0, 1))




```python
rref = a.rref()
```


```python
rref
```




    (Matrix([
     [1, 0],
     [0, 1]]),
     (0, 1))




```python
a.rank()
```




    2




```python

```

2ae849e7e6bf9a1ba656ada7e07551864bba25ee
ipynb
Jupyter Notebook
matrix.ipynb
lgtejas/mfds
dc9569a970f963d298dbe56db58b090684558d7b
MIT
matrix.ipynb
lgtejas/mfds
dc9569a970f963d298dbe56db58b090684558d7b
MIT
matrix.ipynb
lgtejas/mfds
dc9569a970f963d298dbe56db58b090684558d7b
MIT
Qwen/Qwen-72B
1. YES
2. YES