Advertisement
kehboard

кусочно линейная интерполяция

Mar 25th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1.  
  2. from matplotlib import pyplot as plt
  3. from matplotlib import pylab
  4. import metodslau_kramer
  5. # def kusochnolineynay(arr):
  6. arr = [[1, 1], [2, 0], [3, 3], [4, 10], [5, 5], [6, 1], [7, 1], [8, -1], [9, 12], [10, 11], [11, 0], [12, 10]]
  7. n = 10000
  8. arrnew = []
  9.  
  10. for i in range(0,len(arr)-1):
  11.     koef = metodslau_kramer.kramermethod(2,[[1,arr[i][0]],[1,arr[i+1][0]]],[arr[i][1],arr[i+1][1]])
  12.     h = (i + 1 - i) / n
  13.     for k in range(n):
  14.         znacheniye = koef[0]+koef[1] * (arr[i][0] + k * h)
  15.         arrnew.append([arr[i][0] + k * h,znacheniye])
  16. plt.plot([x[0] for x in arrnew], [y[1] for y in arrnew])
  17. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement