我有问题np.linalg.solve求解(我也尝试过使用scipy)但是对于某些线性系统,答案是错误的。在我的程序中生成的系统示例:
Matrix A:
[[7.03894408e+00 1.34629120e+10 2.00000000e+10 1.14564392e+10 1.82002747e+10 1.73205081e+10] [1.34629120e+10 7.03894408e+00 1.82002747e+10 2.00000000e+10 2.23606798e+10 2.07665597e+10] [2.00000000e+10 1.82002747e+10 7.03894408e+00 1.67705098e+10 1.67705098e+10 2.23606798e+10] [1.14564392e+10 2.00000000e+10 1.67705098e+10 7.03894408e+00 1.73205081e+10 1.34629120e+10] [1.82002747e+10 2.23606798e+10 1.67705098e+10 1.73205081e+10 7.03894408e+00 1.95256242e+10] [1.73205081e+10 2.07665597e+10 2.23606798e+10 1.34629120e+10 1.95256242e+10 7.03894408e+00]]
Vector b:
[5.49316406e+42 9.62786249e+22 5.49316406e+42 8.66507624e+23 1.38770661e+25 7.66220239e+24]
Vector x from x = np.linalg.solve(A, b)
[-4.06597524e+32 2.80218361e+32 -2.68178425e+32 2.82035894e+32 1.75304606e+32 3.82470510e+31]
A*x from np.dot(A, x) that should be equal to b
[ 5.49316406e+42 9.28455029e+26 5.49316406e+42 6.18970020e+26 -6.18970020e+26 -1.23794004e+27]
对于某些系统,在向量b和A*x中有更多相等的元素
some verifications:
conditional number: np.linalg.cond(A) = 11.283698804140434
determinant of A: np.linalg.det(A) = -1.146617874355366e+62
norm of A: np.linalg.norm(A) = 99310120330.20604
norm of inv(A): np.linalg.norm(np.linalg.inv(A)) = 1.6365102872452848e-10
一些系统是正常的,解算器给出了正确的答案。你知道吗
谢谢你。你知道吗
你得到的答案不是错的。实际上,比较原始的
b
和重构的br
。。。你知道吗。。。我们得到的相对误差大约是机器精度的2.2倍。。。你知道吗
。。。这其实很准确。你知道吗
相关问题 更多 >
编程相关推荐