Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_values_adams(derivative_func, h, N, init_roots, init_values):
- if len(init_roots) != len(init_values):
- raise Exception("Error")
- length = len(init_roots)
- table = [init_roots, init_values,
- [h * derivative_func(init_roots[i], init_values[i]) for i in range(0, length)], [], [], [], []]
- for i in range(0, 4):
- for j in range(0, length - i - 1):
- table[3 + i].append(table[2 + i][j + 1] - table[2 + i][j])
- for i in range(length, N+1):
- table[0].append(table[0][-1] + h)
- table[1].append(table[1][-1] + (table[2][-1] + 1./2*table[3][-1] + 5./12*table[4][-1] +
- 3./8*table[5][-1] + 251./720*table[6][-1]))
- table[2].append(h * derivative_func(table[0][-1], table[1][-1]))
- for j in range(3, 7):
- table[j].append(table[j-1][-1] - table[j-1][-2])
- return table[1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement