http://istiarto.staff.ugm.a.cid
INTEGRASI NUMERIS Numerical Differentiation and Integration
Integrasi Numeris 2
http://istiarto.staff.ugm.ac.id
q
Acuan q
Chapra, S.C., Canale R.P., 1990, Numerical Methods for Engineers, 2nd Ed., McGraw-Hill Book Co., New York. n
Chapter 15 dan 16, hlm. 459-523.
Diferensial, Derivatif 3
http://istiarto.staff.ugm.ac.id
f(xi+Δx) yi +Δy
f(xi)
yi +Δy
Δy
yi
yi
Δx xi
xi +Δx
(a)
Δy f (xi + Δx ) − f (xi ) = Δx Δx difference approximation
yi xi (b)
xi +Δx
xi (c)
dy f (xi + Δx ) − f (xi ) = lim d x Δx →0 Δx
Diferensial, Derivatif 4
http://istiarto.staff.ugm.ac.id
Δy f (xi + Δx ) − f (xi ) = Δx Δx pendekatan beda (hingga) difference approximation
dy f (xi + Δx ) − f (xi ) = lim d x Δx →0 Δx derivatif dy = y ʹ′ = f ʹ′(x ) dx
derivatif = laju perubahan y terhadap x
Diferensial http://istiarto.staff.ugm.ac.id
160
24
120 y 80
slope = dy/dx
12
40
6
0
0 0
2
4
6 x
dy = 7.5 x 0.5 dx
18
y = 5 x 1. 5
dy/dx
5
8
10
0
2
4
6 x
8
10
Integral http://istiarto.staff.ugm.ac.id
24
160 y = 7.5 x 0.5
18 y 12
120 ∫y dx
6
x
luas = ∫ y d x 0
6
∫ ydx = 5x
1.5
80 40
0
0 0
2
4
6
8
10
0
2
4
6
8
x x § “kebalikan” dari proses men-diferensial-kan adalah meng-integral-kan § integrasi ›‹ diferensiasi
10
Fungsi 7
http://istiarto.staff.ugm.ac.id
q
Fungsi-fungsi yang di-diferensial-kan atau di-integral-kan dapat berupa: q q
q
fungsi kontinu sederhana: polinomial, eksponensial, trigonometri fungsi kontinu kompleks yang tidak memungkinkan didiferensialkan atau dintegralkan secara langsung fungsi yang nilai-nilainya disajikan dalam bentuk tabel [tabulasi data x vs f(x)]
Cara mencari nilai integral 8
http://istiarto.staff.ugm.ac.id
2 + cos(1 + x ) 0.5 x ∫0 1 + 0.5sin x e d x 2
32
x
f(x)
0.25
2.599
0.75
2.414
1.25
1.945
1.75
1.993
4 3 2
A1
1
A2
A3
A4
∫f(x) dx = luas = ∑Ai 0 0
0.5
1
1.5
2
2.5
Derivatif 9
http://istiarto.staff.ugm.ac.id
u = f (x ) dan v = f (x )
y = un y = uv
y=
u v
dy du = n u n−1 dx dx dy du dv =v +u dx dx dx du dv −u dy = dx 2 dx dx v v
d sin x = cos x dx d cos x = − sin x dx d tan x = sec2 x dx d 1 ln x = dx x d x e = ex dx
d cot x = − csc2 x dx d sec x = sec x tan x dx d csc x = − csc x cot x dx d 1 log a x = dx x ln a d x a = a x ln a dx
Integral 10
http://istiarto.staff.ugm.ac.id
1 ( ) cos ax + b d x = sin(ax + b ) + C ∫ a
∫ u dv = uv − ∫ v du u n +1 ∫ u dv = n + 1 + C a bx bx ∫ a d x = blna + C dx ∫ x = ln x + C n
n ≠ −1 a > 0, a ≠ 1
1 ( ) sin ax + b d x = − cos(ax + b ) + C ∫ a
∫ ln x d x = x ln x − x + C e ax ∫e dx = a + C e ax ax ∫ x e d x = a2 (ax − 1) + C dx 1 ab −1 = tan x +C ∫ a + bx2 ab a ax
11
Metode Integrasi Newton-Cotes Metode Trapesium Metode Simpson Metode Kuadratur Gauss
http://istiarto.staff.ugm.ac.id
Persamaan Newton-Cotes 12
http://istiarto.staff.ugm.ac.id
q
Strategi q
mengganti fungsi kompleks dan rumit atau tabulasi data dengan yang mudah untuk diintegralkan b
b
a
a
I = ∫ f (x )d x = ∫ fn (x )d x
fn (x ) = a0 + a1 x + a2 x 2 + ... + an−1 x n−1 + an x n
polinomial tingkat n
Persamaan Newton-Cotes 13
http://istiarto.staff.ugm.ac.id
f (x )
f (x )
a
b
x
Garis lurus (polinomial tingkat 1) sbg fungsi pendekatan.
a
b
x
Kurva parabola (polinomial tingkat 2) sbg fungsi pendekatan.
Persamaan Newton-Cotes 14
http://istiarto.staff.ugm.ac.id
f (x ) 1
Fungsi yang diintegralkan didekati dengan 3 buah garis lurus (polinomial tingkat 1). Dapat pula dipakai beberapa kurva polinomial tingkat yang lebih tinggi.
2 3
a
b
x
Garis lurus (polinomial tingkat 1) sbg fungsi pendekatan.
Metode Trapesium 15
http://istiarto.staff.ugm.ac.id
q
Fungsi pendekatan untuk menghitung integral adalah polinomial tingkat 1 b
b
a
a
I = ∫ f (x )d x = ∫ f1 (x )d x q
Sebuah garis lurus dapat dinyatakan dengan persamaan f1 (x ) = f (a ) +
f (b) − f (a ) (x − a ) b−a
Metode Trapesium 16
http://istiarto.staff.ugm.ac.id
f (b) − f (a ) ⎡ ⎤ ( I ≅ ∫ ⎢ f (a ) + x − a )⎥ d x a b−a ⎣ ⎦ f (a ) + f (b) ≅ (b − a ) 2 b
Metode Trapesium
error
f (x )
a
b
x
Metode Trapesium 17
http://istiarto.staff.ugm.ac.id
Penyelesaian eksak I=∫
0.8
0
(0.2 + 25x − 200x
2
+ 675x 3 − 900 x 4 + 400 x 5 ) d x 0.8
200 3 675 4 400 6 ⎞ ⎛ = ⎜ 0.2 x + 12.5x 2 − x + x − 180 x 5 + x ⎟ = 1.640533 3 4 6 ⎝ ⎠ 0
Metode Trapesium f (x ) = 0.2 + 25 x − 200 x 2 + 675x 3 − 900 x 4 + 400x 5 f (0 ) = 0.2 dan f (0.8 ) = 0.232 I = (0.8 − 0)
0.2 + 0.232 = 0.1728 2
Et = 1.640533− 0.1728 = 1.467733 (≈ 89%)
[error]
Metode Trapesium 18
http://istiarto.staff.ugm.ac.id
4
q
f(x)
Error atau kesalahan q
3 2
error q
1
x
0 0
0.2
0.4
0.6
0.8
bentuk trapesium untuk menghitung nilai integral mengabaikan sejumlah besar porsi daerah di bawah kurva
Kuantifikasi error pada Metode Trapesium Et = −
1 f ʹ′ʹ′(ξ )(b − a )3 12
ξ adalah titik di antara a dan b
Metode Trapesium 19
http://istiarto.staff.ugm.ac.id
4
f ʹ′ʹ′(x ) = −400 + 4050 x 3 − 10800x 2 + 8000 x 3
f(x)
nilai rata-rata derivatif kedua:
3
0.8
(− 400 + 4050x ∫ ʹ′ ʹ′ f (x ) = 0
2
Ea = −
1
x 0
0.2
0.4
0.6
− 10800x 2 + 8000x 3 )d x
0.8 − 0
= −60
error:
error
0
3
0.8
1 (− 0.60 )(0.8 − 0)3 = 2.56 12
order of magnitude nilai error ini sama dengan order of magnitude nilai error terhadap nilai penyelesaian eksak dan keduanya sama tanda (sama-sama positif)
Trapesium multi pias 20
http://istiarto.staff.ugm.ac.id
q
Peningkatan akurasi q
selang ab dibagi menjadi sejumlah n pias dengan lebar seragam h
h=
b−a n
Trapesium multi pias 21
http://istiarto.staff.ugm.ac.id
4
b−a h= n
f(x)
3 2
f(x)
3 2
h = 0.2
h = 0.1
1 0
4
1
x 0
0.2
0.4
0.6
0.8
0
x 0
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
Trapesium multi pias 22
http://istiarto.staff.ugm.ac.id
h=
b−a n
Jika a = x0 dan b = xn x1
x2
xn
x0
x1
x n −1
I = ∫ f (x )d x + ∫ f (x )d x + ... + ∫ I≈h
f (x )d x
f (x0 ) + f (x1 ) f (x1 ) + f (x2 ) f (xn−1 ) + f (xn ) +h + ... + h 2 2 2
⎤ h ⎡ ⎧ n−1 ⎫ I ≈ ⎢ f (x0 ) + ⎨2∑ f (xi )⎬ + f (xn )⎥ 2 ⎣ ⎩ i =1 ⎭ ⎦
⎧ n−1 ⎫ f (x0 ) + ⎨2∑ f (xi )⎬ + f (xn ) ⎩ i =1 ⎭ I ≈ (b − a ) $#" 2n lebar $!!!!#!!!!" tinggi rata-‐rata
Trapesium multi pias 23
http://istiarto.staff.ugm.ac.id
Error = jumlah error pada setiap pias Et
( b − a )3 =− 3
12n
n
∑ f ʹ′ʹ′(ξ ) i =1
i
1 n f ʹ′ʹ′(ξi ) = f ʹ′ʹ′ ∑ n i =1
Et ≈ Ea
( b − a )3 =− 2
12n
f ʹ′ʹ′
setiap kelipatan jumlah pias, error mengecil dengan faktor kuadrat peningkatan jumlah pias
Trapesium multi pias 24
http://istiarto.staff.ugm.ac.id
f (x ) = 0.2 + 25x − 200x 2 + 675x 3 − 900x 4 + 400x 5 0.8
I = ∫ f (x )d x = 1.640533 (exact solution) 0 0.8
I ≈ ∫ f1 (x )d x (the trapezoidal rule) 0
100
%Et vs n
n
h
I
Et
%Et
Ea
60
1
0.8
0.1728
1.4677
89%
2.56
40
2
0.4
1.0688
0.5717
35%
0.64
20
4
0.2
1.4848
0.1557
9%
0.16
8
0.1
1.6008
0.0397
2%
0.04
80
0 1
2
n 4
8
Metode Simpson 25
http://istiarto.staff.ugm.ac.id
The trapezoidal rule q
Fungsi pendekatan: polinomial tingkat 1 q
Peningkatan ketelitian dpt dilakukan dengan meningkatkan jumlah pias
Simpson’s rules q
Fungsi pendekatan: polinomial: q q
tingkat 2: Simpson 1/3 tingkat 3: Simpson 3/8
Metode Simpson 26
http://istiarto.staff.ugm.ac.id
4
4
f(x)
3
3
f2(x)
2
2
1
1
0
x 0
0.2
f(x)
0.4
0.6
Simpson ⅓
0.8
0
f3(x)
x 0
0.2
0.4
0.6
Simpson ⅜
0.8
Metode Simpson 27
http://istiarto.staff.ugm.ac.id
q
Polinomial tingkat 2 atau 3 q
dicari dengan Metode Newton atau Lagrange (lihat materi tentang curve fitting)
Simpson ⅓ 28
http://istiarto.staff.ugm.ac.id
b
b
a
a
I = ∫ f (x )d x ≈ ∫ f2 (x )d x
Jika a = x0 dan b = xn dan f2(x) diperoleh dengan Metode Lagrange ⎡ (x − x1 )(x − x2 ) ⎤ ( ( x − x0 )(x − x2 ) x − x0 )(x − x1 ) I ≈ ∫ ⎢ f (x0 ) + f (x1 ) + f (x2 )⎥ d x a (x − x )(x − x ) ( ) ( ) ( ) ( ) x − x x − x x − x x − x 1 0 1 2 2 0 2 1 ⎣ 0 1 0 2 ⎦ b
I≈
h [f (x0 ) + 4 f (x1 ) + f (x2 )] 3 b−a h= 2
atau
I ≈ (b − a )
Et
f (x0 ) + 4 f (x1 ) + f (x2 ) 6
( b − a )5 4 =− f (ξ) 180n4
Simpson ⅓ multi pias 29
http://istiarto.staff.ugm.ac.id
x2
x4
xn
x0
x2
x n−2
I ≈ ∫ f (x )d x + ∫ f (x )d x + ... + ∫ I ≈ 2h
f (x )d x
f (x 0 ) + 4 f (x1 ) + f (x2 ) f (x2 ) + 4 f (x 3 ) + f (x 4 ) f (x n−2 ) + 4 f (x n−1 ) + f (x n ) + 2h + ... + 2h 6 6 6
f (x0 ) + 4 I ≈ (b − a )
Ea
n−1
n−2
∑ f (x ) + 2 ∑ f (x ) + f (x )
i =1 ,3 , 5
i
i =2 , 4 ,6
i
n
3n
( b − a )5 =− 180n
4
f4
(estimasi error, f 4 rata-rata derivatif ke-4)
Simpson ⅜ 30
http://istiarto.staff.ugm.ac.id
b
b
a
a
I = ∫ f (x )d x ≈ ∫ f3 (x )d x
Jika a = x0 dan b = xn dan f3(x) diperoleh dengan Metode Lagrange b⎡ (x − x )(x − x )(x − x ) (x − x0 )(x − x2 )(x − x3 ) f (x ) + (x − x0 )(x − x1 )(x − x3 ) f (x ) + (x − x0 )(x − x1 )(x − x2 ) f (x )⎤ d x 1 2 3 I ≈ ∫ ⎢ f (x0 ) + a (x − x )(x − x )(x − x ) (x1 − x0 )(x1 − x2 )(x1 − x3 ) 1 (x2 − x0 )(x2 − x1 )(x2 − x3 ) 2 (x3 − x0 )(x3 − x1 )(x3 − x2 ) 3 ⎥⎦ ⎣ 0 1 0 2 0 3
I≈
3h f (x ) + 3 f (x1 ) + 3 f (x2 ) + f (x3 ) [f (x0 ) + 3 f (x1 ) + 3 f (x2 ) + f (x3 )] atau I ≈ ($ b − a) 0 #" 8 8 " lebar $!!!!!#!!!!! tinggi rata−rata b−a h= 3
Simpson ⅜ 31
http://istiarto.staff.ugm.ac.id
Error 3 Et = − h5 f 4 (ξ) 80
atau
Et
( b − a )5 4 =− f (ξ) 6480
Simpson ⅓ dan ⅜ 32
http://istiarto.staff.ugm.ac.id
f (x ) = 0.2 + 25x − 200x 2 + 675x 3 − 900x 4 + 400x 5 0.8
I = ∫ f (x )d x = 1.640533 (exact solution) 0
Metode
I
Et
Simpson ⅓ (n = 2)
1.367467
0.273067 (17%)
Simpson ⅜ (n = 3)
1.51917
0.121363 (7%)
Simpson ⅓ (n = 4)
1.623467
0.017067 (1%)
Pias tak seragam: Metode Trapesium 33
http://istiarto.staff.ugm.ac.id
i 0 1 2 3 4 5 6 7 8 9 10
xi 0 0.12 0.22 0.32 0.36 0.4 0.44 0.54 0.64 0.7 0.8
f(xi) 0.2 1.309729 1.305241 1.743393 2.074903 2.456 2.842985 3.507297 3.181929 2.363 0.232
I 0.090584 0.130749 0.152432 0.076366 0.090618 0.10598 0.317514 0.334461 0.166348 0.12975 1.594801
f (x ) = 0.2 + 25 x − 200 x 2 + 675x 3 − 900 x 4 + 400 x 5
I dihitung dengan Metode Trapesium di setiap pias: f (x1 ) + f (x0 )
I = h1
+ 2 f (x2 ) + f (x1 ) f (xn ) + f (xn−1 ) h2 + ... + hn 2 2
0.8
∫ f (x )d x = 1.594801 0
Pias tak seragam: Metode Simpson 34
http://istiarto.staff.ugm.ac.id
i 0 1 2 3 4 5 6 7 8 9 10
xi 0 0.12 0.22 0.32 0.36 0.4 0.44 0.54 0.64 0.7 0.8
f(xi) 0.2 1.309729 1.305241 1.743393 2.074903 2.456 2.842985 3.507297 3.181929 2.363 0.232
I
f (x ) = 0.2 + 25 x − 200 x 2 + 675x 3 − 900 x 4 + 400 x 5
I dihitung dengan Metode Simpson ⅓ dan Simpson ⅜:
PR, dikumpulkan minggu depan
Metode Integrasi Numeris 35
http://istiarto.staff.ugm.ac.id
Metode
Jumlah pias
Lebar pias
Trapesium
1
Trapesium multi pias
n>1
seragam atau tak-seragam
Simpson ⅓
2
seragam
Simpson ⅓ mul( pias
genap (2m, m = 2,3,…)
seragam
Simpson ⅜
3
seragam
Kuadratur Gauss
1
Kuadratur Gauss 36
http://istiarto.staff.ugm.ac.id
f (x )
f (x )
error terlalu besar
x
upaya mengurangi error
x
Kuadratur Gauss 37
http://istiarto.staff.ugm.ac.id
f (x )
Kuadratur Gauss 2 Titik: Gauss-Legendre f (x1 )
1
I = ∫ f (x )d x ≈ c0 f (x0 ) + c1 f (x1 ) −1
f (x0 )
c , c , x , x : !!unknowns !0 1 0 1 1 c0 f (x0 ) + c1 f (x1 ) = ∫ 1 d x = 2 −1 1
c0 f (x0 ) + c1 f (x1 ) = ∫ x d x = 0 −1
− 1 x0
x1
1
1
x
c0 f (x0 ) + c1 f (x1 ) = ∫ x 2 d x = 2 3 −1 1
c0 f (x0 ) + c1 f (x1 ) = ∫ x 3 d x = 0 −1
Kuadratur Gauss 38
http://istiarto.staff.ugm.ac.id
f (x )
2
1.5 1
1.5
f (x ) = 1
0.5
x 1
0
0.5
∫ 1d x = 2 −1
1
-1
-0.5 0 -0.5
0.5
-1
0 -0.5
x
0 -1.5
-1
f (x ) = x
0.5
1
-1.5
f (x )
1.5
-1.5 1
∫ xdx = 0 −1
1
1.5
Kuadratur Gauss 39
http://istiarto.staff.ugm.ac.id
f (x )
2
f (x )
3
f (x ) = x
2
2
f (x ) = x 3
1
1
x
0 -1.5
-1
-0.5
0
0.5
-1
x
-2
0 -1.5
-1
-0.5
∫
1
0
0.5
x2 d x = 2 3
−1
1
1.5
-3
∫
1
x3 d x = 0
−1
1
1.5
Kuadratur Gauss 40
http://istiarto.staff.ugm.ac.id
1
c0 f (x0 ) + c1 f (x1 ) = ∫ 1 d x = 2 −1 1
c0 f (x0 ) + c1 f (x1 ) = ∫ x d x = 2 −1 1
2
c0 f (x0 ) + c1 f (x1 ) = ∫ x d x = 2 3 −1 1
c0 f (x0 ) + c1 f (x1 ) = ∫ x 3 d x = 0
c0 = c1 = 1 x0 = − 1 x1 = 1
3 3
I ≈ c0 f (x0 ) + c1 f (x1 )
−1
(
I ≈ f −1
) (
3 +f1
3
)
Kuadratur Gauss 41
http://istiarto.staff.ugm.ac.id
Untuk batas integrasi dari a ke b: § diambil asumsi suatu variabel xd yang dapat dihubungkan dengan variabel asli x dalam suatu relasi linear
x = a0 + a1 xd § jika batas bawah, x = a, berkaitan dengan xd = −1 ⇒ a = a0 + a1 (− 1) § jika batas atas, x = b, berkaitan dengan xd = 1
x=
⇒ b = a0 + a1 (1)
(b + a ) + (b − a ) xd 2 (b − a ) d x dx = d 2
x = a0 + a1 xd
a0 =
b+a b−a dan a1 = 2 2
Kuadratur Gauss 42
http://istiarto.staff.ugm.ac.id
f (x ) = 0.2 + 25x − 200x 2 + 675x 3 − 900x 4 + 400x 5 0.8
I = ∫ f (x )d x = 1.640533 (exact solution) 0
Penyelesaian dengan Metode Kuadratur Gauss: x=
(0.8 + 0 ) + (0.8 − 0 )xd
dx =
2
= 0.4 + 0.4 xd
0.8 − 0 d xd = 0.4 d xd 2
Kuadratur Gauss 43
http://istiarto.staff.ugm.ac.id
0.8
∫ (0.2 + 25x − 200x 0
2
+ 675x 3 − 900 x 4 + 400 x 5 )d x =
⎧⎪⎡0.2 + 25(0.4 + 0.4 x d ) − 200(0.4 + 0.4 x d )2 + 675(0.4 + 0.4 x d )3 ∫−1 ⎨⎪⎢⎢900(0.4 + 0.4 x )4 + 400(0.4 + 0.4 x )5 d d ⎩⎣ 1
−⎤ ⎫⎪ ⎥ 0.4 ⎬ d x d = ⎦⎥ ⎪⎭
0.8
(
f xd = − 1
(
f xd = 1
) 3 ) = 1.305837
3 = 0.516741
I ≈ ∫ f (x )d x 0
= 0.516741 + 1.305837 = 1.822578
44
http://istiarto.staff.ugm.ac.id