例题2.34

例题2.34代码

``
import numpy as np
a = np.array([[3, 1], [1, 2]])
b = np.array([9, 8])
x1 = np.linalg.inv(a) @ b #第一种解法

上面语句中@表示矩阵乘法

x2 = np.linalg.solve(a, b) #第二种解法
print(x1); print(x2)

![](https://img2024.cnblogs.com/blog/3513989/202410/3513989-20241022220339517-74177722.png)
![](https://img2024.cnblogs.com/blog/3513989/202410/3513989-20241027194129768-1409198954.png)
posted @ 2024-10-22 22:04  等我刷把宗师  阅读(1)  评论(0编辑  收藏  举报