Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import math
- A = [[-2, 3.01, 0.12, -0.11], [2.92, -0.17, 0.11, 0.22], [0.66, 0.52, 3.17, 2.11], [3.01, 0.42, 0.27, -0.15]]
- b = [0.2, 0.1, 0, -0.1]
- def Goose(A, b):
- for i in range(4):
- for c in range(i + 1, 4):
- k = A[c][i] / A[i][i]
- b[c] -= k * b[i]
- for j in range(4):
- A[c][j] -= k * A[i][j]
- Goose(A, b)
- x1 = b[3] / A[3][3]
- x2 = (b[2] - A[2][3] * x1) / A[2][2]
- x3 = (b[1] - A[1][3] * x1 - A[1][2] * x2) / A[1][1]
- x4 = (b[0] - A[0][3] * x1 - A[0][2] * x2 - A[0][1] * x3)
- print("x1 =", x4)
- print("x2 =", x3)
- print("x3 =", x2)
- print("x4 =", x1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement