function inter=newton_diff(x, y, new_x)% x,y: 입력데이터% new_x: 보간이 적용되는 x값 n=length(x); b=zeros(n,n); b(:,1)=y(:); %분할차분표 작성for i=2:n for j=1:n-i+1 b(j,i)=(b(j+1,i-1)-b(j,i-1))/(x(i+j-1)-x(j)); endend b%뉴턴보간다항식 계산product=1;inter=b(1,1);for j=1:n-1 product=product*(new_x-x(j)); inter=inter+product*b(1,j+1);end