习题2.7(1)
1.代码实现
点击查看代码
import numpy as np
a=np.array([[4,2,-1],[3,-1,2],[11,2,0]])
b=np.array([2,10,8])
#唯一解
x1=np.linalg.inv(a)@b
x2=np.linalg.solve(a,b)
print(x1);print(x2);
#最小二乘解
x3=np.linalg.pinv(a)@b
print("最小二乘解为:",np.round(x3,4))
print("学号:3014")
2.运行结果