Skip to content

Instantly share code, notes, and snippets.

@MovsisyanM
Created May 19, 2022 08:50
Show Gist options
  • Save MovsisyanM/3022b182640e3ddd1851c2ccda97cf5c to your computer and use it in GitHub Desktop.
Save MovsisyanM/3022b182640e3ddd1851c2ccda97cf5c to your computer and use it in GitHub Desktop.
Solves the linear system Ax = b using Gauss-Seidel method.
import numpy as np
def Gauss_Seidel(A, b, N):
"""Solves the linear system Ax = b using Gauss-Seidel method."""
x = np.zeros(len(b))
e_inverse = np.linalg.inv(np.tril(A))
for i in range(N):
x += np.dot(e_inverse, b - np.dot(A, x))
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment