Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- x=[45 50 55 60 65]
- y=f(x)=[29 24 21 19 17]
- x estimate = 46
- Ans:
- 27.792
- */
- function[] = newton_fwd(x,y,xest)
- n=length(y)
- h=x(2)-x(1)
- u=(xest-x(1))/h
- e(1)=u
- for i=1:n-1
- d(i,1)=y(i+1)-y(i)
- end
- for j=2:n
- for i=1:n-j
- d(i,j)=d(i+1,j-1)-d(i,j-1)
- end
- e(j)=e(j-1)*(u+1-j)/j
- end
- yest=0;
- for j=1:n-1
- yest=yest+e(j)*d(1,j)
- end
- yest=yest+y(1)
- disp(yest)
- endfunction
- x=[45 50 55 60 65]
- y=[29 24 21 19 17]
- xest=46
- newton_fwd(x,y,xest)
Add Comment
Please, Sign In to add comment