Advertisement
Voldemord

Untitled

May 15th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. function [wynik] = rzedy(x,y)
  2. n=length(x);
  3. R=zeros(n);
  4. R(:,1)=y;
  5.  
  6. for i=1:n-1
  7. for j=1:n-i
  8. R(j,i+1)=(R(j+1,i)-R(j,i))/(x(i+j)-x(j));
  9. end
  10. end
  11. wynik = R;
  12.  
  13. function[wynik] = newton(R,X,Y)
  14. R=rzedy(x,y);
  15.  
  16. syms x;
  17. n=length(X);
  18. W=Y(1);
  19. for i=1:n-1
  20.  
  21. a=1;
  22. for j=1:i
  23. a=a*(x-X(j));
  24. end
  25. W=W+(R(1,i+1)*a)
  26. end
  27. wynik = simplify(W);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement