## Linear Algebra


```python
%matplotlib inline
```


```python
import numpy as np
import matplotlib.pyplot as plt

import sympy  
```


```python
def plt_complex(numbers, colors, xlim = (-5, 5),ylim = (-5, 5)):
    plt.quiver(
        [0]*len(numbers),
        [0]*len(numbers),
        [number.real for number in numbers],
        [number.imag for number in numbers],
        scale = 1,
        scale_units = "xy",
        angles = "xy",
        color = colors)
    
    plt.gca().set_aspect("equal")
    plt.grid()
    plt.xlim(xlim)
    plt.ylim(ylim)
    plt.show()
```


```python
plt_complex([2+3j, 3 - 2j, 4], ["red", "blue", "grey"])
```


```python
x =sympy.symbols("x")
```


```python
sympy.solve((x-1)**2, x)
```




    [1]




```python
solutions = sympy.solve((x-3)*(x-5)+40+x**3)
```


```python
sol = [complex(solution) for solution in solutions]
```


```python
plt_complex(sol, ["red", "blue"], (-8, 8), (-8,8))
```


```python
sol = sympy.solve(x**36+1)
solutions = [complex(solution) for solution in sol]
plt_complex(solutions, ["red", "blue", "green"], (-1.3, 1.3), (-1.3,1.3))
```

## Vectors
#### scalar product


```python
np.dot([2,3], [1,5])
```




    17




```python
scalar = np.dot([2,3,0],[1,5,0])
vector = np.cross([2,3,0],[1,5,0])

print(scalar)
print(vector)
```

    17
    [0 0 7]



```python
np.dot(np.random.randint(2,20,10), np.random.randint(2,20,10)) # 10 dimentional vectors
```




    485




```python
A = np.array([
    [2,3,7],
    [8,9,1]
])
B = np.array([
    [1,-3,0],
    [2,-4,1]
])
```


```python
A*B   #Adamar multiplication
```




    array([[  2,  -9,   0],
           [ 16, -36,   1]])




```python
A @B.T    #Vectors multiplication
```




    array([[ -7,  -1],
           [-19, -19]])



732cc25a333fa0df7cb8212163f9004cdc976bdc
ipynb
Jupyter Notebook
MathConceptsForDevelopers/03.LinearAlgebraLecture/Linear Algebra Lecture.ipynb
LuGeorgiev/Python-SoftUni
545daa4684b7a333f78dd958f8e9d13263575ddf
MIT
MathConceptsForDevelopers/03.LinearAlgebraLecture/Linear Algebra Lecture.ipynb
LuGeorgiev/Python-SoftUni
545daa4684b7a333f78dd958f8e9d13263575ddf
MIT
MathConceptsForDevelopers/03.LinearAlgebraLecture/Linear Algebra Lecture.ipynb
LuGeorgiev/Python-SoftUni
545daa4684b7a333f78dd958f8e9d13263575ddf
MIT
Qwen/Qwen-72B
1. YES
2. YES