Transcript Pertemuan_5
Mata Praktikum: Metode Numerik & FORTRAN Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Pertemuan 5 Metode Sekan … … 2008 Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Daftar Isi I. II. III. IV. V. VI. VII. I Pendahuluan Metode Sekan Algoritma Sekan Contoh Soal Contoh Program Laporan Akhir Laporan Pendahuluan Pertemuan 6 II V VI III IV Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. VII Daftar Isi I PENDAHULUAN Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I II III IV V VI VII PENDAHULUAN Dalam komputasi terkadang sering dihadapkan dengan permasalahan yang berkaiatan dengan analisa terhadap numeril. Salah satunya mencari nilai akar sautu persamaan. Dan untuk mencari akar dari suatu persamaan nonlinier dapat digunakan beberapa metode. Secara metode numerik, dapat digunakan 2 cara : 1.Tanpa menggunakan derivatif (turunan) - Metode Biseksi - Metode Regulafalsi - Metode Sekan - Metode Iterasi titik tetap 2.Menggunakan derivatif (turunan) - Metode Newton-Raphson Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Daftar Isi II METODE SEKAN Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I II METODE SEKAN • • III Metoda Sekan disebut juga metoda interpolasi linier. Dalam prosesnya tidak dilakukan penjepitan akar sehingga [x0,x1] tidak harus mengandung akar, serta f(x0) dan f(x1) bisa bertanda sama. f(x) IV 0 V x0 x1 x2 x VI VII Daftar Isi • Tarik garis lurus melalui (x0, f(x0)) dan (x1, f(x1)) dan memotong sumbu x di (x2,0) x 2 x1 x 1 x 0 * f x f x 1 f x 0 Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I II METODE SEKAN • III IV V • Iterasi berikutnya dengan pergeseran : x0 x1 x1 x2 Iterasi berlangsung sampai batas maksimum iterasi atau sampai x1 x 2 T x1 VI VII Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Daftar Isi III ALGORITMA SEKAN Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I Algoritma Sekan II a) Tentukan x0, x1, T, iterasi maksimum dan F(x) III IV b) Hitung x2 = x1 – f(x1) (x1 - x0) / [f(x1) – f(x0)] c) Jika nilai |(x1-x2) / x1| < T, tulis x2 sebagai akar dan akhiri program. Jika tidak, lanjutkan ke langkah berikutnya. V d) Jika jumlah iterasi > iterasi maksimum, akhiri program. VI e) x0 = x1 VII f) x1 = x2 Daftar Isi g) Kembali ke b Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Daftar Isi IV CONTOH SOAL Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. 1/4 I Contoh Soal II III IV 1. Cari akar dari f(x) = x3 – 2x – 5, dimana : - x0 = 1 - x1 = 2 - Toleransi (T) = 0,001 atau 10-3 Jawab : Iterasi 1 : V VI VII Daftar Isi f x x x 0 1 x x 2 1 f x f x 1 0 2,2 2 f 22 1 2 -11 -1 - 6 f 2 f 1 f 2,2 1,248 2 2,2 0,1 2 Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. 2/4 I Contoh Soal II III IV V Iterasi 2 : x 2 f(2) -1 0 x 2,2 f(2,2) 1,248 1 x 2,2 1,2482,2 2 2,089 2 1,248 -1 f 2,089 0,062 2,2 2,089 0,051 2,2 VI VII Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. 3/4 I Contoh Soal II III IV V Iterasi 3 : x 2,2 f(2,2) 1,248 0 x 2,089 f(2,089) -0,062 1 - 0,0622,089 2,2 2,094 x 2,089 2 - 0,062 1,248 f 2,094 -0,006 2,089 2,094 0,002 2,089 VI VII Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. 4/4 I Contoh Soal II III IV V Iterasi 4 : x 2,089 f(2,089) -0,062 0 x 2,094 f(2,094) -0,006 1 - 0,0062,094 2,089 2,095 x 2,094 2 - 0,006 - 0,062 f 2,095 0,005 2,094 2,095 0,0005 2,094 VI VII Karena Tolerasi (T) yang didapat = 0,0005 < 10-3 Jadi, akarnya adalah = 2,095 Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I Representasi dalam bentuk tabel II Iterasi x0 x1 x2 |(x1-x2) / x1| 1 1 2 2,2 0,1 2 2 2,2 2,089 0,051 V 3 2,2 2,089 2,094 0,002 VI 4 2,089 2,094 2,095 0,0005 III IV VII Karena Tolerasi (T) yang didapat = 0,0005 < 10-3 Jadi, akarnya adalah = 2,095 Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Daftar Isi V CONTOH PROGRAM Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II III IV V VI VII $ title: Sekan c Contoh program Sekan REAL X0,X1,X2,T INTEGER ORDO, ITER DIMENSION KOEF(20) WRITE (*,’(24(/))’) WRITE (*,’(30X,A)’) ‘Input Persamaan’ WRITE (*,’(30X,A)’) ‘===============’ WRITE (*,*) WRITE (*,’(a,\)’) ‘Orde/Derajat : ’ READ (*,’(I2)’) ORDO 1/11 Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II III IV V VI VII WRITE (*,*) DO 10 I=ORDO+1, 1, -1 WRITE (*,’(A,I2,A,\)’) ‘Koefisien X^’,I-1,‘ = ’ READ (*,’(I3)’) KOEF(I) 10 CONTINUE WRITE (*,*) WRITE (*,*) ‘Persamaan yang diinput : ’ WRITE (*,*) CALL OUTPUT (ORDO,KOEF) PAUSE 2/11 Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II WRITE (*,’(24(/))’) WRITE (*,’(20X,A)’) ‘Pencarian Akar Menggunakan Metode Sekan’ WRITE (*,’(20X,A)’) ‘==========================’ WRITE (*,*) CALL OUTPUT(ORDE,KOEF) WRITE (*,*) WRITE (*,’(A,\)’) ‘X0(Batas Bawah) = ’ READ (*,*) X0 WRITE (*,’(A,\)’) ‘X1(Batas Atas) = ’ READ (*,*) X1 III IV V VI VII 3/11 Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II WRITE (*,’(A,\)’) ‘Toleransi Kesalahan = ’ READ (*,*) T WRITE (*,*) X2 = X1 – (FNG(ORDO,KOEF,X1)*(X1-X0))/ (FNG(ORDO,KOEF,X1)-FNG(ORDO,KOEF,X0)) ITER = 1 WRITE (*,*) ‘ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿’ WRITE (*,'(2(A,3X),7(A,6X),A,3X,A)') '³', ' ITERASI','³','X0','³','X1','³','X2','³', 'F(X2)','³’ WRITE (*,*) ‘ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´’ III IV V VI VII 4/11 Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II WHILE (( ABS((X1-X2)/X1) .GT. T) .AND. ( FNG(ORDO,KOEF,X2) .NE. 0 )) DO WRITE (*,'(A,5X,I3,6X,A,4(1X,F12.7,1X,A))') '³',ITER,'³',X0,'³',X1,'³',X2,'³', FNG(ORDO,KOEF,X2),'³' X0 = X1 X1 = X2 X2 = X1 - (FNG(ORDO,KOEF,X1)*(X1-X0))/ (FNG(ORDO,KOEF,X1)-FNG(ORDO,KOEF,X0)) ITER = ITER + 1 PAUSE ENDWHILE III IV V VI VII 5/11 Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II WRITE (*,'(A,5X,I3,6X,A,4(1X,F12.7,1X,A))') '³',ITER,'³',X0,'³',X1,'³',X2,'³', FNG(ORDO,KOEF,X2),'³' WRITE (*,*) 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ' WRITE (*,*) WRITE (*,*) 'SOLUSINYA = ',X2 END III IV V SUBROUTINE OUTPUT (ORDO,KOEF) DIMENSION KOEF(20) INTEGER ORDO WRITE (*,'(A,\)') 'F(X) = ' VI VII 6/11 Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II DO 20 I = ORDO + 1, 1, -1 IF (I .GT. 2) THEN IF (KOEF(I) .EQ. (-1)) THEN WRITE (*,'(A,I2,\)') 'X^',I – 1 ELSEIF ((KOEF(I) .NE. 1) .AND. (KOEF(I) .NE. 0)) THEN WRITE (*,'(I3,A,I2,\)') KOEF(I),'X^',I – 1 ELSEIF (KOEF(I) .NE. 0) THEN WRITE (*,'(A,I2,\)') 'X^',I – 1 ENDIF IF (KOEF(I-1) .GT. 0) THEN WRITE (*,'(A,\)') ' + ‘ ENDIF III IV V VI VII 7/11 Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II III IV - V VI VII 8/11 ELSEIF (I .EQ. 2) THEN IF (KOEF(I) .EQ. (-1)) THEN WRITE (*,'(A,\)') '-X ‘ ELSEIF ((KOEF(I) .NE. 1) .AND. (KOEF(I) .NE. 0)) THEN WRITE (*,'(I3,A,\)') KOEF(I),' X ‘ ELSEIF (KOEF(I) .NE. 0) THEN WRITE (*,'(A,\)') ' X ‘ ENDIF IF (KOEF(I-1) .GT. 0) THEN WRITE (*,'(A,\)') ' + ‘ ENDIF ELSEIF (KOEF(I) .NE. 0) THEN Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH PROGRAM II III WRITE (*,'(I3)') KOEF(I) ENDIF 20 CONTINUE END IV V VI VII REAL FUNCTION FNG(ORDO,KOEF,MX) INTEGER ORDO DIMENSION KOEF(20) REAL MX FNG = 0 DO 30 I = ORDO + 1, 1, -1 IF (MX .NE. 0) FNG = FNG + (KOEF(I)*MX**(I-1)) 30 CONTINUE RETURN 9/11 END Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH OUTPUT PROGRAM II Input Persamaan =============== III Orde/Derajat : 3 IV V VI Koefisien Koefisien Koefisien Koefisien X^ X^ X^ X^ 3 2 1 0 = = = = 1 0 -2 -5 Persamaan yang diinput : F(X) = X^ 3 -2 X -5 VII 10/11 Bersambung ke slide berikutnya Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I CONTOH OUTPUT PROGRAM II III IV V VI VII Pencarian Akar menggunakan Metode Sekan ======================================= F(X) = X^ 3 -2 X -5 X0(Batas Bawah) = 1 X1(Batas Atas) = 2 Toleransi Kesalahan = 0.001 ┌──────────┬───────────┬───────────┬───────────┬───────────────┐ │ ITERASI │ X0 │ X1 │ X2 │ F(X2) │ ├──────────┼───────────┼───────────┼───────────┼───────────────┤ │ 1 │ 1.0000000 │ 2.0000000 │ 2.2000000 │ 1.2480010 │ │ 2 │ 2.0000000 │ 2.2000000 │ 2.0889680 │ -0.0621233 │ │ 3 │ 2.2000000 │ 2.0889680 │ 2.0942330 │ -0.0035534 │ │ 4 │ 2.0889680 │ 2.0942330 │ 2.0945530 │ 0.0000114 │ └──────────┴───────────┴───────────┴───────────┴───────────────┘ Solusinya = 2.0945530 11/11 Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Daftar Isi VI LAPORAN AKHIR Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I LAPORAN AKHIR II III IV 1. Tuliskan Logika untuk program yang telah ditulis. 2. Logika tidak boleh sama. V VI VII Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Daftar Isi VII LAPORAN PENDAHULUAN PERTEMUAN 6 Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. I LAPORAN PENDAHULUAN PERTEMUAN 6 II 1. III IV 2. Sebutkan dan jelaskan metode yang dapat digunakan untuk mencari invers suatu matriks ! Diketahui sebuah matriks : VI │ │ │ │ │ VII Tentukan : a. Matriks adjoin ? b. Eliminasi Gauus Jordan ? V 2 4 8 16 32 3 6 12 24 48 4 8 16 32 64 5 10 20 40 80 6 12 24 48 96 │ │ │ │ │ Daftar Isi Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only. Daftar Isi Sampai bertemu lagi di Pertemuan ke 6 Copyright © 2008. This presentation is dedicated to Laboratorium Informatika Universitas Gunadarma. This presentation is for education purpose only.