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時,演算法就不收斂了,迭代次數越多,誤差越大.