Python gauss seidel methos

broken image
broken image

Consider the domain ( 0, 1) 2 R and a function g C 0 ( ), we want to find a (strong) solution u C 2 ( ) for the following boundary value problem. In this notebook, we will guide you through solving the Laplace equation. #LnormInf corresponds to the absolute value of the greatest element of the vector. Iterative Methods and Preconditioners for Systems of Linear Equations. For example, we first assume the initial values for \(x2, x3, \cdots, xn\) (except for \(x1\)), and then we can calculate \(x1\). X = x*(1-omega) + (omega/A)*(b - np.dot(A, x) - np.dot(A, x_old)) Gauss-Seidel Method The Gauss-Seidel Method is a specific iterative method, that is always using the latest estimated value for each elements in \(x\). 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): See section 3 on the paper The Optimal Relaxation Parameter for the SOR Method Applied to

broken image

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. #An example case that mirrors the one in the Wikipedia article Here I have some python script, which solves the system of linear equations using Gauss-Seidel method: import numpy as np

broken image