metode secant

3
1. Membuat program Metode secant seperti di bawah ini clc; clear; disp('Program Metode Secant'); disp('Reynes E.Tekay f44114022'); disp('alamsyah f44114019'); E=0.000001; x1=input('Masukkan X1 :'); x2=input('Masukkan X2 :'); i=0 ; M=5; disp('______________________________________________'); disp(' i xi f(xi) epsilon'); disp('______________________________________________'); while (E<M) fx=3/6*(x1)^5+2/3*(x1)^4+4/2; fx2=3/6*(x2)^5+2/3*(x2)^4+4/2; d = x2 - (fx2*(x2-x1)/(fx2-fx)); M=abs(x1-x2); x1 = x2; x2 = d; i=i+1; fprintf('%3.0f %12.6f %12f %12.6f\n',i,x2,fx,M); %angka angka didalamnya adalah spasi end; disp(sprintf('Hasil Akar=%5f',i+1)) xg=linspace(x1,x2); yg=(xg); plot(xg,yg) grid on 2. Menekan Evaluate call seperti di bawah ini

Upload: reynes-e-tekay

Post on 20-Mar-2017

37 views

Category:

Presentations & Public Speaking


0 download

TRANSCRIPT

Page 1: Metode Secant

1. Membuat program Metode secant seperti di bawah ini

clc; clear; disp('Program Metode Secant'); disp('Reynes E.Tekay f44114022'); disp('alamsyah f44114019'); E=0.000001; x1=input('Masukkan X1 :'); x2=input('Masukkan X2 :'); i=0 ; M=5; disp('______________________________________________'); disp(' i xi f(xi) epsilon'); disp('______________________________________________'); while (E<M) fx=3/6*(x1)^5+2/3*(x1)^4+4/2; fx2=3/6*(x2)^5+2/3*(x2)^4+4/2; d = x2 - (fx2*(x2-x1)/(fx2-fx)); M=abs(x1-x2); x1 = x2; x2 = d; i=i+1; fprintf('%3.0f %12.6f %12f %12.6f\n',i,x2,fx,M); %angka angka didalamnya adalah spasi end; disp(sprintf('Hasil Akar=%5f',i+1))xg=linspace(x1,x2);yg=(xg);plot(xg,yg)grid on

2. Menekan Evaluate call seperti di bawah ini

3. Akan muncul Command window dan menapilkan hasil program seperti gambar

Page 2: Metode Secant

4. Apabila selesai tekan tombol enter dan akan sendirinya muncul data tabel program seprti gambar di bawah ini:

Page 3: Metode Secant

5. Apabila selesa tekan tombol enter dan akan sendirinya muncul figure 1 atau grafik seperti di bawah ini