Newton Interpolation

You might also like

You are on page 1of 2

Name: Aditya Kumar

Roll no.: 3914

Group: A+B

Scilab Code 11

Aim:
To find the population of the town in year
1895 using Newton’s Interpolation Method.
clc
clear

x = [1891;1901;1911;1921;1931]
y = [46;66;81;93;101]

n = length(x)

for j=2:n
for i = 1:(n-j+1)
y(i,j)=y(i+1,j-1)-y(i,j-1)
end
end

k = [x y]
disp("Year(x) Pop(y) d1y d2y d3y d4y")
disp(k)

z = 1895
h = x(2)-x(1)
//disp(h)
p =(z-x(1))/h
//disp(p)
t = y(1)
r=1
for j = 1:n-1
r = (r*(p-(j-1)))
t = (t + ((r*y(1,j+1))/factorial(j)))
end
disp("Population of the town in year 1895 is "+string(t))
OUTPUT:

"Year(x) Pop(y) d1y d2y d3y d4y"

1891. 46. 20. -5. 2. -3.


1901. 66. 15. -3. -1. 0.
1911. 81. 12. -4. 0. 0.
1921. 93. 8. 0. 0. 0.
1931. 101. 0. 0. 0. 0.

"Population of the town in year 1895 is 54.8528"

You might also like