integral numerik

34
Pengintegralan Pengintegralan Numerik Numerik

Upload: haniffudin-nurdiansah

Post on 20-Oct-2015

317 views

Category:

Documents


17 download

DESCRIPTION

Numerical Integral

TRANSCRIPT

Pengintegralan Pengintegralan NumerikNumerik

PengantarPengantar Pengintegralan numerik merupakan

alat atau cara yang digunakan oleh ilmuwan untuk memperoleh jawaban hampiran (aproksimasi) dari pengintegralan yang tidak dapat diselesaikan secara analitik.

Misalnya dalam termodinamik, model Debye untuk menghitung kapasitas panas dari benda padat.

Dasar Pengintegralan NumerikDasar Pengintegralan Numerik Penjumlahan berbobot dari nilai

fungsi

)(...)()(

)()(

1100

0

nn

i

n

ii

b

a

xfcxfcxfc

xfcdxxf

x0 x1 xnxn-1x

f(x)

0

2

4

6

8

10

12

3 5 7 9 11 13 15

Melakukan penginteralan pada bagian-bagian kecil, seperti saat awal belajar integral – penjumlahan bagian-bagian.

Metode Numerik hanya mencoba untuk lebih cepat dan lebih mendekati jawaban eksak.

Dasar Pengintegralan Dasar Pengintegralan NumerikNumerik

Formula Newton-Cotes

- Berdasarkan pada

dxxfdxxfIb

a n

b

a )()(

Nilai hampiran f(x) dengan polinomial

nn

1n1n10n xaxaxaaxf

)(

Dasar Pengintegralan Dasar Pengintegralan NumerikNumerik

fn (x) bisa fungsi linear fn (x) bisa fungsi kuadrat

fn (x) bisa juga fungsi kubik atau polinomial yang lebih tinggi

Polinomial dapat didasarkan pada data

Formula Newton-Cotes Aturan Trapesium : LinierAturan Simpson’s 1/3 : KuadratAturan Simpson’s 3/8 : KubikAturan Boole : Orde Empat

Aturan TrapesiumAturan Trapesium Aproksimasi garis lurus (linier)

)()(

)()()()(

10

1100i

1

0ii

b

a

xfxf2

h

xfcxfcxfcdxxf

x0 x1x

f(x)

L(x)

Contoh: Aturan TrapesiumContoh: Aturan Trapesium Hitung integral dari Solusi eksak

Aturan trapesium

926477.5216)12(4

1

4

1

24

0

2

4

0

224

0

2

xe

eex

dxxe

x

xxx

dxxe4

0

x2

%..

..

.)()()(

123579265216

66238479265216

6623847e4024f0f2

04dxxeI 84

0

x2

Aturan Komposisi Aturan Komposisi TrapesiumTrapesium

)()()()()(

)()()()()()(

)()()()(

n1ni10

n1n2110

x

x

x

x

x

x

b

a

xfxf2x2fxf2xf2

h

xfxf2

hxfxf

2

hxfxf

2

h

dxxfdxxfdxxfdxxfn

1n

2

1

1

0

x0 x1x

f(x)

x2h h x3h h x4

n

abh

function f = example1(x)% a = 0, b = pif=x.^2.*sin(2*x);

dxx2sinx0

2 )(

Aturan Komposisi Aturan Komposisi TrapesiumTrapesium

» a=0; b=pi; dx=(b-a)/100;» x=a:dx:b; y=example1(x);» I=trap('example1',a,b,1)I = -3.7970e-015» I=trap('example1',a,b,2)I = -1.4239e-015» I=trap('example1',a,b,4)I = -3.8758» I=trap('example1',a,b,8)I = -4.6785» I=trap('example1',a,b,16)I = -4.8712» I=trap('example1',a,b,32)I = -4.9189

» I=trap('example1',a,b,64)I = -4.9308» I=trap('example1',a,b,128)I = -4.9338» I=trap('example1',a,b,256)I = -4.9346» I=trap('example1',a,b,512)I = -4.9347» I=trap('example1',a,b,1024)I = -4.9348» Q=quad8('example1',a,b)Q = -4.9348 MATLAB

function

Aturan Komposisi Aturan Komposisi TrapesiumTrapesium

n = 2

I = -1.4239 e-15

Exact = -4. 9348

dxx2sinx0

2 )(

n = 4

I = -3.8758

Eksak = -4. 9348

dxx2sinx0

2 )(

n = 8

I = -4.6785

Eksak = -4. 9348

dxx2sinx0

2 )(

n = 16

I = -4.8712

Eksak = -4. 9348

dxx2sinx0

2 )(

Hitung integral dari dxxeI4

0

x2

%..)().().(

).().()(.,

%..)().(

)().()().(

)().()(.,

%..)()(

)()()(,

%..)()()(,

%..)()(,

662 9553554f753f253f2

50f2250f20f2

hI250h16n

5010 7657644f53f2

3f252f22f251f2

1f250f20f2

hI50h8n

7139 7972884f3f2

2f21f20f2

hI1h4n

75132 23121424f2f20f2

hI2h2n

12357 66238474f0f2

hI4h1n

Aturan Komposisi Aturan Komposisi TrapesiumTrapesium

» x=0:0.04:4; y=example2(x);» x1=0:4:4; y1=example2(x1);» x2=0:2:4; y2=example2(x2);» x3=0:1:4; y3=example2(x3);» x4=0:0.5:4; y4=example2(x4);» H=plot(x,y,x1,y1,'g-*',x2,y2,'r-s',x3,y3,'c-o',x4,y4,'m-d');» set(H,'LineWidth',3,'MarkerSize',12);» xlabel('x'); ylabel('y'); title('f(x) = x exp(2x)');

» I=trap('example2',0,4,1)I = 2.3848e+004» I=trap('example2',0,4,2)I = 1.2142e+004» I=trap('example2',0,4,4)I = 7.2888e+003» I=trap('example2',0,4,8)I = 5.7648e+003» I=trap('example2',0,4,16)I = 5.3559e+003

Aturan Komposisi Aturan Komposisi TrapesiumTrapesium

dxxeI4

0

x2

Aturan Komposisi Aturan Komposisi TrapesiumTrapesium

Aturan Simpson 1/3Aturan Simpson 1/3 Aproksimasi dengan fungsi

parabola

)()()(

)()()()()(

210

221100i

2

0ii

b

a

xfxf4xf3

h

xfcxfcxfcxfcdxxf

x0 x1x

f(x)

x2h h

L(x)

1 xx

0 xx

1 xx

h

dxd

h

xx

2

abh

2

ba x bx ax let

xfxxxx

xxxx

xfxxxx

xxxx xf

xxxx

xxxxxL

2

1

0

1

120

21202

10

12101

200

2010

21

,,

,,

)())((

))((

)())((

))(()(

))((

))(()(

)()(

)()()()(

)( 212

0 xf2

1xf1xf

2

1L

Aturan Simpson 1/3Aturan Simpson 1/3

)()(

)()()()(

)( 212

0 xf2

1xf1xf

2

1L

1

1

23

2

1

1

3

1

1

1

23

0

1

12

1

0

21

1

10

1

1

)23

(2

)(

)3

()()23

(2

)(

)1(2

)()1)(

)1(2

)()()(

ξξhxf

ξξhxf

ξξhxf

dξξξh

xfdξξ(hxf

dξξξh

xfdξLhdxxfb

a

)()()()( 210

b

axfxf4xf

3

hdxxf

Aturan Simpson 1/3Aturan Simpson 1/3

Aturan Komposisi Aturan Komposisi SimpsonSimpson

x0 x2x

f(x)

x4h h xn-2h xn

n

abh

…...

hx3x1 xn-1

Hitung integral dari n = 2, h = 2

n = 4, h = 1

dxxeI4

0

x2

%..

)()()(

)()()()()(

708 9755670

e4e34e22e403

1

4f3f42f21f40f3

hI

8642

%..)(

)()()(

9657 4118240e4e2403

2

4f2f40f3

hI

84

Aturan Komposisi Aturan Komposisi SimpsonSimpson

Aturan Simpson 3/8Aturan Simpson 3/8 Aproksimasi dengan fungsi kubik

)()()()(

)()()()()()(

3210

33221100i

3

0ii

b

a

xfxf3xf3xf8

h3

xfcxfcxfcxfcxfcdxxf

x0 x1x

f(x)

x2h h

L(x)

x3h

)())()((

))()(()(

))()((

))()((

)())()((

))()(()(

))()((

))()(()(

3231303

2102

321202

310

1312101

3200

302010

321

xfxxxxxx

xxxxxxxf

xxxxxx

xxxxxx

xfxxxxxx

xxxxxxxf

xxxxxx

xxxxxxxL

)()()()( 3210

b

a

b

a

xfxf3xf3xf8

h33

abh ;L(x)dxf(x)dx

Error Pemenggalan

3

abh ;f

6480

abfh

80

3E 4

545

t

)(

)()( )()(

Aturan Simpson 3/8Aturan Simpson 3/8

Hitung integral dari Aturan Simpson 1/3

Aturan Simpson 3/8

dxxe4

0

x2

%..

..

.)(

)()()(

96579265216

41182409265216

4118240e4e2403

2

4f2f40f3

hdxxeI

84

4

0

x2

%71.30926.5216

209.6819926.5216

209.6819832.11923)33933.552(3)18922.19(308

)4/3(3

)4(f)3

8(f3)

3

4(f3)0(f

8

h3dxxeI

4

0

x2

Aturan Simpson 3/8Aturan Simpson 3/8

function I = Simp(f, a, b, n)% integral of f using composite Simpson rule% n must be evenh = (b - a)/n;S = feval(f,a);for i = 1 : 2 : n-1 x(i) = a + h*i; S = S + 4*feval(f, x(i));endfor i = 2 : 2 : n-2 x(i) = a + h*i; S = S + 2*feval(f, x(i));endS = S + feval(f, b); I = h*S/3;

Aturan Komposisi Aturan Komposisi SimpsonSimpson

Aturan SimpsonAturan Simpson

Aturan Komposisi Aturan Komposisi SimpsonSimpson

MATLAB FunctionMATLAB Function:: trapztrapz

» x=[0 1 1.5 2.0 2.5 3.0 3.3 3.6 3.8 3.9 4.0]

x =

Columns 1 through 7

0 1.0000 1.5000 2.0000 2.5000 3.0000 3.3000

Columns 8 through 11

3.6000 3.8000 3.9000 4.0000

» y=x.*exp(2.*x)

y =

1.0e+004 *

Columns 1 through 7

0 0.0007 0.0030 0.0109 0.0371 0.1210 0.2426

Columns 8 through 11

0.4822 0.7593 0.9518 1.1924

» integr = trapz(x,y)

integr =

5.3651e+003

Z = trapz(x,y)

Sumber:Sumber: http://ceprofs.tamu.edu/hchen/cven302/

chap16.ppt