# SciPy
## Solve Linear Equation


```python
#import 
from scipy import linalg as sla
import numpy as np
import sympy as sy
sy.init_printing()

from matplotlib import pyplot as plt
from pprint import pprint
```


```python
A=sy.Matrix([[3,2],[-3,5]])
b=sy.Matrix([8,-1])
```


```python
A, b
```

## try %timeit


```python
%timeit x=A.inv() * b
```

    998 µs ± 60.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)



```python
%timeit x=A.solve(b)
```

    1.23 ms ± 196 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)



```python
%timeit x=A.LUsolve(b)
```

    1.06 ms ± 522 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)



```python
A=np.array(A).astype(float)
b=np.array(b).astype(float)
print(A)
print(b)
```

    [[ 3.  2.]
     [-3.  5.]]
    [[ 8.]
     [-1.]]



```python
%timeit x=sla.solve(A,b)
```

    199 µs ± 53.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)



```python
# Handle Exception
```


```python
A=sy.Matrix([[3,2],[6,4 ]])
b=sy.Matrix([8,-1])
```


```python
A,b
```


```python
x=A.LUsolve(b)
x
```


```python
A=np.array(A).astype(float)
b=np.array(b).astype(float)
print(A)
print(b)
```

    [[ 3.  2.]
     [ 6.  4.]]
    [[ 8.]
     [-1.]]



```python
x=sla.solve(A,b)
```

e353aa85bbea4c9f413e903494156f432237d72e
ipynb
Jupyter Notebook
scipyExercise/Solve Linear Equation.ipynb
terasakisatoshi/pythonCodes
baee095ecee96f6b5ec6431267cdc6c40512a542
MIT
scipyExercise/Solve Linear Equation.ipynb
terasakisatoshi/pythonCodes
baee095ecee96f6b5ec6431267cdc6c40512a542
MIT
scipyExercise/Solve Linear Equation.ipynb
terasakisatoshi/pythonCodes
baee095ecee96f6b5ec6431267cdc6c40512a542
MIT
Qwen/Qwen-72B
1. YES
2. YES