```python
import unittest
import sympy as sym
from IPython.display import YouTubeVideo
```


```python
YouTubeVideo('MBhPaqKRehg', width=800, height=400)
```











```python
YouTubeVideo('NcIAd0ho43g', width=800, height=400)
```











```python
sym.init_printing(use_latex="mathjax")
```


```python
B = sym.Matrix([[1, 2, 0], [3, 4, 0], [7, 5, 0], [0,0, 0]])
```


```python
B
```




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




```python
foods = sym.Matrix([[260, 51, 70], [9, 5.4, 15], [5, 5.2, 0]])
b =sym.Matrix([40, 30, 10])
```


```python
B.echelon_form()
```




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




```python
B[0,:]
```




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




```python
A = sym.diag(3, 4, 5)
```


```python
type(A)
```




    sympy.matrices.dense.MutableDenseMatrix




```python
B * A
```




$$\left[\begin{matrix}3 & 8 & 0\\9 & 16 & 0\\21 & 20 & 0\\0 & 0 & 0\end{matrix}\right]$$




```python
sym.ones(4) + sym.eye(4)
```




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




```python
sym.zeros(3)
```




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




```python
sym.Matrix([[3,4],[5,7]])
```




$$\left[\begin{matrix}3 & 4\\5 & 7\end{matrix}\right]$$




```python
sym.eye(3)
```




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




```python
YouTubeVideo('SNdzRI_yqIo', width=800, height=400)
```











```python
x, y = sym.symbols("x y")
```


```python
x**2
```




$$x^{2}$$




```python
a11, a12, a21, a22, b11, b12, b21, b22 = sym.symbols("a11, a12, a21, a22, b11, b12, b21, b22")
```


```python
A = sym.Matrix([[0, -2], [6, 1]])
B = sym.Matrix([[-1, 5, 5], [0,0,0]])
```


```python
A , B
```




$$\left ( \left[\begin{matrix}0 & -2\\6 & 1\end{matrix}\right], \quad \left[\begin{matrix}-1 & 5 & 5\\0 & 0 & 0\end{matrix}\right]\right )$$




```python
A * B
```




$$\left[\begin{matrix}0 & 0 & 0\\-6 & 30 & 30\end{matrix}\right]$$




```python
A * 3
```




$$\left[\begin{matrix}0 & -6\\18 & 3\end{matrix}\right]$$




```python
A + B
```


```python
A * B 
```




$$\left[\begin{matrix}a_{11} b_{11} + a_{12} b_{21} & a_{11} b_{12} + a_{12} b_{22}\\a_{21} b_{11} + a_{22} b_{21} & a_{21} b_{12} + a_{22} b_{22}\end{matrix}\right]$$




```python

```


```python

```


```python

```


```python
YouTubeVideo('rqP1EWoAiVc', width=800, height=400)
```











```python
from sympy import Matrix
```


```python
A = Matrix([[1,2,3], [4,5,6], [10, 11, 9]])
A
```




$$\left[\begin{matrix}1 & 2 & 3\\4 & 5 & 6\\10 & 11 & 9\end{matrix}\right]$$




```python
L, U, _ = A.LUdecomposition()
```


```python
A == L*U
```




    True




```python
L
```




$$\left[\begin{matrix}1 & 0 & 0\\4 & 1 & 0\\10 & 3 & 1\end{matrix}\right]$$




```python
U
```




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




```python
YouTubeVideo('vvq4VdYQOJY', width=800, height=400)
```











```python
from sympy import Matrix, init_printing
```

$$ A \underline{x} = \underline{b} $$


```python
A1 = Matrix([[3, 4, 1, 0], [4, 5, 0, 1]])
A1
```




$$\left[\begin{matrix}3 & 4 & 1 & 0\\4 & 5 & 0 & 1\end{matrix}\right]$$




```python
A1.rref()
```




$$\left ( \left[\begin{matrix}1 & 0 & -5 & 4\\0 & 1 & 4 & -3\end{matrix}\right], \quad \left ( 0, \quad 1\right )\right )$$




```python
A2 = Matrix([[3, 4], [4, 5]])
A2.inv()
```




$$\left[\begin{matrix}-5 & 4\\4 & -3\end{matrix}\right]$$




```python
A2.inv(method='LU')
```




$$\left[\begin{matrix}-5 & 4\\4 & -3\end{matrix}\right]$$




```python

```


```python
YouTubeVideo('FgXp28Abllw', width=800, height=400)
```











```python

```


```python

```


```python

```


```python
def add(a, b):
    return a + b
```


```python
class TestNotebook(unittest.TestCase):

    def test_add(self):
        self.assertEqual(add(2, 2), 4)
    def test_type(self):
        self.assertIsInstance(add(1, 1), int)


unittest.main(argv=[''], verbosity=2, exit=False)
```

8a78412497bc3059740dfc3c035a05bca3290991
ipynb
Jupyter Notebook
matrix_operations.ipynb
allaccountstaken/sympy_linear_algebra
0b3ff4bd54b90f7ac02feef79692770c3b47bb46
MIT
matrix_operations.ipynb
allaccountstaken/sympy_linear_algebra
0b3ff4bd54b90f7ac02feef79692770c3b47bb46
MIT
matrix_operations.ipynb
allaccountstaken/sympy_linear_algebra
0b3ff4bd54b90f7ac02feef79692770c3b47bb46
MIT
Qwen/Qwen-72B
1. YES
2. YES