Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def init(points):
- n = len(points)
- sole = np.zeros((n, n + 1))
- # Populate the augmented matrix
- for i in range(n):
- sole[i, -1] = points[i][1]
- x = 1
- for j in range(n - 1, -1, -1):
- sole[i, j] = x
- x *= points[i][0]
- return sole
- def solve():
- # Define the points (x, y)
- points = [(0, 8), (1, 9), (2, 16), (3, 43)]
- # Print the x values
- print("\t".join(f"{x[0]:.1f}" for x in points))
- # Print the y values
- print("\t".join(f"{x[1]:.1f}" for x in points))
- print()
- # Initialize the augmented matrix
- sole = init(points)
- # Print the augmented matrix
- for row in sole:
- print("\t".join(f"{x:.3f}" for x in row))
- if __name__ == "__main__":
- solve()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement