【数值计算方法】线性方程组的迭代解法-数值实验
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时,算法就不收敛了,迭代次数越多,误差越大.
本文来自博客园,作者:FE-有限元鹰,转载请注明原文链接:https://www.cnblogs.com/aksoam/p/18347935