Advertisement
here2share

# b_cubic_interpolation.py

Dec 13th, 2022
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. # b_cubic_interpolation.py
  2.  
  3. def cubic(a, b, c, d):
  4.     # Calculate the step size between the values of the corners
  5.     step_size_1 = (b - a) / 4
  6.     step_size_2 = (c - a) / 4
  7.     step_size_3 = (d - (a + 4 * step_size_1 + 4 * step_size_2)) / 16
  8.  
  9.     # Initialize the grid with the corner values
  10.     grid = [[int(a + i * step_size_1 + j * step_size_2 + (i * j) * step_size_3) for i in range(5)] for j in range(5)]
  11.     return grid
  12.  
  13. for i in cubic(3,15,19,59):
  14.     print(i)
  15.    
  16. '''
  17. [3, 6, 9, 12, 15]
  18. [7, 11, 16, 21, 26]
  19. [11, 17, 24, 30, 37]
  20. [15, 23, 31, 39, 48]
  21. [19, 29, 39, 49, 59]
  22. '''
  23.  
  24. print('.')
  25. for i in cubic(3,15,19,99):
  26.     print(i)
  27.    
  28. '''
  29. [3, 6, 9, 12, 15]
  30. [7, 14, 21, 28, 36]
  31. [11, 22, 34, 45, 57]
  32. [15, 30, 46, 62, 78]
  33. [19, 39, 59, 79, 99]
  34. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement