SHARE
TWEET

Untitled

a guest Dec 9th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def get_values_adams(derivative_func, h, N, init_roots, init_values):
  2.     if len(init_roots) != len(init_values):
  3.         raise Exception("Error")
  4.  
  5.     length = len(init_roots)
  6.  
  7.     table = [init_roots, init_values,
  8.              [h * derivative_func(init_roots[i], init_values[i]) for i in range(0, length)], [], [], [], []]
  9.  
  10.     for i in range(0, 4):
  11.         for j in range(0, length - i - 1):
  12.             table[3 + i].append(table[2 + i][j + 1] - table[2 + i][j])
  13.  
  14.     for i in range(length, N+1):
  15.         table[0].append(table[0][-1] + h)
  16.         table[1].append(table[1][-1] + (table[2][-1] + 1./2*table[3][-1] + 5./12*table[4][-1] +
  17.                                                             3./8*table[5][-1] + 251./720*table[6][-1]))
  18.         table[2].append(h * derivative_func(table[0][-1], table[1][-1]))
  19.         for j in range(3, 7):
  20.             table[j].append(table[j-1][-1] - table[j-1][-2])
  21.  
  22.     return table[1]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top