---
# System prepended metadata

title: 軟體實作

---

# 軟體實作
```=python
import numpy as np
X = np.array([range(1,82)])
Y = np.reshape(X,(9,9))
A = Y[3:8,2:7]
print(A)
I = np.eye(5)
B = A + 3*I
print(B)
from numpy.linalg import inv
C = inv(B)
print(C)
D = C @ B
print(D)
E = D - I
print(E)
absErr = np.sum(np.sum(np.abs(E)))
print(absErr)

```
```=python
import numpy as np
from numpy.linalg import inv
A = np.matrix([[2,5,1],[1,1,1],[3,1,1]])
invA = inv(A)
ans = invA @ np.matrix([[9],[0],[2]])
print(ans)
```
```=python
import numpy as np
from numpy.linalg import inv
A = np.matrix([[2,1],[1,1],[3,1],[0,1]])
b = np.matrix([[1.95],[-0.48],[4.53],[-2.95]])
AT = np.matrix.transpose(A)
B = AT @ A
invB = inv(B)
ans = invB @ AT @ b
print(ans)
```
```=python
import numpy as np
from numpy.linalg import eig
P = np.array([[0.6, 0.13],[0.4,0.87]])
value, vector = eig(P)
print(value)
print(vector[:,1])
a,b = abs(vector[:,1])
x = np.array([[1],[0]])
r = a / (a+b)
print(r)

```