Python Programming
Basics
Numerical Methods
- Bisection Method
- Secant Method
- Regular Falsi (False Position) Method
- Newton Raphson Method
- Gauss Elimination Method
- Gauss Jordan Method
- Gauss-Seidel Method
- Lagrange Interpolation Method
- Newton Divided Difference Interpolation
- Newton Forward Difference Interpolation
- Newton Backward Difference Interpolation
- Trapezoidal Rule
- Simpson 1/3rd Rule
- Simpson 3/8 Rule
- Euler’s Method
- Euler’s Modified Method
- Runge-Kutta 2nd Order Method
- Runge-Kutta 4th Order Method
- Cubic Spline Method
- Bilinear Interpolation Method
- Milne’s Method
- More topics coming soon…
Advance Numerical Methods
The Gauss-Jordan method is a way to solve systems of linear equations.
It works by using row operations to transform the coefficient matrix of the system into reduced row-echelon form, and then back-substituting to find the solution.
In simple words, it solves the system of linear equations Ax = b
Gauss-Jordan method in Python for equations:
x + y – z = 7
x – y + 2z = 3
2x + y + z = 9
def gauss_jordan(A, b):
# Gauss-Jordan Method [By Bottom Science]
n = len(A)
M = A
i = 0
for x in M:
x.append(b[i])
i += 1
for k in range(n):
for i in range(k, n):
if abs(M[i][k]) > abs(M[k][k]):
M[k], M[i] = M[i], M[k]
else:
pass
for j in range(k+1, n):
q = M[j][k] / M[k][k]
for m in range(k, n+1):
M[j][m] -= q * M[k][m]
x = [0 for i in range(n)]
x[n-1] = M[n-1][n] / M[n-1][n-1]
for i in range(n-1, -1, -1):
z = 0
for j in range(i+1, n):
z = z + M[i][j]*x[j]
x[i] = (M[i][n] - z) / M[i][i]
return x
# A - coefficient matrix
A = [[1, 1, -1], [1, -1, 2], [2, 1, 1]]
b = [7, 3, 9]
print(gauss_jordan(A, b))
# Output - [6.0, -1.0, -2.0]