Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function NF = newton_forward(x, y, a)
- n = length(x);
- diff_table = zeros(n, n);
- for i = 1 : n
- diff_table(i, 1) = y(i);
- end
- for j = 2 : n
- for i = 1 : n - j + 1
- diff_table(i, j) = diff_table(i + 1, j - 1) - diff_table(i, j - 1);
- end
- end
- NF = diff_table(1, 1);
- s = (a - x(1)) / (x(2) - x(1));
- fact = 1;
- val = s;
- for j = 2 : n
- NF = NF + (val * diff_table(1, j)) / fact;
- val = val * (s - j - 1);
- fact = fact * j;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement