and Interpolation
Linear Interpolation
Polynomial Interpolation
Cubic Spline Interpolation
Least-Square Fit
Interpolation VS Curve Fitting
Dalam interpolasi kita membuat
kurva melalui titik-titik data. Disini
kita asumsikan bahwa bahwa titik
data akurat
• Interpolasi Linier
Derajat/orde 1 memerlukan 2 titik
Berapa f(x = 1,325) = ?
x f(x)
Memerlukan 2 titik awal :
1 4,5 x=1
2 7.6 x=2
3 9.8
4 11.2
Macam Interpolasi Beda Terbagi Newton
• Interpolasi Kuadratik
Derajat/orde 2 memerlukan 3 titik
x = 1 f(x = 1) = . . . .
x = 2 f(x = 2) = . . . .f (x = 1,325) = ?
x = 3 f(x = 3) = . . . .
Macam Interpolasi Beda Terbagi Newton
• Interpolasi Kubik
Derajat/orde 3 memerlukan 4 titik
…
• Interpolasi derajat/orde ke-n
memerlukan n+1 titik
b1 = f[x1, x0]
…
bn = f[xn, xn-1, xn-2, . . . ., x0]
Example 1
From the table we see that the last nonzero coefficient (last nonzero
diagonal term) of Newton’s polynomial is ∇3y3, which is the coefficient of
the cubic term. Hence, the polynomial is a cubic
Example 2
Misalnya, kita memiliki tabel seperti ini, yang memberikan beberapa nilai
fungsi f yang tidak diketahui . Interpolasi menyediakan cara untuk
memperkirakan fungsi pada titik-titik perantara, seperti x = 2,5
Jika fungsi nya adalah
f(x) = -0.001521x6 – 0.003130x5 + 0.07321x4 – 0.3577x3 + 0.2255x2 +
0.9038x
x F(x)
0 0
1 0.8415
2 0.9093
3 0.1411
4 -0.7568
5 -0.9589
6 -0.2794
Hence evaluate
P( x 3.5)
Solution
x x0 x x0 x x1 2
P2 ( x) f 0 f 0 2
f0.
h 2h
k xk fk f k 2 f k
0 1 6
5
1 2 11 2
7
2 3 18 2
9
3 4 27
x 1 x 2
S
P2 ( x ) 6 5( x 1) 2
2
x 2 2x 3
Alternatively, P ( x) f mf m m 11 2 f .
2 0 0 2 0
2h
mm 11
6 5m 2 m 4m 6.
2
dengan n x xj
Li x
j 0 xi x j
j i
Interpolasi Lagrange
Pendekatan orde ke-1
f1(x) = L0(x)f(x0) + L1(x)f(x1)
x x1 x x0
L0 x L1 x
x0 x1 x1 x0
x x1 x x0
f1 x f x0 f x1
x0 x1 x1 x0
Interpolasi Lagrange
Pendekatan orde ke-2
f2(x) = L0(x)f(x0) + L1(x)f(x1) + L2(x)f(x2)
x x1 x x2 x x0 x x2
L0 x L1 x
x x x x x1 x0 x1 x2
i 0
n 2
0 1 0 2 i 1
n 2
j i j i
x x0 x x1
L2 x
i 2 x2 x0 x2 x1
n 2
j i
x x1 x x2 x x0 x x2 x x0 x x1
f2 x
f x0
f x1
f x2
x0 x1 x0 x2 x1 x0 x1 x2 x2 x0 x2 x1
Interpolasi Lagrange
Pendekatan orde ke-3
f3(x) = L0(x)f(x0) + L1(x)f(x1) + L2(x)f(x2) + L3(x)f(x3)
x x1 x x2 x x3 x x0 x x2 x x3
f2 x
f x0
f x1
x 0 x1 x 0 x2 x 0 x 3 x1 x 0 x1 x2 x1 x3
x x0 x x1 x x3 x x0 x x1 x x2
x x x x x x f x2 x x x x x x f x3
2 0 2 1 2 3 3 0 3 1 3 2
Contoh : Berapa nilai distribusi t pada = 4 %?
4 5 4 10 4 2,5 4 10 4 2,5 4 5
2,571 2,015 1,476
2,5 5 2,5 10 5 2,5 5 10 10 2,5 10 5
2,214
Contoh
Carilah nilai dari ln 2 dengan metode interpolasi polinomial
Lagrange Orde dua berdasar data sebagai berikut ln 1 = 0,
ln 4 = 1,3862944 dan
ln 6 = 1,7917595. Untuk membandingkan hasil yang
diperoleh, hitung pula besar kesalahan (diketahui nilai
eksak dari ln 2 = 0,69314718).
Jawab : Dari soal di atas dapat diperoleh data sbg brkt.. x0
= 1 f (x0 ) = 0
x1 = 4 f (x1 ) = 1,3862944
x2 = 6 f (x2 ) = 1,7917595
Dari data yg diketahui masukkan ke persamaan
interpolasi lagrange orde 2.
Problem
Find a polynomial of degree two which
takes the following values.
x 1 2 4
f (x) 6 11 27
Interpolate f (3).
Solution
Since the x-values are not equi-spaced
then
we have to apply Langrangian formula.
S
n
Ln ( x) Pni f i
i 0 , where
x x i j j
( x)
x x
Pni
i j i j
2
L2 ( x) P2i f i P20 ( x) f 0 P21 ( x) f1 P22 ( x) f 2 .
i 0
Now,
x x
j 0 j x x1 x x2 ( x 2) ( x 4)
0 f0 6
x x
P20 f 0 f
j 0 0 j x0 x1 x0 x2 (1 2) (1 4)
2 x 12 x 16
2
S
x x
j 1 j x x0 x x2 f ( x 1) ( x 4) 11
x x
P21 f1 f
j 1 1 j
1
x1 x0 x1 x2 1 (2 1) (2 4)
1
11x 2 55 x 44
2
j 2
x x j x x0 x x1 ( x 1) ( x 2)
P22 f 2 f2 f2 27
j 2 x2 x j x2 x0 x2 x1 (2 1) (4 2)
1
2
9 x 2 27 x 18
Collecting the expressions above we’ve
L2 ( x) 2 x 12 x 16 11x 55 x 44 9 x 27 x 18
2 1 2 1 2
2 2
L2 ( x) x 2 x 3
2
f ( x) x 2 x 3
2
y i x i
y i 1
; x i 1
n n
KUANTIFIKASI KESALAHAN REGRESI LINEAR
Kesalahan standar (Standard Deviation)
antara model prediksi dengan sebaran data
dapat dikuantifikasi dengan rumus berikut:
Sy/x
(y i a0 a1 x) 2
n2
KUANTIFIKASI KESALAHAN REGRESI LINEAR
Disamping jumlah kuadrat residual (sr) yang dibicarakan
sebelumnya terdapat suatu besaran jumlah kuadrat disekitar
rata2 st = (y-yi)2. Selisih besaran ini dengan sr menunjukkan
perbaikan yang didapat dengan regresi linear. Di bawah ini
diperkenalkan besaran koefisien determinasi dan koefisien
korelasi yang menunjukkan kesempurnaan pencocokan kurva
dgn regresi linear.
Koef. Determinasi
r2
( y yi ) 2
i 0 1
( y a a x ) 2
( y yi ) 2
i xi yi
1 1 0,5
2 2 2,5
3 3 2,0
4 4 4,0
5 5 3,5
6 6 6,0
7 7 5,5
Pencocokan Kuadrat Terkecil
Contoh:
Carilah persamaan garis regresi …
i xi yi xi yi xi2 yi-a0-a1xi
1 1 0,5 … … …
2 2 2,5 … … …
3 3 2,0 … … …
4 4 4,0 … … …
5 5 3,5 … … …
6 6 6,0 … … …
7 7 5,5 … … …
= … = … = … = … = …
Pencocokan Kuadrat Terkecil
Contoh: (lanjutan)
Carilah persamaan garis regresi …. Silahkan
melengkapi tabel sebelumnya dan akan diperoleh:
xi 28 i
y 24 x 28 4
7 y 24 3,4285
7
a1
a0
Example 2
Fit a straight line to the data shown
and compute the standard deviation.
Solution
The intercept a and slope b of the interpolant can now be determined from
the regression line is f (x) = 2.927 + 0.6431x, which is shown in the figure
together with the data points.
Example 3
Determine the parameters a and b so that fits the following
data in the least-squares sense.
(1) fit ln yi and
(2) Compute the standard deviation in this case.
Solution :
(1) The problem is to fit the function ln( ae) bx
= lna +bx to the data
A
Therefore, a = e = 3.790
and the fitting function
becomes
The plots of f (x) and the data
points are shown in the figure.
52
(2). Here is the computation of standard deviation:
54
Acknowledgement
These slides have been adapted
from: