資源描述:
《sor迭代(算法分析和數(shù)值算例)》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、SOR迭代基本思想Gauss-Seidel迭代的結(jié)果作為中間值,記為。SOR方法是將與上次計(jì)算的結(jié)果做加權(quán)平均作為最后結(jié)果。迭代格式為:或者算法:1.2.當(dāng)時,,結(jié)果仍然存儲在中。迭代次數(shù)3.計(jì)算誤差(真解已知)4.如果,則已達(dá)到精確度要求,否則繼續(xù)第2步數(shù)值結(jié)果,用Gauss消去法求的其真解為依次取,數(shù)值結(jié)果見下表0.251.0625-0.4843750.25751.09630625-0.4902011406250.2751.175625-0.5017031250.5156251.0078125-0.4980468750.5320738593751.00789303757813
2、-0.4982615086048830.5707968751.00143828125-0.499434160156250.5019531251.0009765625-0.4997558593750.5010702413951171.00048645756614-0.4999268919185720.493315839843750.998173633789063-0.5005588346923830.5002441406251.0001220703125-0.4999694824218750.5000931555814281.0000282191662-0.499994926807
3、1460.5001661653076171.00007465254028-0.4999235870821840.5000305175781251.00001525878906-0.4999961853027340.5000044717678541.0000016112524-0.4999997372982940.5000039129178161.00001462435077-0.500003619595320.5000038146972661.00000190734863-0.4999995231628420.500003630404680.999998540537497-0.5
4、00000039392656迭代次數(shù)656總結(jié)從實(shí)驗(yàn)結(jié)果可以看出,當(dāng)取松弛參數(shù)為1.03時只需五步就能達(dá)到所需精度。附錄(M文件)function[t,x]=successiive_over_Rellaxatiion(A,b,x0,w,rx)n=length(A);x=x0;%%x0為迭代初值e=norm(rx-x0,inf);%%rx為真解,e為誤差t=0;%%t為迭代次數(shù)whilee>5*10^(-6)fori=1:ntemp=0;forj=1:ntemp=temp+A(i,j)*x(j,1);endx(i,1)=x(i,1)+w*(b(i,1)-temp)/A(i,i);e
5、nde=norm(rx-x,inf);t=t+1;xend