Gauss-Seidel Method for Solving Linear Systems
Linear Systems & Numerical Methods DS practice problem on Onlearn.
Difficulty: medium.
Topics: Gauss-Seidel Method for Solving Linear Systems, Gauss-Seidel Iteration, Residual Vector, Spectral Radius, Diagonal Dominance, Stopping Criteria, Linear Algebra, Numerical Methods, Scientific Computing, Applied Mathematics, Computational Science, Iterative Solvers, System of Linear Equations, Convergence Analysis, Numerical Stability, Matrix Algebra.
Task: Implement the Gauss Seidel Method Your task is to implement the Gauss Seidel method, an iterative technique for solving a system of linear equations \(Ax = b\). The function should iteratively update the solution vector \(x\) by using the most recent values available during the iteration process. Write a function gauss seidel(A, b, n, x ini=None) where: A is a square matrix of coefficients, b is the right hand side vector, n is the number of iterations, x ini is an optional initial guess for \(x\) (if not provided, initialize with zeros). The function should return the approximated solution vector \(x\) after performing the specified number of iterations. Assumptions: The matrix A is diagonally dominant (ensures convergence) All diagonal elements of A are non zero The system has a unique solution