def roots(filename): points = np.matrix(week2.read_matrix(filename)) x = np.asarray(points[:, 0]).squeeze() y = np.asarray(points[:, 1]).squeeze() z = np.polyfit(x, y, 3) f = np.poly1d(z) root = newton(f, 0) return root
def solve_matrix(filename): mat = np.matrix(week2.read_matrix(filename)) A = np.matrix(mat[:, range(len(mat))]) last_column = np.array(mat[:, len(mat)]) return np.linalg.solve(A, last_column)