#LnormInf corresponds to the absolute value of the greatest element of the vector. Print ('The solution vector in iteration', iter1, 'is:', x) The Poisson Equation in Any Space Dimensions def sor_method(A, b, omega, initial_guess, tolerance, max_iterations): Gauss-Seidel Method Example: The above MATLAB program of Gauss-Seidel method in MATLAB is now solved here mathematically. See section 3 on the paper The Optimal Relaxation Parameter for the SOR Method Applied to Obviously, with higher omega values the number of iterations should decrease.Īs for a working algorithm on SOR this is what I have computed, where best convergence is reached when the optimal omega is used. Phi = sor_solver(A, b, omega, initial_guess, residual_convergence)įor an extended answer on omega and its uses please refer to my other answer SOR method as what is quoted below is not accurate. Below is the Python Code for a 50x50 Matrix. A similar method can be used for any slowly converging iterative process.
#An example case that mirrors the one in the Wikipedia article In numerical linear algebra, the method of successive over-relaxation (SOR) is a variant of the GaussSeidel method for solving a linear system of equations, resulting in faster convergence. Here I have some python script, which solves the system of linear equations using Gauss-Seidel method: import numpy as np