Commit de2dda5e authored by Aruchira's avatar Aruchira

Up

parent 3ffe0728
def ge(A, b):
# 1. elimination
n = len(b)
for j in range(0, n-1): # pivot equation
for i in range(j+1, n):
lam = A[i,j]/A[j,j]
A[i,j:n] = A[i, j:n] - lam*A[j, j:n]
b[i] = b[i] - lam*b[j]
x = b.copy()
for k in range(n-1, -1, -1):
x[k] = (b[k] - np.dot(A[k,k+1:n], x[k+1:n]))/A[k,k]
print(x)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment