NRP : 01111940000004
Kelas : Fisika Komputasi I
Tugas Interpolasi
A. Interpolasi Polinomial Newton
Ord Skrip Matlab Hasil
o
10 %deklarasi data: batas bawah x = -1, batas atas x=1
x=[-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1]; %input
nilai x
y=1./(1+8*x.^2);%input fungsi y terhadap x
%%%plot grafik
xx=[-1:0.02: 1]; % Interval to look over
yy=1./(1+8*xx.^2); % Graph of the true function
yy1=polyval(n,xx); % Graph of the approximate polynomial
function
subplot(221), plot(xx,yy,'k-', x,y,'o', xx,yy1,'b')
subplot(222), plot(xx,yy1-yy,'r') % Graph of the error
function
8 %deklarasi data: batas bawah x = -1, batas atas x=1
x=[-1 -0.75 -0.5 -0.25 0 0.25 0.5 0.75 1]; %input nilai x
y=1./(1+8*x.^2);%input fungsi y terhadap x
%%%plot grafik
xx=[-1:0.02: 1]; % Interval to look over
yy=1./(1+8*xx.^2); % Graph of the true function
yy1=polyval(n,xx); % Graph of the approximate polynomial
function
subplot(221), plot(xx,yy,'k-', x,y,'o', xx,yy1,'b')
subplot(222), plot(xx,yy1-yy,'r') % Graph of the error
function
%%%plot grafik
xx=[-1:0.02: 1]; % Interval to look over
yy=1./(1+8*xx.^2); % Graph of the true function
yy1=polyval(n,xx); % Graph of the approximate
polynomial function
subplot(221), plot(xx,yy,'k-', x,y,'o', xx,yy1,'b')
subplot(222), plot(xx,yy1-yy,'r') % Graph of the
error function
B. Interpolasi Polinomial Lagrange
%deklarasikan data
x=[-2 -1 1 2 4]; %masukkan nilai x
y=[-6 0 0 6 60]; %masukkan nilai y
0 1
n =
0 1 -3
n =
0 1 -2 3
n =
0 1 0 -1 0
L =
l =
L =
0 0 0 0 0
-0.0333 0.1667 0 -0.6667 0.5333
l =
L =
0 0 0 0 0
0 0 0 0 0
0.0556 -0.1667 -0.4444 0.6667 0.8889
l =
L =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
-0.0417 0.0833 0.3750 -0.0833 -0.3333
l =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0.0056 0.0000 -0.0278 0.0000 0.0222
l =