0% found this document useful (0 votes)
23 views

Script File:: Function For End For For End End

The document contains code for a Newton backward interpolation function. The function takes in x and y arrays and an x-point and returns the interpolated y-point. It uses divided differences to calculate the interpolated value.

Uploaded by

TRUE LOVERS
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Script File:: Function For End For For End End

The document contains code for a Newton backward interpolation function. The function takes in x and y arrays and an x-point and returns the interpolated y-point. It uses divided differences to calculate the interpolated value.

Uploaded by

TRUE LOVERS
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Script File:

x = [1 2 3 4 5 6 7 8]
y = [1 8 27 64 125 216 343 512]
xp = 7.5
yp = NewtonBackward(x,y,xp)

Fumction File:
function [ yp ] = NewtonBackward( x,y,xp )
n = length(x)
for (i = 1:n)
diff(i,1) = y(i)
end
for (j = 2:n)
for(i = n:-1:j)
diff(i,j) = diff(i,j-1)-diff(i-1,j-1)
end
end
yp= y(n)
h = x(2)-x(1)
p = (xp-x(n))/h
for (i=1:n-1)
T = 1
for (j= 1:i)
T = T*(p+j-1)/j
end
yp = yp+T*diff(n,i+1)
end
end

You might also like