integrasi numerik (bag. 1)

53
Integrasi Numerik (Bag. 1) Bahan Kuliah IF4058 Topik Khusus Informatika I Oleh; Rinaldi Munir (IF-STEI ITB) 1 IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

Upload: italia

Post on 24-Feb-2016

165 views

Category:

Documents


8 download

DESCRIPTION

Integrasi Numerik (Bag. 1). Bahan Kuliah IF4058 Topik Khusus Informatika I Oleh ; Rinaldi Munir (IF-STEI ITB). Persoalan Integrasi Numerik. Hitunglah nilai Integral- Tentu yang dalam hal ini : - a dan b batas-batas integrasi , - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

1

Integrasi Numerik(Bag. 1)

Bahan Kuliah IF4058 Topik Khusus Informatika I

Oleh; Rinaldi Munir (IF-STEI ITB)

Page 2: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

2

Persoalan Integrasi Numerik

Hitunglah nilai Integral-Tentu

yang dalam hal ini:- a dan b batas-batas integrasi, - f adalah fungsi yang dapat diberikan secara eksplisit

dalam bentuk persamaan ataupun secara empirik dalam bentuk tabel nilai.

b

a

dxxfI )(

Page 3: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

3

• Contoh integral fungsi eksplisit:

• Contoh integral dalam bentuk tabel (fungsi implisit):

Hitung:

2

0

23 ))cos(6( dxexxx x

x f(x)

0.00 0.25 0.50 0.75 1.00

6.0 7.5 8.0 9.0 8.5

0.1

0.0

)( dxxf

Page 4: Integrasi Numerik (Bag. 1)

Tafsir Geometri Integral Tentu

• Nilai integral-tentu = luas daerah di bawah kurva

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

y

a b

y = f(x )

x

b

a

dxxfI )( = luas daerah yang dibatasi oleh kurva y = f(x), garis x = a dan garis x = b

Page 5: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

5

Contoh persoalan integral

1. Dalam bidang teknik elektro/kelistrikan, telah diketahui bahwa harga rata-rata suatu arus listrik yang berosilasi sepanjang satu periode boleh nol. Disamping kenyataan bahwa hasil netto adalah nol, arus tersebut mampu menimbulkan kerja dan menghasilkan panas. Karena itu para rekayasawan listrik sering mencirikan arus yang demikian dengan persamaan

yang dalam hal ini IRMS adalah arus RMS (root-mean-square), T adalah periode, dan i(t) adalah arus pada rangkaian, misalnya

i(t) = 5e-2t sin 2t untuk 0 t T/2 = 0 untuk T/2 t T

T

dtti

I

T

RMS

0

2

Page 6: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

6

2. Pengukuran fluks panas matahari yang diberikan oleh tabel berikut:

Waktu, jam Fluks panas q,kalori/cm/jam

0 0.11 1.622 5.323 6.294 7.85 8.816 8.007 8.578 8.039 7.04

10 6.2711 5.5612 3.5413 1.014 0.2

t

ab qAdteH0

Data yang ditabulasikan pada tabel ini memberikan pengukuran fluks panas q setiap jam pada permukaan sebuah kolektor sinar matahari. Anda diminta memperkiraan panas total yang diserap oleh panel kolektor seluas 150.000 cm2 selama waktu 14 jam. Panel mempunyai kemangkusan penyerapan (absorption), eab, sebesar 45%. Panas total yang diserap diberikan oleh persamaan

Page 7: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

7

Klasifikasi Metode Integrasi Numerik

1. Metode Pias Daerah integrasi dibagi atas sejumlah pias (strip) yang berbentuk segiempat. Luas daerah integrasi dihampiri dengan luas seluruh pias.

2. Metode Newton-CotesFungsi integrand f(x) dihampiri dengan polinom interpolasi pn(x). Selanjutnya, integrasi dilakukan terhadap pn(x).

3. Kuadratur Gauss.Nilai integral diperoleh dengan mengevaluasi nilai fungsi pada sejumlah titik tertentu di dalam selang [-1, 1], mengalikannya dengan suatu konstanta, kemudian menjumlahkan keseluruhan perhitungan.

Page 8: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

8

Metode-Metode Pias

• Selang integrasi [a, b] menjadi n buah pias (strip) atau segmen. Lebar tiap pias adalah

• Titik absis pias dinyatakan sebagai xr = a + rh, r = 0, 1, 2, ..., n dan nilai fungsi pada titik absis pias adalahfr = f(xr)

nabh

y

y =f(x)fn-1

fn

f2

f1

f0

hhh

x a = x0 x1 x2 xn-1 xn=b

Gambar 6.2 Metode pias

r xr fr

0 x0 f0

1 x1 f1

2 x2 f2

3 x3 f3

4 x4 f4

... ... ...

n-2 xn-2 fn-2

n-1 xn-1 fn-1

n xn fn

Page 9: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

9

• Kaidah integrasi numerik yang dapat diturunkan dengan metode pias adalah:1. Kaidah segiempat (rectangle rule)2. Kaidah trapesium (trapezoidal rule)3. Kaidah titik tengah (midpoint rule)

• Dua kaidah pertama pada hakekatnya sama, hanya cara penurunan rumusnya yang berbeda

• Kaidah yang ketiga, kaidah titik tengah, merupakan bentuk kompromi untuk memperoleh nilai hampiran yang lebih baik.

Page 10: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

10

Kaidah Segiempat (Rectangle Rule)

y

xx 0

y = f(x )

h

x 1

Pandang sebuah pias berbentuk empat persegi panjang dari x = x0 sampai x = x1 berikut Luas satu pias adalah (tinggi pias = f(x0) )

)()( 0

1

0

xhfdxxfx

x

atau (bila tinggi pias = f(x1) )

)()( 1

1

0

xhfdxxfx

x

Page 11: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

11

1

0

)(x

x

dxxf hf (x0)

1

0

)(x

x

dxxf hf(x1) +

2 1

0

)(x

x

dxxf h [ f(x0) + f(x1)]

1

0

)(x

x

dxxf 2h [f(x0) + f(x1)]

(Kaidah Segiempat)

Page 12: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

12

• Kaidah segiempat gabungan (composite rectangle's rule):

b

a

dxxf )( hf (x0) + hf (x1) + hf (x2) + ... + hf (xn-1)

b

a

dxxf )( hf (x1) + hf (x2) + hf (x3) + ... + hf (xn) +

2 b

a

dxxf )( hf(x0) + 2hf (x1) + 2hf(x2) + ... + 2hf(xn-1) + hf(xn)

b

a

dxxf )( 2h f (x0) + hf(x1) + hf(x2) + ... + hf(xn-1) +

2h f (xn)

Page 13: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

13

Jadi, kaidah segiempat gabungan adalah

b

a

dxxf )( 2h ( f0 + 2f1 + 2f2+ ... + 2fn-1 + fn) =

2h (f0 + 2

1

1

n

iif + fn)

dengan fr = f(xr) , r = 0, 1, 2, ..., n .

y

xa = x 0 x n = b

y = f(x )

x 1 x 2

...

... x n- 1x n- 2x 3

Gambar Kaidah segiempat gabungan

Page 14: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

14

Kaidah Trapesium

y

x

h

x 0 x 1

Luas satu trapesium adalah

1

0

)(x

x

dxxf 2h [ f(x0) + f(x0)]

Pandang sebuah pias berbentuk trapesium dari x = x0 sampai x = x1 berikut

Page 15: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

15

• Kaidah trapesium gabungan (composite trapezoidal's rule):

b

a

dxxf )( 1

0

)(x

x

dxxf + 2

1

)(x

x

dxxf + ... +

n

n

x

x

dxxf1

)(

2h [ f(x0) + f(x1)] +

2h [ f(x1)+ f(x2)] + ... +

2h [ f(xn-1) + f(xn)]

2h [ f(x0) + 2f(x1) + 2f(x2) + ... + 2f(xn-1) + f(xn)]

2h ( f0 + 2

1

11

n

i

f + fn)

dengan fr = f(xr) , r = 0, 1, 2, ..., n.

Page 16: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

16

procedure trapesium(a, b : real; n: integer; var I : real);{ Menghitung integrasi f(x) di dalam selang [a, b] dan jumlas pias adalah n dengan menggunakan kaidah trapesium. K.Awal : nilai a, b, dan n sudah terdefinisi K.Akhir: I adalah hampiran integrasi yang dihitung dengan kaidah segi-empat. }var h, x, sigma: real; r : integer; begin h:=(b-a)/n; {lebar pias} x:=a; {awal selang integrasi} I:=f(a) + f(b); sigma:=0; for r:=1 to n-1 do begin x:=x+h;

sigma:=sigma + 2*f(x); end; I:=(I+sigma)*h/2; { nilai integrasi numerik}end;  

Page 17: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

17

Kaidah Titik Tengah• Pandang sebuah pias berbentuk empat persegi panjang dari x

= x0 sampai x = x1 dan titik tengah absis x = x0 + h/2

y

x

y = f(x )

h

x 0 x 1x 0 + h /2

Luas satu pias adalah

1

0

)(x

x

dxxf h f(x0 + h/2) h f(x1/2)

Page 18: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

18

y

x

a b

y = f(x )

x 1/2 x 3/2

...

... x n- 1/2x n- 3/2x 5/2

Page 19: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

19

Kaidah titik-tengah gabungan adalah

b

a

dxxf )( 1

0

)(x

x

dxxf + 2

1

)(x

x

dxxf + ... +

n

n

x

x

dxxf1

)(

hf(x1/2) + hf(x3/2) + hf(x5/2) + hf(x7/2) + ... + hf(xn-1/2)

h(f1/2 + f3/2 +... + fn-1/2) h

1

0

n

i

fi+1/2

yang dalam hal ini,

xr+1/2 = a + (r+1/2)h) dan

fr +1/2 = f(xr+1/2) r = 0,1,2,..,n-1

Page 20: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

20

procedure titik_tengah(a, b : real; n: integer; var I : real);{ menghitung integrasi f(x) dalam selang [a, b] dengan jumlah pias sebanyak n. K.Awal : harga a, b, dan n sudah terdefinisi K.Akhir: I adalah hampiran integrasi yang dihitung dengan kaidah titik-tengah}var h, x, sigma : real; r : integer; begin h:=(b-a)/n; {lebar pias} x:= a+h/2; {titik tengah pertama} sigma:=f(x); for r:=1 to n-1 do begin

x:=x+h; sigma:=sigma + f(x)

end; I:=sigma*h; { nilai integrasi numerik}end;

Page 21: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

21

• Contoh: Hitung integral dengan kaidah trapesium. Ambil h = 0.2. Gunakan 5 angka bena.Penyelesaian: Fungsi integrand-nya adalah

f(x) = ex Jumlah pias adalah n = (b-a)/h = (3.4 - 1.8)/0.2 = 8

Tabel data diskritnya adalah sebagai berikut:

4.3

8.1

dxe x

r xr f(xr) r xr f(xr) 0 1.8 6.050 5 2.8 16.445 1 2.0 7.389 6 3.0 20.086 2 2.2 9.025 7 3.2 24.533 3 2.4 11.023 8 3.4 29.964 4 2.6 13.464

Page 22: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

22

Nilai integrasinya,

4.3

8.1

dxe x 2h (f0 + 2f1 + 2f 2+ ... + 2f6 + 2f7 + f8)

22.0 [[6.050 + 2(7.389) + 2(9.025) +....+ 2(16.445)

+ 2(20.086) + 2(24.533) + 29.964] 23.994 Nilai integrasi sejatinya adalah

4.3

8.1

dxe x = ex 4.38.1

xx

= e 3.4 - e1.8 = 29.964 - 6.050 = 23.914

Page 23: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

23

Galat Metode-Metode Pias• Galat:

E = I – I '• yang dalam hal ini I adalah nilai integrasi sejati dan I ' adalah

integrasi secara numerik.

• Galat kaidah trapesium:

E = h

dxxf0

)( - 2

h ( f0 + f1)

y

x

y = f(x )

h

0 h

galat

Page 24: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

24

Galat untuk satu buah pias adalah

E = h

dxxf0

)( - 2

h ( f0 + f1)

E =h

0

[ f0 + xf0' + 21 x2f0" +

61 x3f0"' + ... ]dx -

2h f0 - 2

h [ f0 + hf0' + 21 h2f0" + ...]

= xf0 + 1/2 x2f0' + 1/6 x3f0"'+..]0

h - 1/2 hf0 - 1/2h f0 - 1/2 h2f0' - 1/4 h3f0"' - ...

= (hfo + 1/2 h2f '0 + 1/6 h3f "0 + ...) - (hf0 + 1/2 h2f '0 + 1/4 h3f0"'+ ...)

= - 121 h3f0 " + ...

- 121 h3f "(t) , 0 < t < h

O(h3)

Uraikan f(x) dan f1 = f(x1) = f(h) ke dalam deret Taylor di sekitar x0 = 0

Page 25: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

25

Jadi,

h

dxxf0

)( 2h ( f0 + f1) + O(h3)

Untuk n buah pias, galat keseluruhan (total) adalah

Etot - 12

3h ( f0" + f1" + f2" + ... + f "n-1)

yang dapat disederhanakan dengan teorema nilai antara untuk penjumlahan menjadi

Etot - 12

3h

1

1

n

i

fi "

- n 12

3h f "(t) , a < t < b

Page 26: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

26

Mengingat

h = n

ab

maka

Etot -n 12

3h f "(t)

- n n

ab 12

3h f "(t)

- 12

3h (b - a) f "(t)

O(h2)

Dengan demikian,

b

a

dxxf )( = 2h ( f0 + 2

1

1

n

i

fi + fn) + O(h2)

Page 27: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

27

• Galat kaidah titik-tengah:Galat untuk satu buah pias adalah

E = h

dxxf0

)( - hf1/2

Dengan cara penurunan yang sama seperti pada kaidah trapesium, dapat dibuktikan bahwa

E

24

3h f "(t) , 0 < t < h

Galat untuk seluruh pias adalah

Etot n 24

3h f "(t) , a < t < b

24

2h ( b - a) f "(t)

= O(h2)

Galat integrasi dengan kaidah titik tengah sama dengan 1/2 kali galat pada kaidah trapesium

Page 28: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

28

Metode-Metode Newton-Cotes• Metode Newton-Cotes adalah metode yang umum untuk

menurunkan kaidah integrasi numerik. • Polinom interpolasi menjadi dasar metode Newton-Cotes. • Gagasannya adalah menghampiri fungsi f(x) dengan polinom

interpolasi pn(x)

yang dalam hal ini,pn (x) = a0 + a1x + a2x2 + ... + an-1xn-1 + anxn

I = b

a

dxxf )( b

an dxxp )(

Page 29: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

29

• Sembarang polinom interpolasi yang telah kita bahas sebelumnya dapat digunakan sebagai hampiran fungsi

• Tetapi dalam kuliah ini polinom interpolasi yang kita pakai adalah polinom Newton-Gregory maju:

• Kaidah integrasi numerik yang diturunkan dari metode Newton-Cotes, tiga di antaranya yang terkenal adalah:1. Kaidah trapesium (Trapezoidal rule)2. Kaidah Simpson 1/3 (Simpson's 1/3 rule)3. Kaidah Simpson 3/8 (Simpson's 3/8 rule)

pn(x) = f0 + (x - x0) hf!1

0 + (x - x0)(x - x1) 2

02

!2 hf + … +

(x - x0)(x - x1). ..(x - xn-1) n

n

hnf

!0

Page 30: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

30

Kaidah Trapesium (lagi)y

y = p 1 (x )

x 0 = 0 x 1 = h

y = f(x )

x

Polinom interpolasi Newton-Gregory derajat 1 yang melalui kedua buah titik itu adalah

p1(x) = f(x0) + x hxf 0

= f0 + xhf 0

Page 31: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

31

Integrasikan p1(x) di dalam selang [0,1]:

I h

dxxf0

)( h

dxxp0

1 )(

h

f0

0( + x hf 0

) dx

xf0 + h

x2

2

f0 0

xhx

hf0 + 2h

f0

hf0 + 2h ( f1 - f0) , sebab f0 = f1-f0

2h f0 +

2h f1

2h ( f0 + f1)

Page 32: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

32

Jadi, kaidah trapesium adalah

h

dxxf0

)( 2h ( f0 + f1) sama seperti yang diturunkan

Dengan metode pias

Kaidah trapesium untuk integrasi dalam selang [0, h] kita perluas untuk menghitung

I = b

a

dxxf )(

b

a

dxxf )( 1

0

)(x

x

dxxf + 2

1

)(x

x

dxxf + ... +

n

n

x

x

dxxf1

)(

2h ( f0 + f1) +

2h ( f1+ f2) + ... +

2h ( fn-1 + fn)

2h ( f0 + 2f1 + 2f2 + ... + 2fn-1 + fn)

2h ( f0 + 2fi +

1

1

n

inf )

Page 33: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

33

Kaidah Simpson 1/3• Hampiran nilai integrasi yang lebih baik dapat ditingkatkan

dengan mengunakan polinom interpolasi berderajat yang lebih tinggi.

• Misalkan fungsi f(x) dihampiri dengan polinom interpolasi derajat 2 yang grafiknya berbentuk parabola.

• Luas daerah yang dihitung sebagai hampiran nilai integrasi adalah daerah di bawah parabola.

• Untuk itu, dibutuhkan 3 buah titik data, misalkan (0, f(0)), (h, f(h)), dan (2h, f(2h)).

Page 34: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

34

x

y = f(x )

x 0 = 0 x 1 = h x 2 = 2 h

y = p 2 (x )y

Polinom interpolasi Newton-Gregory derajat 2 yang melalui ketiga buah titik tersebut adalah

p2(x) = f(x0) + hx f(x0) +

2!2 hhxx 2f(x0) = f0 + x f0 +

2!2 hhxx 2f0

Page 35: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

35

Integrasikan p2(x) di dalam selang [0, 2h]:

I h

dxxf2

0

)( h

dxxp2

02 )(

h2

0

( f0 + hx f0 +

2!2 hhxx 2f0) dx

f0x + h2

1 x2 f0 + ( 2

3

6hx -

hx4

2

) 2f0 0 2

xhx

2hf0 + h

h2

4 2

f0 + (2

3

68

hh -

hh4

4 2

) 2f0

2hf0 + 2h f0 + ( 3

4h - h) 2f0

2hf0 + 2h f0 + 3h 2f0

Page 36: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

36

Mengingat

f0 = f1 - f0 dan

2f0 = f1 - f0 = ( f2 - f1) - ( f1 - f0) = f2 -2f1 + f0 maka, selanjutnya

I 2hf0 + 2h ( f1 - f0) + 3h ( f2 - 2f1 + f0)

2hf0 + 2hf1 - 2hf0 + 3h f2 - 3

2h f1 + 3h f0

3h f0 +

34h f1 +

3h f2

3h ( f0 + 4f1 + f2)

(Kaidah Simpson 1/3)

Page 37: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

37

• Kaidah Simpson 1/3 gabungan:

b

a

dxxf )( 2

0

)(x

x

dxxf + 4

2

)(x

x

dxxf + ... +

n

n

x

x

dxxf2

)(

3h ( f0 + 4f1 + f2) +

3h ( f2 + 4f3 + f4) + ... +

3h ( fn-2 + 4fn-1 + fn)

3h ( f0 + 4f1 + 2f2 + 4f3 + 2f4 + ... + 2fn-2 + 4fn-1 + fn)

3h ( f0 + 4

1

5,3,1

n

iif + 2

2

6,4,2

n

iif + fn )

Ingat pola koefisien dalam rumus Simpson 1/3:1, 4, 2, 4, 2, ... ,2, 4, 1

Page 38: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

38

• Penggunaan kaidah 1/3 Simpson mensyaratkan jumlah upaselang (n) harus genap.

• Ini berbeda dengan kaidah trapesium yang tidak mempunyai persyaratan mengenai jumlah selang.

Page 39: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

39

procedure Simpson_sepertiga(a, b : real; n: integer; var I : real);{ menghitung integrasi f(x) dalam selang [a, b] dengan jumlah pias sebanyak n (n harus genap} K.Awal : harga a, b, dan n sudah terdefinisi (n harus genap) K.Akhir: I adalah hampiran integrasi yang dihitung dengan kaidah Simpson 1/3}var h, x, sigma : real; r : integer; begin h:=(b-a)/n; {jarak antar titik } x:=a; {awal selang integrasi} I:=f(a) + f(b); sigma:=0; for r:=1 to n-1 do begin x:=x+h; if r mod 2 = 1 then { r = 1, 3, 5, ..., n-1 }

sigma:=sigma + 4*f(x) else { r = 2, 4, 6, ..., n-2 } sigma:=sigma + 2*f(x); end; I:=(I+sigma)*h/3; { nilai integrasi numerik}end;

Page 40: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

40

• Contoh: Hitung integral dengan menggunakana. kaidah trapesiumb. kaidah titik-tengahc. kaidah Simpson 1/3

Gunakan jarak antar titik h = 0.125.

1

01

1dx

x

Penyelesaian: Jumlah upaselang: n = (1 - 0)/0.125 = 8 Tabel titik-titik di dalam selang [0,1]: Tabel titik-titik di dalams elang [0, 1]: (untuk kaidah trapesium dan Simpson 1/3) (untuk kaidah titik-tengah)

r xr fr r xr fr 0 0 1 1/2 0.063 0.94118 1 0.125 0.88889 3/2 0.188 0.84211 2 0.250 0.80000 5/2 0.313 0.76190 3 0.375 0.72727 7/2 0.438 0.69565 4 0.500 0.66667 9/2 0.563 0.64000 5 0.625 0.61538 11/2 0.688 0.59259 6 0.750 0.57143 13/2 0.813 0.55172 7 0.875 0.53333 15/2 0.938 0.51613 8 1.000 0.50000

Page 41: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

41

(a) dengan kaidah trapesium

1

01

1 dxx

h/2 ( f0 + 2f1 + 2f2 + 2f3 + 2f4 + 2f5 + 2f6 + 2f7 + f8)

0.125/2 [1 + 2(0.88889) + 2(0.80000) + ... + 0.50000) 0.69412 (b) dengan kaidah titik-tengah

1

01

1 dxx

h ( f1/2 + f3/2 + f5/2 + f7/2 + f9/2 + f11/2 + f13/2 + f15/2 )

0.125 (5.54128) (c) dengan kaidah 1/3 Simpson

1

01

1 dxx

h/3 ( f0 + 4f1 + 2f2 + 4f3 + 2f4 + 4f5 + 2f6 + 4f7 + f8)

0.125/3 (16.63568) 0.69315 Bandingkan solusi (a), (b), dan (c) dengan solusi sejatinya:

1

01

1 dxx

= ln(1+x) 0 1

xx

= ln(2) - ln(1) = 0.69314718

Page 42: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

42

Galat Kaidah Simpson 1/3

Galat kaidah Simpson 1/3 untuk dua pasang upaselang adalah

E = h

dxxf2

0

)( - 3h ( f0 + 4f1 +f2) (P.6.29)

Uraikan f(x), f1, dan f2 masing-masing ke dalam deret Taylor di sekitar x0 = 0:

f(x) = f0 + xf0' + 2

2x f0" + 6

3x f0"' + 24

4x f0(iv) + ... (P.6.30)

f1 = f(h) = f0 + hf0' + 2

2h f0" + 6

3h f0"' + 24

4h f0(iv) + ... (P.6.31)

f2 = f(2h) = f0 + 2h f0' + 2

4 2h f0" + 6

8 3h f0"'+ 24

16 4h f0(iv) + ... (P.6.32)

Page 43: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

43

Sulihkan persamaan (P.6.30), (P.6.31), (P.6.32) ke dalam persamaan (P.6.29):

E = h2

0

( f0 + xf0' + 2

2x f0" + 6

3x f0"' + 24

4x f0(iv) + ...) dx

- 3h [ ( f0 + 4f0 + 4hf0' +

24 2h f0" +

64 3h f0"' +

244 4h f0

(iv) + ...)

+ (f0 + 2hf0' + 2

4 2h f0" + 6

8 3h f0"' + 24

16 4h f0(iv) + ...) ]

= (xf0 + 2

2x f0' + 6

3x f0" + 24

4x f0"' + 120

5x f0(iv) + ...)

0 2

xhx

- 3h (6f0 + 6hf0' + 4h2f0" + 2h3 f0"' +

2420 4h f0

(iv) + ...)

= (2hf0 + 2h2f0' + 3

4 3h f0" + 3

2 4h f0"' + 12032 5h f0

(iv) +...)

Page 44: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

44

- (2hf0 + 2h2f 0' + 3

4 3h f0" + 3

2 4h f0"' + 72

20 5h f0IV + ...)

= 12032 5h f0

(iv) - 72

20 5h f0(iv) + ...

= ( 308 -

1805 ) h5fo

(iv) + ...

= - 901 h5 f0

(iv) (P.6.33)

= O(h5)

Page 45: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

45

Jadi, kaidah Simpson 1/3 untuk sepasang upaselang ditambah dengan galatnya dapat dinyatakan sebagai

h

dxxf2

0

)( = 3h ( f0 + 4f1 + f2) + O(h5)

Galat untuk n/2 pasang upaselang adalah

Etot = - 901 h5( f0

(iv) + f2(iv) + f4

(iv) + ... + fn-2(iv)) = -

901 h5

2

,...2,0

n

i

fi (iv)

= -

90

5h . 2n . f (iv)(t) , a < t < b

= -

180

4h (b - a) f (iv)(t) , karena n = (b - a)/h (P.6.34)

= O(h4)

Page 46: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

46

Jadi, kaidah Simpson 1/3 gabungan ditambah dengan galatnya dapat dinyatakan sebagai,

b

a

dxxf )( 3h ( f0 + 4

1

5,3,1

n

iif + 2

2

6,4,2

n

iif + fn ) + O(h4)

dengan kata lain, kaidah Simpson 1/3 gabungan berorde 4

Dibandingkan dengan kaidah trapesium gabungan, hasil integrasi Dengan kaidah Simpson gabungan jauh lebih baik, karena orde galatnya lebih tinggi.

Tapi ada kelemahannya, yaitu kaidah Simpson 1/3 tidak dapat diterapkan bila jumlah upaselang (n) ganjil.

Page 47: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

47

Kaidah Simpson 3/8

• Fungsi f(x) kita hampiri dengan polinom interpolasi derajat 3.

• Luas daerah yang dihitung sebagai hampiran nilai integrasi adalah daerah di bawah kurva polinom derajat 3 tersebut.

• Untuk membentuk polinom interpolasi derajat 3, dibutuhkan 4 buah titik data, misalkan titik-titk tersebut (0, f(0)), (h, f(h)), (2h, f(2h)), dan (3h, f(3h)).

Page 48: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

48

x 0 = 0 x 1 = h x 2 = 2 h x 2 = 3 h

y

x

y = f(x )

y = p 3 (x )

Page 49: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

49

Polinom interpolasi Newton-Gregory derajat 3 yang melalui keempat buah titik itu adalah

p3(x) = f(x0) + hx f(x0) +

2!2 hhxx 2f(x0) +

3!32

hhxhxx 3f(x0)

= f0 + hx f0 +

2!2 hhxx

2f0 + 3!3

2h

hxhxx 3f(x0)

Integrasi p3(x) di dalam selang [0,3h] adalah

I h

dxxf3

0

)( h

dxxp3

03 )(

h3

0

[ f0 + hxf0 +

2!2 hhxx

2f0 + 3!3

2h

hxhxx 3f(x0) ] dx

Dengan cara penurunan yang sama seperti pada kaidah Simpson 1/3, diperoleh

h

dxxf3

0

)( 8

3h ( f0 + 3f1 + 3f2 + f3) Kaidah Simpson 3/8

Page 50: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

50

Galat kaidah Simpson 3/8 adalah

E - 803 h5 f0

(iv) (t) , 0 < t < 3h

Jadi, kaidah Simpson 3/8 ditambah dengan galatnya deapat dinyatakan sebagai

h

dxxf3

0

)( 8

3h ( f0 + 3f1 + 3f2 + f3) + O(h5)

Sedangkan kaidah Simpson 3/8 gabungan adalah

b

a

dxxf )( 83h ( f0 + 3f1 + 3f2 + 2f3 + 3f4 + 3f5 + 2f6 + 3f7 + 3f8 + 2f9 + ...

+ 2 fn-3 + 3 fn-2 + 3 fn-1 + fn)

8

3h ( f0 + 3

1

,...9,6,31

n

ii

if + 2

3

,...9,6,3

n

iif + fn)

Page 51: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

51

Galat kaidah 3/8 Simpson gabungan adalah

Etot

3/

1

n

i

803 5h f (iv)(t) -

803 5h

3

1

n

i

f (iv)(t)

- 80

3 5h . 3n . f (iv) (t)

- 80

5h h

ab f (iv)(t)

- 80

4hab f (iv)(t) , a < t < b

= O(h4)

Jadi, kaidah Simpson 3/8 ditambah dengan galatnya dapat dinyatakan sebagai

b

a

dxxf )( 8

3h ( f0 + 3

1

,...9,6,31

n

ii

if + 2

3

,...9,6,3

n

iif + fn) + O(h4)

Page 52: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

52

Metode Integrasi Numerik Untuk h yang Berbeda-beda

y = f(x )

x

y

x 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9

h 1 h 1 h 1 h 1

h 2 h 2 h 1

h 3h 4

1/3Simpson kaidah

3/8Simpson kaidah

trap

trap

Page 53: Integrasi Numerik (Bag. 1)

IF4058 Topik Khusus Informatika I: Metode Numerik/Teknik Informatika ITB

53

Bentuk Umum Metode Newton-Cotes

b

a

dxxf )( = h[w0 f0 + w1 f1+ w2 f 2+ ... + wn fN] + E

n wi , i = 1, 2, ..., n E Nama

1 1/2 1 1 -1/12 h3 f " Trapesium

2 1/3 1 4 1 -1/90 h5 f ( 4) 1/3 Simpson

3 3/8 1 3 3 1 -3/80 h5 f (4) 3/8 Simpson

4 2/45 7 32 12 32 7 -8/945 h7 f (6) Boole

5 5/288 19 75 50 50 75 19 -275/12096 h7 f (4)

6 1/140 41 216 27 272 27 216 41 -9/1400 h9 f (8)

7 7/17280 751 3577 1323 2989 2989 1323 3577 751

-8183/518400 h 9 f (8)

8 8/14175 989 5888 -928 10496 -4540 10496 -928 5888 989

-2368/467775 h 11 f (10)

9 9/89600 2857 15741 1080 19344 5788 5788 19344 1080 15741 2857

-173/14620 h11 f (10)

10 5/299376 16067 106300 -48525 272400 -260550 427368 -260550 272400 -48525 106300 16067

-1346350/326918592 h13 f (12)