Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Interpolation
- function newton_interpolation(data::Matrix, x)
- n = size(data, 1)
- ys = data[:, 2]
- xs = data[:, 1]
- res = y[1]
- k = 1
- for i = 1:n
- for j = 1:n - i
- ys[j] = (ys[j + 1] - ys[j])/(xs[j + i] - xs[j])
- end
- k += x - xs[i]
- res += ys[1] * k
- end
- return res
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement