Numerical Differentiation and Integration
INTEGRASI NUMERIS
https://istiarto.staff.ugm.ac.id
Integrasi Numeris
❑
Acuan
❑
Chapra, S.C., Canale R.P., 1990, Numerical Methods for Engineers, 2nd Ed., McGraw-Hill Book Co., New York.
◼ Chapter 15 dan 16, hlm. 459-523.
2
https://istiarto.staff.ugm.ac.id
Diferensial, Derivatif
xi xi +Δx yi
yi +Δy
Δx Δy
xi xi +Δx yi
yi +Δy
xi yi
(a) (b) (c)
( ) ( )
x
x f x x
f x
y i i
−
= +
( ) ( )
x
x f x x
f x
y i i
x
−
= +
→
lim0
d d
difference approximation
f(x
i+Δx)
f(x
i)
3
https://istiarto.staff.ugm.ac.id
Diferensial, Derivatif
( ) ( )
x
x f x x
f x
y i i
−
= +
( ) ( )
x
x f x x
f x
y i i
x
−
= +
→
lim0
d d
pendekatan beda (hingga)
difference approximation derivatif
( )
x f x yy = = d
d
derivatif = laju perubahan y terhadap x
4
𝑛=0
∞ 𝑓(𝑛) 𝑎
𝑛! 𝑥 − 𝑎 𝑛 Deret Taylor
https://istiarto.staff.ugm.ac.id
Diferensial
0 40 80 120 160
0 2 4 6 8 10
y
x
slope = dy/dx
0 6 12 18 24
0 2 4 6 8 10
dy/dx
x
5 .
5x1
y =
5 .
5 0
. d 7
d x
xy =
5
https://istiarto.staff.ugm.ac.id
Integral
0 40 80 120 160
0 2 4 6 8 10
∫y dx
x
5 .
5 0
. 7 x y =
5 .
5 1
dx x
y =
= xy x
0 d
luas
▪ “kebalikan” dari proses men-diferensial-kan adalah meng-integral-kan
▪ integrasi ›‹ diferensiasi 0
6 12 18 24
0 2 4 6 8 10
y
x
6
https://istiarto.staff.ugm.ac.id
Fungsi
❑
Fungsi-fungsi yang di-diferensial-kan atau di-integral-kan dapat berupa:
❑
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)]
7
https://istiarto.staff.ugm.ac.id
Cara mencari nilai integral
( )
2 + + +0
5 . 0 2 3
sin d 5 . 0 1
1 cos
2 e x
x
x x
x f(x)
0.25 2.599
0.75 2.414
1.25 1.945
1.75 1.993 0
1 2 3 4
0 0.5 1 1.5 2 2.5
A1 A2 A3 A4
∫f(x) dx = luas = ∑Ai
8
https://istiarto.staff.ugm.ac.id
Derivatif
x u u
x n
y n
d d d
d = −1
( )
x v f( )
x fu= dan = un
y =
v u y =
v y = u
x u v x v u x y
d d d
d d
d = +
2
d d d
d d
d
v
x u v x v u
x
y −
=
x
x e
x e x x x
x x x
x x x
x x x
=
=
=
−
=
=
d d
ln 1 d
d
sec d tan
d
sin d cos
d
cos d sin
d
2
a a xa
a x x
x
x x
x x
x x
x x
x x x
x x
a
d ln d
ln log 1
d d
cot csc
d csc d
tan sec
d sec d
csc d cot
d 2
=
=
−
=
=
−
=
9
https://istiarto.staff.ugm.ac.id
Integral
( ) (
ax b)
Cx a b ax
C x x
x
a a
a C b x a a
n n C
v u u
u v uv v
u
bx bx
n n
+ +
−
= +
+
=
+
=
−
+ +
=
−
=
+
1cos d
sin d ln
1 ,
ln 0 d
1 1 d
d d
1
( ) ( )
( )
C a x
ab bx ab
a x
C a ax
x e e
x
a C x e e
C x x x x x
C b a ax
x b ax
ax ax
ax ax
+ + =
+
−
= +
=
+
−
=
+ +
= +
−
1 2
2
1 tan d
1 d
d
ln d
ln
1sin d
cos
10
Metode Trapesium Metode Simpson
Metode Kuadratur Gauss
Metode Integrasi Newton-Cotes
11
https://istiarto.staff.ugm.ac.id
Persamaan Newton-Cotes
❑
Strategi
❑
mengganti fungsi kompleks dan rumit atau tabulasi data dengan yang mudah untuk diintegralkan
( ) ( )
=
=
ba n b
a
f x x f x x
I d d
( )
n n n nn
x a a x a x a x a x
f =
0+
1+
2 2+ ... +
−1 −1+
polinomial tingkat n
12
https://istiarto.staff.ugm.ac.id
Persamaan Newton-Cotes
( ) x f
x
a b
( ) x f
a b
x
Garis lurus (polinomial tingkat 1) sbg fungsi pendekatan.
Kurva parabola (polinomial tingkat 2) sbg fungsi pendekatan.
13
https://istiarto.staff.ugm.ac.id
Persamaan Newton-Cotes
( ) x f
x
a b
Garis lurus (polinomial tingkat 1) sbg fungsi pendekatan.
1 2
3
Fungsi yang diintegralkan didekati dengan 3 buah garis lurus (polinomial tingkat 1).
Dapat pula dipakai beberapa kurva polinomial tingkat yang lebih tinggi.
14
https://istiarto.staff.ugm.ac.id
Metode Trapesium
❑
Fungsi pendekatan untuk menghitung integral adalah polinomial tingkat 1
❑
Sebuah garis lurus dapat dinyatakan dengan persamaan
( ) ( )
=
=
ba b
a
f x x f x x
I d
1d
( ) ( ) ( ) ( )( x a )
a b
a f b
a f f x
f −
− + −
1
=
15
https://istiarto.staff.ugm.ac.id
Metode Trapesium
( ) ( ) ( )( ) ( ) ( ) ( )
2
d b
f a
a f b
x a
a x b
a f b
a f f I
ba
− +
−
− + −
Metode Trapesium
( ) x f
x
a b
error
16
https://istiarto.staff.ugm.ac.id
Metode Trapesium
( )
640533 .
6 1 180 400
4 675 3
5 200 . 12 2
. 0
d 400
900 675
200 25
2 . 0
8 . 0
0 6 5
4 3
2 8
. 0 0
5 4
3 2
=
+ − + − +
=
+
− +
− +
=
x x
x x
x x
x x
x x
x x
I
( ) ( )
0 0.2 dan( )
0.8 0.232400 900
675 200
25 2
.
0 2 3 4 5
=
=
+
− +
− +
=
f f
x x
x x
x x
f
Penyelesaian eksak
Metode Trapesium
( )
0.17282
232 . 0 2 . 0 0 8 .
0 + =
−
I = Et =1.640533−0.1728=1.467733
(
89%) [error]
17
https://istiarto.staff.ugm.ac.id
0 1 2 3 4
0 0.2 0.4 0.6 0.8
x
f(x)
Metode Trapesium
❑
Error atau kesalahan
❑
bentuk trapesium untuk menghitung nilai integral
mengabaikan sejumlah besar porsi daerah di bawah kurva
❑
Kuantifikasi error pada Metode Trapesium
error
( )( )
312
1 f b a
Et = − −
adalah titik di antara a dan b
18
https://istiarto.staff.ugm.ac.id
Metode Trapesium
0 1 2 3 4
0 0.2 0.4 0.6 0.8
x
f(x)
error
( 0.60)(0.8 0) 2.56 12
1 − − 3 =
−
a = E
( )x 400 4050x3 10800x2 8000x3
f =− + − +
nilai rata-rata derivatif kedua:
( )
( )
0 60 8 . 0
d 8000 10800
4050
8 400
. 0 0
3 2
3
−
− =
+
− +
= −
x
x x x xf
error:
order of magnitude nilai error ini sama dengan order of magnitude nilai error terhadap nilai penyelesaian eksak dan keduanya sama tanda (sama-sama positif)
19
https://istiarto.staff.ugm.ac.id
Trapesium multi pias
❑
Peningkatan akurasi
❑
selang ab dibagi menjadi sejumlah n pias dengan lebar seragam h
n a h = b −
20
https://istiarto.staff.ugm.ac.id
0 1 2 3 4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
x
f(x)
h = 0.1
Trapesium multi pias
0 1 2 3 4
0 0.2 0.4 0.6 0.8
x
f(x)
h = 0.2
n a h= b−
21
https://istiarto.staff.ugm.ac.id
Trapesium multi pias
n a h= b−
xn
b x
a= dan =
Jika 0
( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( )
... 2 2
2
d ...
d d
1 2
1 1
0
1 2
1 1
0
n n
x x x
x x
x
x f x
h f x
f x
h f x
f x
h f I
x x f x
x f x
x f
I n
n
+ + + +
+ +
+ + +
=
−
−( ) ( ) ( )
+
+
−= n
n
i
i f x
x f x
h f I
1
1
0 2
2
( ) ( ) ( ) ( )
rata - rata tinggi
1
1 0
lebar 2
2 n
x f x
f x
f a b I
n n
i
i +
+
−
−= 22
https://istiarto.staff.ugm.ac.id
Trapesium multi pias
( ) ( )
=
− −
= n
i
i
t f
n a E b
1 3
3
12
Error = jumlah error pada setiap pias
( )
f n fn
i
i =
=11
( )
n f a E b
Et a =− − 2 3
12
setiap kelipatan jumlah pias, error mengecil dengan faktor kuadrat peningkatan jumlah pias
23
https://istiarto.staff.ugm.ac.id
Trapesium multi pias
( )
x 0.2 25x 200x2 675x3 900x4 400x5f = + − + − +
n h I Et %Et Ea
1 0.8 0.1728 1.4677 89% 2.56
2 0.4 1.0688 0.5717 35% 0.64
4 0.2 1.4848 0.1557 9% 0.16
8 0.1 1.6008 0.0397 2% 0.04
( )
d 1.6405338 . 0
0 =
=
f x xI
( )
0.8
0 f1 x d x
I
(the trapezoidal rule) (exact solution)
0 20 40 60 80 100
1 2 n 4 8
%Et vs n
24
https://istiarto.staff.ugm.ac.id
Metode Simpson
❑
Fungsi pendekatan:
polinomial tingkat 1
❑
Peningkatan ketelitian dpt dilakukan dengan
meningkatkan jumlah pias
❑
Fungsi pendekatan:
polinomial:
❑
tingkat 2: Simpson 1/3
❑
tingkat 3: Simpson 3/8
The trapezoidal rule Simpson’s rules
25
https://istiarto.staff.ugm.ac.id
Metode Simpson
0 1 2 3 4
0 0.2 0.4 0.6 0.8
x
f(x) f
2(x)
0 1 2 3 4
0 0.2 0.4 0.6 0.8
x
f(x) f
3(x)
Simpson ⅓ Simpson ⅜
26
https://istiarto.staff.ugm.ac.id
Metode Simpson
❑
Polinomial tingkat 2 atau 3
❑
dicari dengan Metode Newton atau Lagrange (lihat materi tentang curve fitting)
27
https://istiarto.staff.ugm.ac.id
Simpson ⅓
( ) ( )
= b
a b
a f x x f x x
I d 2 d
xn
b x
a = dan =
Jika 0
( )( )
( )( ) ( ) ( )( )
( )( ) ( ) ( )( )
( )( ) ( )
−− −− + −− −− + −− −− b
a f x x
x x x x
x x x x x
x f x x x
x x x x x
x f x x x
x x x
I x 2 d
1 2 0 2
1 0
1 2
1 0 1
2 0
0 2
0 1 0
2 1
dan f2(x) diperoleh dengan Metode Lagrange
( ) ( ) ( )
0 4 1 2
3 f x f x f x
I h + +
2 a h= b−
( ) ( ) ( ) ( )
6
4 1 2
0 f x f x
x a f b
I − + +
atau
(
−) ( )
−
= 45 4
180 f n a Et b
28
https://istiarto.staff.ugm.ac.id
Simpson ⅓ multi pias
( ) ( ) ( )
+ + + − n
n
x x x
x x
x f x x f x x f x x
I
2 4
2 2
0
d ...
d d
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
6 2 4
6 ...
2 4 6
2 0 4 1 2 2 3 4 f xn 2 f xn 1 f xn
x h f x
f x
h f x
f x
f x
h f
I + + + + + + + − + − +
( ) ( ) ( ) ( ) ( )
n
x f x f x
f x
f a b I
n n
i
i n
i
i
3 2 4
2
6 , 4 , 2 1
5 , 3 , 1
0 + + +
−
−=
−
=
( )
44 5
180 f n a
Ea =− b−
(estimasi error,
f4rata-rata derivatif ke-4)
29
https://istiarto.staff.ugm.ac.id
Simpson ⅜
( ) ( )
= b
a b
a f x x f x x
I d 3 d
xn
b x
a = dan =
Jika 0
( )( )( )
( )( )( ) ( ) ( )( )( )
( )( )( ) ( ) ( )( )( )
( )( )( ) ( ) ( )( )( )
( )( )( ) ( )
−− −− −− + −− −− −− + −− −− −− + −− −− −−
b
a f x x
x x x x x x
x x x x x x x
x f x x x x x
x x x x x x x
x f x x x x x
x x x x x x x
x f x x x x x
x x x x x
I x 3 d
2 3 1 3 0 3
2 1
0 2
3 2 1 2 0 2
3 1
0 1
3 1 2 1 0 1
3 2
0 0
3 0 2 0 1 0
3 2
1
dan f3(x) diperoleh dengan Metode Lagrange
( ) ( ) ( ) ( )
0 3 1 3 2 3
8
3h f x f x f x f x
I + + +
3 a h= b−
( ) ( ) ( ) ( ) ( )
rata rata tinggi
3 2
1 0
lebar 8
3 3
−
+ +
− +
f x f x f x f x
a b
atau
I30
https://istiarto.staff.ugm.ac.id
Simpson ⅜
(
−) ( )
−
= 5 4
6480a f Et b
Error
( )
−
= 5 4
80 3 h f
Et
atau
31
https://istiarto.staff.ugm.ac.id
Simpson ⅓ dan ⅜
( )
x 0.2 25x 200x2 675x3 900x4 400x5f = + − + − +
( )
d 1.6405338 . 0
0 =
=
f x xI
(exact solution)
Metode I Et
Simpson ⅓ (n = 2) 1.367467 0.273067 (27%) Simpson ⅜ (n = 3) 1.51917 0.121363 (7%) Simpson ⅓ (n = 4) 1.623467 0.017067 (1%)
32
https://istiarto.staff.ugm.ac.id
Pias tak seragam: Metode Trapesium
( )
5 4
3
2
400 900
675
200 25
2 . 0
x x
x
x x
x f
+
−
+
− +
i xi f(xi) I =
0 0 0.2
1 0.12 1.309729 0.090584
2 0.22 1.305241 0.130749
3 0.32 1.743393 0.152432
4 0.36 2.074903 0.076366
5 0.4 2.456 0.090618
6 0.44 2.842985 0.10598
7 0.54 3.507297 0.317514
8 0.64 3.181929 0.334461
9 0.7 2.363 0.166348
10 0.8 0.232 0.12975
1.594801
I dihitung dengan Metode Trapesium di setiap pias:
( ) ( )
( ) ( ) ( ) ( )
... 2 2
2
1 1
2 2
0 1
1
+ −
+ + +
+ +
=
n n
n
x f x h f x
f x h f
x f x h f I
( )d 1.594801
8 . 0
0 =
f x x33
https://istiarto.staff.ugm.ac.id
Pias tak seragam: Metode Simpson
( )
5 4
3
2
400 900
675
200 25
2 . 0
x x
x
x x
x f
+
−
+
− +
i xi f(xi) I =
0 0 0.2
1 0.12 1.309729
2 0.22 1.305241
3 0.32 1.743393
4 0.36 2.074903
5 0.4 2.456
6 0.44 2.842985
7 0.54 3.507297
8 0.64 3.181929
9 0.7 2.363
10 0.8 0.232
I dihitung dengan Metode Simpson ⅓ dan Simpson ⅜:
PR, dikumpulkan minggu depan
34
https://istiarto.staff.ugm.ac.id
Metode Integrasi Numeris
Metode Jumlah pias Lebar pias
Trapesium 1
Trapesium multi pias n > 1 seragam atau tak-seragam
Simpson ⅓ 2 seragam
Simpson ⅓ multi pias genap (2m, m = 2,3,…) seragam
Simpson ⅜ 3 seragam
Kuadratur Gauss 1
35
https://istiarto.staff.ugm.ac.id
Kuadratur Gauss
( ) x f
x
( ) x f
error terlalu besar upaya mengurangi error
x
36
https://istiarto.staff.ugm.ac.id
Kuadratur Gauss
( )
x fx
( )
x0 f( )
x1 fx0 x1
−1 1
Kuadratur Gauss 2 Titik: Gauss-Legendre
( )
0( )
0 1( )
11
1 f x dx c f x c f x
I =
− +( ) ( ) ( ) ( ) ( ) ( )
( ) ( )
d 03 2 d
0 d
2 d
1
1 1
3 1
1 0
0
1 1
2 1
1 0
0
1 1 1
1 0
0
1 1 1
1 0
0
=
= +
=
= +
=
= +
=
= +
−
−
−
−
x x x
f c x
f c
x x x
f c x
f c
x x x
f c x
f c
x x
f c x
f c
c
0, c
1, x
0, x
1: unknowns
37
https://istiarto.staff.ugm.ac.id
0 0.5 1 1.5 2
-1.5 -1 -0.5 0 0.5 1 1.5 -1.5
-1 -0.5 0 0.5 1 1.5
-1.5 -1 -0.5 0 0.5 1 1.5
Kuadratur Gauss
( ) x f
x
( ) x = 1 f
( ) x x
f =
2 d
1
1
1
=
−x
1d 0
1
=
−x x
( ) x f
x
38
https://istiarto.staff.ugm.ac.id
-3 -2 -1 0 1 2 3
-1.5 -1 -0.5 0 0.5 1 1.5
0 1 2
-1.5 -1 -0.5 0 0.5 1 1.5
Kuadratur Gauss
( ) x f
x
( ) x x
2f = f ( ) x = x
33 2
1
d
1
2
=
−x x
1d 0
1
3
=
−x x
( ) x f
x
39
https://istiarto.staff.ugm.ac.id
Kuadratur Gauss
( ) ( ) ( ) ( ) ( ) ( )
( ) ( )
d 03 2 d
2 d
2 d
1
1 1
3 1
1 0
0
1 1
2 1
1 0
0
1 1 1
1 0
0
1 1 1
1 0
0
=
= +
=
= +
=
= +
=
= +
−
−
−
−
x x x
f c x
f c
x x x
f c x
f c
x x x
f c x
f c
x x
f c x
f c
( )
0 1( )
10f x c f x
c
I +
3 1
3 1
1
1 0
1 0
=
−
=
=
=
x x
c c
(
1 3) ( )
f 1 3f
I − +
40
https://istiarto.staff.ugm.ac.id
Kuadratur Gauss
Untuk batas integrasi dari a ke b:
▪ diambil asumsi suatu variabel xdyang dapat dihubungkan dengan variabel asli x dalam suatu relasi linear
xd
a a
x = 0 + 1
▪ jika batas bawah, x = a, berkaitan dengan xd = −1
▪ jika batas atas, x = b, berkaitan dengan xd= 1
( )
11
0 + −
=
a a a
( )
11
0 a
a b= +
2 dan 2 1
0
a a b
a
a = b+ = −
( ) ( )
( )
d d
a x x b
x a b a
x b
2 d d
2 −
=
− +
= +
xd
a a
x = 0 + 1
41
https://istiarto.staff.ugm.ac.id
Kuadratur Gauss
( )
x 0.2 25x 200x2 675x3 900x4 400x5f = + − + − +
( )
d 1.6405338 . 0
0 =
=
f x xI
(exact solution)
Penyelesaian dengan Metode Kuadratur Gauss:
( ) ( )
d d
d d
x x
x
x x x
d 4 . 0 2 d
0 8 . d 0
4 . 0 4 . 2 0
0 8 . 0 0
8 . 0
− =
=
+
− = +
= +
42
https://istiarto.staff.ugm.ac.id
Kuadratur Gauss
( )
( ) ( ) ( )
( ) ( )
=
+ +
+
− +
+ +
− +
+
= +
− +
− +
− 1
1 4 5
3 2
8 . 0 0
5 4
3 2
d 4 . 4 0
. 0 4 . 0 400 4
. 0 4 . 0 900
4 . 0 4 . 0 675 4
. 0 4 . 0 200 4
. 0 4 . 0 25 2
. 0
d 400
900 675
200 25
2 . 0
d d
d
d d
d x
x x
x x
x
x x
x x
x x
( )
(
=d =−11 33)
==10..305837516741d
x f x
f
( )
822578 .
1
305837 .
1 516741 .
0
8 d
. 0 0
=
+
=
f x xI
43
44