# Mathematics for Machine Learning: Linear Algebra
## Week1
## Module 1:

### The relationship between machine learning, linear algebra, and vectors and matrices

#### Motivations for linear algebra


```python
from sympy import solve, Poly, Eq, Function, exp

from sympy.abc import x, y, z, a, b
```

$2a + 3b = 8$

$10a +1b = 13$


```python
solve((2 * a + 3* b- 1, 10 * a + b - 13), a, b)
```




    {a: 19/14, b: -4/7}



$\begin{pmatrix} 2 & 3 \\ 10 & 1 \end{pmatrix} \begin{bmatrix} a \\ b \end{bmatrix} = \begin{bmatrix} 8 \\ 13 \end{bmatrix}$ 

## Getting a handle on vectors

# Operations with vectors


```python
import numpy as np
r = [3,2]
s = [-1,2]
print(f'r + s = {np.add(r,s)}')
print(f's + r = {np.add(s,r)}')
```

    r + s = [2 4]
    s + r = [2 4]



```python
np.arange(9.0)
```




    array([0., 1., 2., 3., 4., 5., 6., 7., 8.])




```python
np.arange(9.0).reshape((3, 3))
```




    array([[0., 1., 2.],
           [3., 4., 5.],
           [6., 7., 8.]])




```python
np.arange(3.0)
```




    array([0., 1., 2.])




```python
x1 = np.arange(9.0).reshape((3, 3))

x2 = np.arange(3.0)

x1 + x2
```




    array([[ 0.,  2.,  4.],
           [ 3.,  5.,  7.],
           [ 6.,  8., 10.]])




```python
r2 = [2*x for x in r]
print(f'2*r = {r2}')
```

    2*r = [6, 4]



```python
np.array([1, 2, 3]) * 2
```




    array([2, 4, 6])




```python
r = np.array([3,2])
s = np.array([-1,2])
```


```python
print(f' r-r = {r-r}')
print(f' r-s = {r-s}')
print(f' s-r = {s-r}')
```

     r-r = [0 0]
     r-s = [4 0]
     s-r = [-4  0]



```python
house = np.array([120,2,1,150])
2*house
```




    array([240,   4,   2, 300])




```python
house + house
```




    array([240,   4,   2, 300])




```python

```

795b8dfa06cd09221bfcd71467ae0e1a332374ed
ipynb
Jupyter Notebook
week1/Module1/Module_1.ipynb
FarhadManiCodes/Math_for_ML_Coursera
68f06d7be417d625f60a7257e81242084c0cc7d9
MIT
week1/Module1/Module_1.ipynb
FarhadManiCodes/Math_for_ML_Coursera
68f06d7be417d625f60a7257e81242084c0cc7d9
MIT
week1/Module1/Module_1.ipynb
FarhadManiCodes/Math_for_ML_Coursera
68f06d7be417d625f60a7257e81242084c0cc7d9
MIT
Qwen/Qwen-72B
1. YES
2. YES