Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_cubic_interpolation.py
- def cubic(a, b, c, d):
- # Calculate the step size between the values of the corners
- step_size_1 = (b - a) / 4
- step_size_2 = (c - a) / 4
- step_size_3 = (d - (a + 4 * step_size_1 + 4 * step_size_2)) / 16
- # Initialize the grid with the corner values
- 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)]
- return grid
- for i in cubic(3,15,19,59):
- print(i)
- '''
- [3, 6, 9, 12, 15]
- [7, 11, 16, 21, 26]
- [11, 17, 24, 30, 37]
- [15, 23, 31, 39, 48]
- [19, 29, 39, 49, 59]
- '''
- print('.')
- for i in cubic(3,15,19,99):
- print(i)
- '''
- [3, 6, 9, 12, 15]
- [7, 14, 21, 28, 36]
- [11, 22, 34, 45, 57]
- [15, 30, 46, 62, 78]
- [19, 39, 59, 79, 99]
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement