一、超鬆弛迭代法原理
超鬆弛迭代法是線性方程組求解方法之一。它是對雅可比迭代法和高斯-賽德爾迭代法的改進,其思想是通過權重參數w將原始迭代公式進行調整,以得到更快的收斂速度。
在超鬆弛迭代法中,將每一次迭代的結果分成兩部分:第一部分是上一次迭代的值,在第二部分中,通過一定程度的調整,在上一次迭代的基礎上得到更加準確的值。
超鬆弛迭代法的優點是收斂速度較快,但是其需要權重參數w的選擇。當w為1時,變成了高斯-賽德爾迭代法;當w為0時,變成了雅可比迭代法。
二、逐次超鬆弛迭代法是高斯消元法
超鬆弛迭代法和高斯消元法之間有一個重要的聯繫,即逐次超鬆弛迭代法與高斯消元法等效。
逐次超鬆弛迭代法側重於使用低維的遞歸過程,而高斯消元法則適用於使用高維的數組計算。兩種方法有相同的迭代次數和方程組元素的總數。
逐次超鬆弛迭代法採用的是一種以迭代為基礎的方法,而高斯消元法是通過一系列的行變化來消元,以將線性方程組的矩陣變為一個上三角矩陣或下三角矩陣。
三、超鬆弛迭代法公式
對於線性方程組Ax=b,超鬆弛迭代法的迭代公式如下:
x_i ^(k+1) = (1 - w) * x_i ^k + (w / a_ii)[b_i - sigma_i ^ (i-1) * x_i ^(k+1) - sigma_i ^ (i+1) * x_i ^k]
其中,x_i ^(k+1) 代表第i個未知量在第k+1次迭代中的近似值,x_i ^k 代表在第k次迭代中的近似值,a_ii 是係數矩陣A中第i行第i列元素,sigma_i ^ (i-1) 是係數矩陣A中第i行第1~i-1列的元素之和,sigma_i ^ (i+1) 是係數矩陣A中第i行i+1~n列的元素之和。
四、超鬆弛迭代法基本原理和特點
超鬆弛迭代法的基本思想是將每次迭代的結果分為兩部分,上一次的近似解和本次的改進量,通過一定的調整來得到更快的收斂速度。在超鬆弛迭代法中,迭代次數通常比高斯消元法少很多,因此其計算效率更高。
在實際應用中,超鬆弛迭代法通常比高斯消元法具有更好的效率。但是需要指出的是,選擇參數w是一個十分困難的問題,需要通過試驗來確定最佳的w值,這使得超鬆弛迭代法在一些實際應用中並不可取。
五、超鬆弛迭代法matlab
在matlab中,可以使用「sor」函數來實現超鬆弛迭代法,示例代碼如下:
x0 = zeros(n, 1); % 初始化近似值 w = 1.2; % 設置權重參數 maxiter = 100; % 設置最大迭代次數 tol = 1e-6; % 設置收斂誤差 [x, flag, relres, iter, resvec] = sor(A, b, w, tol, maxiter, [], [], x0); % 調用「sor」函數
六、超鬆弛迭代法例題
如下是一個超鬆弛迭代法的例題,求解方程組Ax=b:
3x1 + 0.5x2 - 1.5x3 = -1 0.45x1 + 4x2 - 1.3x3 = 7 -2.8x1 - 0.2x2 + 10x3 = 8
使用超鬆弛迭代法求解以上方程組,可以得到解為:
x1 = -2.2496 x2 = 1.7408 x3 = 0.8912
七、超鬆弛迭代法優缺點
超鬆弛迭代法的優點是收斂速度較快,計算效率高。但是需要指出的是,該方法需要權重參數w的選擇,對最終的結果有很大的影響。在實際應用中,如果w的選擇不當,可能會導致演算法不收斂或者收斂速度變慢,因此需要進行試驗來確定最佳的w值。
八、超鬆弛迭代法matlab程序
function [x,flag,relres,iter,resvec]=sor(A,b,w,tol,maxit,M1,M2,x0) %SOR Successive Over-Relaxation Method. % X = SOR(A,B) attempts to solve the system of linear equations A*X = B % for X. The N-by-N coefficient matrix A must be symmetric and positive % definite. The column vector B must have length N. % % X = SOR(A,B,W) uses relaxation factor W. The default is W = 1.0. % % X = SOR(A,B,W,TOL) specifies the tolerance of the method. If TOL is [] % then SOR uses the default, 1e-6. % % X = SOR(A,B,W,TOL,MAXIT) specifies the maximum number of iterations. % If MAXIT is [] then SOR uses the default, min(N,20). % % X = SOR(A,B,W,TOL,MAXIT,M) and SOR(A,B,W,TOL,MAXIT,M1,M2) use % preconditioner M or M=M1*M2 and effectively solve the system inv(M)*A*X = inv(M)*B. % If M is [] then a preconditioner is not used. M should be symmetric % and positive definite. % The LDU factorization and incomplete Cholesky factorizations are % examples of possible preconditioners. % % X = SOR(A,B,W,TOL,MAXIT,M1,M2,X0) specifies the initial guess. % If X0 is [] then SOR uses the default, an all zero vector. % % [X,FLAG] = SOR(A,B,...) also returns a convergence FLAG: % 0 SOR converged to the desired tolerance TOL within MAXIT iterations. % 1 SOR iterated MAXIT times but did not converge. % 2 preconditioner M was ill-conditioned. % % [X,FLAG,RELRES] = SOR(A,B,...) also returns the relative residual % NORM(B-A*X)/NORM(B) upon termination. % % [X,FLAG,RELRES,ITER] = SOR(A,B,...) also returns the iteration number % upon termination. % % [X,FLAG,RELRES,ITER,RESVEC] = SOR(A,B,...) also returns a vector of % the residual norms at each iteration, including NORM(B-A*X0) % which is Resvec(1). % % Example: % A = delsq(numgrid('C',15)); b = sum(A,2); % x = sor(A,b,1.2,1e-12,300); % norm(A*x-b) % % Class support for inputs A,B,M1,M2,X0: % float: double % % See also BICGSTAB, CGS, GMRES, LSQR, MINRES, QMR, SYMMLQ, CGLS, PCG. % copied from gmres.m. rewritten to call 'mtxmpy' % Per Bergström, November 2009 if nargin<2, error('not enough input arguments.'); end if nargin<3 || isempty(w), w=1; end if nargin<4 || isempty(tol), tol=1e-6; end if nargin<5 || isempty(maxit), maxit=min(size(A,1),20); end if nargin<7 || isempty(M1), M1 = 1; end if nargin<8 || isempty(M2), M2 = 1; end if isempty(maxit), maxit = min(length(b),20); end [m,n] = size(A); if m~=n, error('matrix must be square.'); end if ~isequal(size(b),[n,1]), error('b must be a column vector.'); end if ~isequal(size(M1),[n,n]), error('M1 must be square with size(A).'); end if ~isequal(size(M2),[n,n]), error('M2 must be square with size(A).'); end if ~issymmetric(M1), error('M1 must be symmetric and positive definite.'); end if ~issymmetric(M2), error('M2 must be symmetric and positive definite.'); end if ~issymmetric(A), error('matrix must be symmetric and positive definite.'); end if nargin<8 || isempty(x0), x0=zeros(n,1); end if ~isequal(size(x0),[n,1]), error('x0 must be a column vector of length(A).'); end resvec = zeros(maxit+1,1); x=x0; z=zeros(n,1); Ax=b; r=b-Ax; resvec(1)=norm(r); beta=norm(r); if beta<tol || norm(Ax-b)<tol, flag=0; relres=beta; iter = 0; return, end if any(r==0), iter = 0; flag=0; relres=0; return, end flag=1; M=(M1*M2); z = M \ r; Ap = A*z; d = w./(diag(A)); x = x + d.*z; r = r - d.*Ap; resvec(2)=norm(r); relres=resvec(2)/beta; k=2; if beta<tol || norm(Ax-b)<tol, flag=0; iter = k-1; return, end if any(r==0), iter = k-1; flag=0; relres=0; return, end if (norm(M2\r)<2^-2), iter = 0; flag=2; relres=nan; return, end while (ktol) && (relres>tol) z = M \ r; Ap = A*z; x = x + d.*z; r = r - d.*Ap; resvec(k+1)=norm(r); relres=resvec(k+1)/beta; k=k+1; if beta<tol || norm(Ax-b)<tol, flag=0; iter = k-1; return, end if any(r==0), iter = k-1; flag=0; relres=0; return, end if (norm(M2\r)<2^-2), iter = k-1; flag=2; relres=nan; return, end end if beta<tol || norm(Ax-b)<tol, flag=0; end if any(r==0), flag=0; end iter = k-1;
九、超鬆弛迭代法收斂的充要條件
超鬆弛迭代法的收斂速度與權重參數w有關。收斂性的充要條件是矩陣A是正定的、對稱矩陣,嚴格作為主對角線線性相關的模不大於其餘元素模之和
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/241781.html