rorschack

QT_Prac_NewtonsBackward_2B

Mar 1st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.58 KB | None | 0 0
  1. /*
  2. x=[45 50 55 60 65]
  3. y=f(x)=[29 24 21 19 17]
  4. x estimate = 46
  5. Ans:
  6.    27.996288
  7. */
  8.  
  9. function[] = newton_bkwd(x,y,xest)
  10.     n=length(y)
  11.     h=x(2)-x(1)
  12.     p=(xest-x(n))/h
  13.     for i=1:n-1
  14.         d(i+1,1)=y(i+1)-y(i)
  15.     end
  16.     for j=2:n
  17.         for i=2:n
  18.             d(i,j)=d(i,j-1)-d(i-1,j-1)
  19.         end
  20.     end
  21.     e(1)=p
  22.     for j=2:n
  23.         e(j)=e(j-1)*(p-1+j)/j
  24.     end
  25.     yest=0;
  26.     for j=1:n
  27.         yest=yest+e(j)*d(n,j)
  28.     end
  29.     yest=yest+y(n)
  30.     disp(yest)
  31. endfunction
  32.  
  33. x=[45 50 55 60 65]
  34. y=[29 24 21 19 17]
  35. xest=46
  36. newton_bkwd(x,y,xest)
Add Comment
Please, Sign In to add comment