Advertisement
STANAANDREY

newtondd

Mar 12th, 2023 (edited)
1,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.27 KB | None | 0 0
  1. function c = newtondd(x, y, n)
  2.     c = zeros(1,n);
  3.     for j=1:n
  4.         v(j, 1)=y(j);
  5.     end
  6.     for i=2:n
  7.         for j=1:n+1-i
  8.             v(j, i)=(v(j+1, i-1) - v(j, i-1))/(x(j+i-1) - x(j));
  9.         end
  10.     end
  11.     for i=1:n
  12.         c(i)=v(1, i);
  13.     end
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement