1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
clc
clear
x=[3.2 2.7 1 4.8 5.6]
y=[22 17.8 14.2 38.3 51.7]
for i=1:1:5
X=[x(1,i) y(1,i)]
disp(X)
end
P31=(3-x(1,2))*(3-x(1,3))*(3-x(1,4))*(3-x(1,5))*y(1,1)/((x(1,1)-x(1,2))*(x(1,1)-x(1,3))*(x(1,1)-x(1,4))*(x(1,1)-x(1,5)));
P32=(3-x(1,1))*(3-x(1,3))*(3-x(1,4))*(3-x(1,5))*y(1,2)/((x(1,2)-x(1,1))*(x(1,2)-x(1,3))*(x(1,2)-x(1,4))*(x(1,2)-x(1,5)))
P33=(3-x(1,2))*(3-x(1,1))*(3-x(1,4))*(3-x(1,5))*y(1,3)/((x(1,3)-x(1,2))*(x(1,3)-x(1,1))*(x(1,3)-x(1,4))*(x(1,3)-x(1,5)))
P34=(3-x(1,2))*(3-x(1,3))*(3-x(1,1))*(3-x(1,5))*y(1,4)/((x(1,4)-x(1,2))*(x(1,4)-x(1,3))*(x(1,4)-x(1,1))*(x(1,4)-x(1,5)))
P35=(3-x(1,2))*(3-x(1,3))*(3-x(1,4))*(3-x(1,1))*y(1,5)/((x(1,5)-x(1,2))*(x(1,5)-x(1,3))*(x(1,5)-x(1,4))*(x(1,5)-x(1,1)))
printf(' Ploynomial at x=3 is')
P=P31+P32+P33+P34+P35
disp(P)
|