Advertisement
ruhan008

Newton Backward differentiation

Nov 1st, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.46 KB | None | 0 0
  1. function NBD = newton_backward_differentiation(x, y)
  2.     n = length(x);
  3.     diff_table = zeros(n, n);
  4.  
  5.     for i = 1 : n
  6.         diff_table(i, 1) = y(i);
  7.     end
  8.    
  9.     for j = 2 : n
  10.         for i = 1 : n - j + 1
  11.             diff_table(i, j) = diff_table(i + 1, j - 1) - diff_table(i, j - 1);
  12.         end
  13.     end
  14.  
  15.     NBD = 0;
  16.     for i = 2 : n
  17.          NBD = NBD + diff_table(n - i + 1, i) / (i - 1);
  18.     end
  19.  
  20.     NBD = NBD / (x(2) - x(1));
  21.    
  22.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement