from formu_lib import *
import numpy as np
A=np.array([[-55,-5,12],
[21,36,-13],
[24,7,47]])
b=np.array([41,52,12])
w=lambda t:0.1*t
xs,ys,ts=[],[],[]
for i in range(1,20):
_,err=SORIter(A,b,w(i))
xs.append(list(range(len(err+1))))
ys.append(err)
ts.append(f"SOR iter error with w={w(i)}")
print(f"i={i}")
- w=0.1~0.5
- w=0.6~1.0
- w=1.1~1.5
- w=1.6~1.9
结论:w 接近1.8时,算法就不收敛了,迭代次数越多,误差越大.
标签:迭代,err,0.1,线性方程组,数值,np,append From: https://www.cnblogs.com/aksoam/p/18347935