16
Nama : SATRIA ADI PRASETYA NIM : A410090156 Kelas : VD TUGAS METODE NUMERIK (LANJUTAN) 1. Tentukan rumus pendekatan turunan kedua beserta order kesalahannya dengan metode: a. Forward Difference order-2, O(h^2) b. Backward Difference order-2, O(h^2) c. Central Difference order-4, O(h^4) Penyelesaian: a. Forward Difference order-2, O(h^2) f ( x 0 +h) =f ( x 0 ) +hf I ( x 0 ) + h 2 f II ( x 0 ) 2 ! + h 3 f III ( x 0 ) 3 ! + h 4 f IV ( x 0) 4 ! +x8 f ( x 0 +2 h) =f ( x 0 ) +2 hf I ( x 0) + 4 h 2 f II ( x 0 ) 2 ! + 8 h 3 f III ( x 0) 3 ! + 16 h 4 f IV ( x 0 ) 4 ! + 8 f ( x 0 +h) =8 f ( x 0 ) +8 hf I ( x 0 ) +8 h 2 f II ( x 0 ) 2 ! + 8 h 3 f III ( x 0) 3 ! + 8 h 4 f IV ( x 0) 4 ! +f ( x 0 +2 h) =f ( x 0 ) +2 hf I ( x 0) + 4 h 2 f II ( x 0 ) 2 ! + 8 h 3 f III ( x 0) 3 ! + 16 h 4 f IV ( x 0 ) 4 ! + 8 f ( x 0 + h) f ( x 0 +2 h )=7 f ( x 0) + 6 hf I ( x 0 ) + 4 h 2 f II ( x 0 ) 2 ! 8 h 4 f IV ( x 0) 4 ! +

Metode Numeric Matematika

Embed Size (px)

DESCRIPTION

Metode Numeric

Citation preview

Page 1: Metode Numeric Matematika

Nama : SATRIA ADI PRASETYA

NIM : A410090156

Kelas : VD

TUGAS METODE NUMERIK (LANJUTAN)

1. Tentukan rumus pendekatan turunan kedua beserta order kesalahannya dengan metode:

a. Forward Difference order-2, O(h^2)

b. Backward Difference order-2, O(h^2)

c. Central Difference order-4, O(h^4)

Penyelesaian:

a. Forward Difference order-2, O(h^2)

f ( x 0+h )=f ( x 0 )+h f I ( x0 )+ h2 f II ( x0 )2!

+h3 f III ( x0 )

3 !+

h4 f IV (x 0)4 !

+… x8

f ( x 0+2h )=f ( x0 )+2hf I ( x0 )+ 4 h2 f II ( x0 )2 !

+8 h3 f III ( x0 )

3 !+

16 h4 f IV ( x 0 )4 !

+…

8 f ( x 0+h )=8 f ( x 0 )+8 hf I ( x 0 )+8h2 f II (x 0 )

2 !+8

h3 f III (x 0 )3!

+8h4 f IV ( x 0 )

4 !+…

f ( x 0+2h )=f ( x0 )+2hf I ( x0 )+ 4 h2 f II ( x0 )2 !

+8 h3 f III ( x0 )

3 !+

16 h4 f IV ( x 0 )4 !

+…

8 f ( x 0+h )−f ( x 0+2 h )=7 f (x 0 )+6 hf I ( x0 )+ 4 h2 f II ( x0 )2 !

−8 h4 f IV ( x0 )

4 !+…

4 h2 f II ( x 0 )2!

=8 f ( x 0+h )−7 f ( x0 )−f ( x 0+2 h )−6hf I ( x 0 )+ 8 h4 f IV ( x 0 )4 !

+…

2 h2 f II ( x0 )=8 f ( x 0+h )−7 f ( x0 )−f ( x 0+2h )−6 hf I ( x0 )+ 8 h4 f IV ( x0 )4 !

+…

Page 2: Metode Numeric Matematika

f II ( x 0 )=8 f ( x 0+h )−7 f ( x0 )−f ( x 0+2 h )−6hf I ( x 0 )2h2 +

h2 f IV ( x0 )6

+…

ϑ (h2)=h2 f IV ( x0 )6

b. Backward Difference order-2, O(h^2)

f ( x 0−h )=f (x 0 )−hf I ( x 0 )+ h2 f II (x0)2!

−h3 f III(x 0)

3!+

h4 f IV (x 0)4 !

+… x8

f ( x 0−2h )=f ( x 0 )−2hf I (x 0 )+ 4 h2 f II (x0)2 !

−8 h3 f III(x 0)

3!+

16 h4 f IV (x 0)4 !

+…

f ( x 0−2h )=f ( x 0 )−2 hf I (x 0 )+ 4 h2 f II (x0)2 !

−8 h3 f III(x 0)

3!+

16 h4 f I ( x0)4 !

+…

8 f ( x 0−h )=8 f (x 0 )−8hf I ( x 0 )+8h2 f II (x0)

2!−8

h3 f III(x 0)3 !

+8h4 f IV (x0)

4 !+…

f ( x 0−2h )−8 f ( x 0−h )=−7 f (x 0 )+6hf I ( x0 )−4h2 f II ( x0 )

2!+8

h4 f IV (x 0 )4 !

+…

4h2 f II ( x 0 )

2 !=8 f ( x 0−h )−7 f ( x 0 )−f ( x0−2h )+6hf I (x 0 )+8

h4 f IV ( x 0 )4 !

+…

2 h2 f II ( x0 )=8 f ( x 0−h )−7 f ( x 0 )−f ( x0−2h )+6 hf I ( x 0 )+8h4 f IV ( x 0 )

4 !+…

f II ( x 0 )=8 f ( x 0−h )−7 f ( x 0 )−f ( x0−2 h )+6 hf I ( x 0 )2 h2 +

h2 f IV ( x 0 )6

+…

ϑ (h¿¿2)=h2 f IV (x 0 )

6¿

c. Central Difference order-4, O(h^4)

f ( x 0+h )=f ( x 0 )+hf I ( x 0 )+ h2 f II(x 0)2 !

+h3 f III(x 0)

3 !+

h4 f IV (x0)4 !

+h5 f V (x 0)

5 !+

h6 f VI( x0)6 !

+…

f ( x 0−h )=f (x 0 )−hf I ( x 0 )+ h2 f II (x0)2!

−h3 f III(x 0)

3!+

h4 f IV (x 0)4 !

−h5 f V (x0)

5 !+

h6 f VI (x 0)6 !

+…

Page 3: Metode Numeric Matematika

f ( x 0+h )+ f ( x0−h )=2 f ( x0 )+2h2 f II (x 0)

2 !+2

h4 f IV (x 0)4 !

+2h6 f VI (x 0)

6 !+…

f ( x 0+2 h )=f ( x0 )+2hf I ( x0 )+ 4 h2 f II (x 0)2!

+8 h3 f III(x 0)

3 !+

16 h4 f IV (x0)4 !

+32 h5 f V (x0)

5 !+…

f ( x 0−2h )=f ( x 0 )−2 hf I (x 0 )+ 4 h2 f II (x0)2 !

−8 h3 f III(x 0)

3!+

16 h4 f IV (x 0)4 !

−32 h5 f V (x 0)

5!+…

f ( x 0+2h )+ f (x 0−2h )=2 f ( x0 )+8h2 f II ( x 0 )

2 !+32

h4 f IV ( x 0 )4 !

+128h6 f VI ( x 0 )

6 !+…

f ( x 0+h )+ f ( x0−h )=2 f ( x0 )+2h2 f II(x 0)

2 !+2

h4 f IV (x 0)4 !

+2h6 f VI (x 0)

6 !+… x16

f ( x 0+2h )+ f (x 0−2h )=2 f ( x0 )+8h2 f II ( x 0 )

2 !+32

h4 f IV ( x 0 )4 !

+128h6 f VI ( x 0 )

6 !+…

16 f ( x 0+h )+16 f ( x0−h )=32 f (x 0 )+32h2 f II (x0)

2!+32

h4 f IV (x 0)4 !

+32h6 f VI (x0)

6!+…

f ( x 0+2h )+ f (x 0−2h )−16 f ( x 0+h )−16 f ( x 0−h )=−30 f ( x 0 )−24h2 f II(x 0)

2 !+96

h6 f VI (x0)6!

+…

24h2 f II(x 0)

2 !=−f ( x 0+2h )−30 f ( x 0 )−f ( x0−2h )+96

h6 f VI (x 0)6 !

+…

12 h2 f II (x 0 )=−f ( x 0+2 h )−30 f ( x 0 )−f ( x0−2 h )+96h6 f V I (x 0)

6!+…

f II ( x 0 )=−f ( x 0+2 h )−30 f (x 0 )−f ( x0−2 h )12 h2 +

h4 f VI (x 0)90

+…

ϑ (h4 )=h4 f VI (x 0)90

Page 4: Metode Numeric Matematika

2. Tentukan rumus pendekatan turunan ketiga beserta order kesalahannya dengan

metode Forward Difference, Backward Difference, dan Central Difference (Petunjuk:

ingat p>=n+1)

Penyelesaian:

a. Turunan 3 Forward Difference dengan titik x0, x0+h, x0+2h

f ( x 0+h )=f ( x 0 )+hf I ( x 0 )+ h2 f II(x 0)2 !

+h3 f III(x 0)

3 !+

h4 f IV (x0)4 !

+…

f ( x 0+2h )=f ( x0 )+2hf I ( x0 )+ 4 h2 f II(x 0)2!

+8h3 f III(x 0)

3 !+

16 h4 f IV (x0)4 !

+…

4 f ( x 0+h )=4 f (x 0 )+4 hf I ( x 0 )+4h2 f II (x0)

2!+4

h3 f III(x 0)3 !

+4h4 f IV (x0)

4 !+…

-

f ( x 0+2 h )−4 f (x 0+h )=−3 f ( x 0 )−2 hf I (x 0 )+ 4 h3 f III(x 0)3 !

+12h4 f IV (x 0)

4 !+…

4 h3 f III (x0)3 !

= f (x 0+2 h )+3 f (x 0 )−4 f (x 0+h )+2hf I ( x0 )−12 h4 f IV (x 0)4 !

+…

2h3 f III (x 0)3

=f (x 0+2 h )+3 f (x 0 )−4 f (x 0+h )+2 hf I ( x0 )−12 h4 f IV (x 0)4 !

+…

f III ( x 0 )=3 f ( x 0+2 h )+9 f ( x 0 )−12 f ( x 0+h )+6 hf I ( x0 )2 h3 −3

h f IV (x0)4 !

+…

ϑ (h )=−3 h f IV (x 0)4

b. Turunan 3 Backward Difference dengan titik x0-2h, x0-h, x0

Page 5: Metode Numeric Matematika

f ( x 0−h )=f (x 0 )−hf I ( x 0 )+ h2 f II (x0)2!

−h3 f III(x 0)

3!+

h4 f IV (x 0)4 !

+…

f ( x 0−2h )=f ( x 0 )−2 hf I (x 0 )+ 4 h2 f II (x0)2 !

−8 h3 f III(x 0)

3!+

16 h4 f IV (x 0)4 !

+…

4 f ( x 0−h )=4 f ( x0 )−4 hf I ( x 0 )+4h2 f II (x 0)

2 !−4

h3 f III (x0)3 !

+4h4 f IV (x 0)

4 !+…

f ( x 0−2h )−4 f ( x0−h )=−3 f ( x0 )+2 hf I ( x0 )−4h3 f III (x0)

3 !+12

h4 f IV (x 0)4 !

+…

4h3 f III (x0)

3 !=4 f ( x 0−h )−3 f ( x 0 )−f ( x0−2h )+12

h4 f IV (x 0)4 !

+…

2h3 f III (x 0)3

=4 f ( x 0−h )−3 f ( x 0 )−f ( x0−2 h )+12h4 f IV (x 0)

4 !+…

2 h3 f III ( x0 )=12 f ( x0−h )−9 f ( x 0 )−3 f ( x 0−2 h )+36h4 f IV (x 0)

4 !+…

f III ( x 0 )=12 f ( x0−h )−9 f ( x 0 )−3 f ( x 0−2 h )2h3 +

3 h f IV (x 0)4

+…

ϑh=3 h f IV (x0)

4

c. Turunan 3 Central Differance dengan titik x0-h,x0,x0+h

f ( x 0+h )=f ( x 0 )+hf I ( x 0 )+ h2 f II(x 0)2 !

+h3 f III(x 0)

3 !+

h4 f IV (x0)4 !

+h5 f V (x 0)

5 !+…

f ( x 0−h )=f (x 0 )−hf I ( x 0 )+ h2 f II (x0)2!

−h3 f III(x 0)

3!+

h4 f IV (x 0)4 !

−h5 f V (x0)

5 !+…

f ( x 0+h )−f ( x 0−h )=2 hf I ( x 0 )+2h3 f III (x0)

3 !+2

h5 f V (x 0)5 !

+…

Page 6: Metode Numeric Matematika

2h3 f III (x 0)

3 !=f (x 0+h )−2 hf I ( x 0 )−f ( x0−h )−2

h5 f V (x0)5 !

+…

h3 f III(x 0)3 !

= f ( x0+h )−2 hf I (x 0 )−f ( x0−h )−2h5 f V (x 0)

5 !+…

h3 f III ( x 0 )=3 f (x 0+h )−6 hf I (x 0 )−3 f ( x0−h )−6h5 f V (x 0)

5 !+…

f III ( x 0 )=3 f ( x 0+h )−6 hf I ( x 0 )−3 f ( x 0−h )h3 −6

h5 f V (x 0)5 !

+…

f III ( x 0 )=3 f ( x 0+h )−6 hf I ( x 0 )−3 f ( x 0−h )h3 −

h2 f V (x 0)20

+…

ϑ (h2)=−h2 f V ( x0)20

Tugas Komputasi/Praktikum:

Tentukan nilai pendekatan turunan kedua dan ketiga untuk fungsi f(x)=exp(x)-x^3+1

pada xo=1 dengan h=0.1, 0.05, dan 0.025 dengan rumus yang diperoleh pada soal no.

1 dan 2. Selanjutnya lakukan perbandingan error dengan menggunakan order

kesalahan untuk menghitung errornya.

Penyelesaian:

Untuk soal no 1

>> syms x;

>> f=exp(x)-x^3+1;

>> x0=1;

>> h1=0.1;

>> h2=0.05;

>> h3=0.025;

>> f1=diff(f);

>> f2=diff(f1);

Page 7: Metode Numeric Matematika

>> f3=diff(f2);

>> f4=diff(f3);

>> f5=diff(f4);

>> f6=diff(f5);

>> a1=x0+h1;

>> a2=x0+h2;

>> a3=x0+h3;

>> b1=x0+2*h1;

>> b2=x0+2*h2;

>> b3=x0+2*h3;

>> c1=x0-h1;

>> c2=x0-h2;

>> c3=x0-h3;

>> d1=x0-2*h1;

>> d2=x0-2*h2;

>> d3=x0-2*h3;

>> fx0=subs(f,x0);

>> f1x0=subs(f1,x0);

>> f4x0=subs(f4,x0);

>> f6x0=subs(f6,x0);

>> fa1=subs(f,a1);

>> fa2=subs(f,a2);

>> fa3=subs(f,a3);

>> fb1=subs(f,b1);

>> fb2=subs(f,b2);

Page 8: Metode Numeric Matematika

>> fb3=subs(f,b3);

>> fc1=subs(f,c1);

>> fc2=subs(f,c2);

>> fc3=subs(f,c3);

>> fd1=subs(f,d1);

>> fd2=subs(f,d2);

>> fd3=subs(f,d3);

>> %forward difference

>> ffd1=(8*fa1-7*fx0-fb1-6*h1*f1x0)/2*h1.^2 %untuk h1

ffd1 =

-3.2865e-004

>> ffd2=(8*fa2-7*fx0-fb2-6*h2*f1x0)/2*h2.^2 %untuk h2

ffd2 =

-2.0518e-005

>> ffd3=(8*fa3-7*fx0-fb3-6*h3*f1x0)/2*h3.^2 %untuk h3

ffd3 =

-1.2820e-006

>> %backward difference

>> fbd1=(8*fc1-7*fx0-fd1+6*h1*f1x0)/2*h1.^2 %untuk h1

fbd1 =

-3.2860e-004

>> fbd2=(8*fc2-7*fx0-fd2+6*h2*f1x0)/2*h2.^2 %untuk h2

fbd2 =

-2.0518e-005

>> fbd3=(8*fc3-7*fx0-fd3+6*h3*f1x0)/2*h3.^2 %untuk h3

Page 9: Metode Numeric Matematika

fbd3 =

-1.2820e-006

>> %central difference

>> fcd1=(-fb1-30*fx0-fd1)/12*h1.^2 %untuk h1

fcd1 =

-0.0724

>> fcd2=(-fb2-30*fx0-fd2)/12*h2.^2 %untuk h2

fcd2 =

-0.0181

>> fcd3=(-fb3-30*fx0-fd3)/12*h3.^2 %untuk h3

fcd3 =

-0.0045

>> %forward error dengan order kesalahan

>> O1=(h1.^2*f4x0)/6 %untuk h1

O1 =

0.0045

>> O2=(h2.^2*f4x0)/6 %untuk h2

O2 =

0.0011

>> O3=(h3.^2*f4x0)/6 %untuk h3

O3 =

2.8315e-004

>> %backward error dengan order kesalahan

>> O1=(h1.^2*f4x0)/6 %untuk h1

O1 =

Page 10: Metode Numeric Matematika

0.0045

O2=(h2.^2*f4x0)/6 %untuk h2

O2 =

0.0011

O3=(h3.^2*f4x0)/6 %untuk h3

O3 =

2.8315e-004

>> %central error dengan order kesalahan

>> O1=(h1.^4*f6x0)/90 %untuk h1

O1 =

3.0203e-006

>> O2=(h2.^4*f6x0)/90 %untuk h2

O2 =

1.8877e-007

>> O3=(h3.^4*f6x0)/90 %untuk h3

O3 =

1.1798e-008

Untuk yang no 2

>> syms x;

>> f=exp(x)-x.^3+1;

>> x0=1;

>> h1=0.1;

>> h2=0.05;

Page 11: Metode Numeric Matematika

>> h3=0.025;

>> f1=diff(f);

>> f2=diff(f1);

>> f3=diff(f2);

>> f4=diff(f3);

>> f5=diff(f4);

>> a1=x0+h1;

>> a2=x0+h2;

>> a3=x0+h3;

>> b1=x0-h1;

>> b2=x0-h2;

>> b3=x0-h3;

>> c1=x0+2*h1;

>> c2=x0+2*h2;

>> c3=x0+2*h3;

>> d1=x0-2*h1;

>> d2=x0-2*h2;

>> d3=x0-2*h3;

>> fx0=subs(f,x0);

>> fa1=subs(f,a1);

>> fa2=subs(f,a2);

>> fa3=subs(f,a3);

>> fb1=subs(f,b1);

>> fb2=subs(f,b2);

>> fb3=subs(f,b3);

Page 12: Metode Numeric Matematika

>> fc1=subs(f,c1);

>> fc2=subs(f,c2);

>> fc3=subs(f,c3);

>> fd1=subs(f,d1);

>> fd2=subs(f,d2);

>> fd3=subs(f,d3);

>> f1x0=subs(f1,x0);

>> f4x0=subs(f4,x0);

>> f5x0=subs(f5,x0);

>> %untuk forward

>> ffd1=(3*fc1+9*fx0-12*fa1+6*h1*f1x0)/2*h1.^3 %untuk h1

ffd1 =

-3.0680e-006

>> ffd2=(3*fc2+9*fx0-12*fa2+6*h2*f1x0)/2*h2.^3 %untuk h2

ffd2 =

-4.9646e-008

>> ffd3=(3*fc3+9*fx0-12*fa3+6*h3*f1x0)/2*h3.^3 %untuk h3

ffd3 =

-7.8861e-010

>> %untuk backward

>> fbd1=(12*fb1-9*fx0-3*fd1)/2*h1.^3 %untuk h1

fbd1 =

8.1039e-005

>> fbd2=(12*fb2-9*fx0-3*fd2)/2*h2.^3 %untuk h2

fbd2 =

Page 13: Metode Numeric Matematika

5.2294e-006

>> fbd3=(12*fb3-9*fx0-3*fd3)/2*h3.^3 %untuk h3

fbd3 =

3.2932e-007

>> % untuk central

>> fcd1=(3*fa1-6*h1*f1x0-3*fb1)/h1.^3 %untuk h1

fcd1 =

-3.2804

>> fcd2=(3*fa2-6*h2*f1x0-3*fb2)/h2.^3 %untuk h2

fcd2 =

-3.2814

>> fcd3=(3*fa3-6*h3*f1x0-3*fb3)/h3.^3 %untuk h3

fcd3 =

-3.2816

>> % forward error dengan order kesalahan

>> O1=-(3*h1*f4x0)/4 %untuk h1

O1 =

-0.2039

>> O2=-(3*h2*f4x0)/4 %untuk h2

O2 =

-0.1019

>> O3=-(3*h3*f4x0)/4 %untuk h3

O3 =

-0.0510

Page 14: Metode Numeric Matematika

>> %backward error dengan order kesalahan

>> O1=(3*h1*f4x0)/4 %untuk h1

O1 =

0.2039

>> O2=(3*h2*f4x0)/4 %untuk h2

O2 =

0.1019

>> O3=(3*h3*f4x0)/4 %untuk h3

O3 =

0.0510

>> %central error dengan order kesalahan

>> O1=-(h1.^2*f5x0)/20 %untuk h1

O1 =

-0.0014

>> O2=-(h2.^2*f5x0)/20 %untuk h2

O2 =

-3.3979e-004

>> O3=-(h3.^2*f5x0)/20 %untuk h3

O3 =

-8.4946e-005