Professional Documents
Culture Documents
Analysis Bisection and Golden-Section Method in Matlab: 1. Preliminary
Analysis Bisection and Golden-Section Method in Matlab: 1. Preliminary
Analysis Bisection and Golden-Section Method in Matlab: 1. Preliminary
MATLAB
1
Maizan Rin Dalwain
1
Departemen Tenik Geofisika, Fakultas Teknik Sipil Lingkungan dan Kebumian
Institut Teknologi Sepuluh Nopember (ITS)
ABSTRACT
Bisection method is root-finding method that applies to any continuous function
for which one knows two values with opposites signs. Golden-section method is method
which is searching for minimum of the function on given interval <a,b>. In this
experiment we we solve mathematical problems on MATLAB using bisection method and
golden-section method. We find for roots numerically and to determine the maximum of
function in one example of a mathematical calculation on MATLAB.
Keywords : Bisection Method, Golden Section, Iteration
2. Bisection (x2.5-x-6 = 0)
Script sebagai berikut
%MAIZAN RIN DALWAIN iter = 0;
%03411740000022 error = 1;
%KOMGE D while(1)
clear all %untuk looping
clc iter = iter+1;
%iter xr error = syaratnya
f = @(x) x.^2.5-x-6; xr = (x1+xu)/2;
xmin = -50 %mencari nilai tengah dr nilai min dan
xmax = 50; max
error_max = 0.0001; %perkiraan error = abs(f(xr));
besar error dalam perhitungan, %abs = nilai absolute
diharapkan sekecil mungkin if(error<=error_max ||
iter_max = 100; %pengulangan iter>=iter_max) %|| or kalo | and,
perhitungan merupakan sebuah kondisi
data = xmin:xmax; break;
end
x1 = xmin; %pengganti nama
agar fungsi pada while tidak panjang if(f(xr))*(f(x1))>0
xu = xmax; x1 = xr;
else(f(xr))*(f(xu))<0;
xu = xr; hold on
end plot(xr,f(xr),'*')
end
%syarat bisection (secara matematis)
disp('Root=') %x1 = xr, jika (f(xr))*(f(x1))>0
disp(xr) %xu = xr, jika (f(xr))*(f(xu))<0
%syarat lain : error<=error_max atau
plot(data,f(data)) iter>=iter_max
3. Golden-Section
%MAIZAN RIN DALWAIN x2=x2-d
%03411740000022 iter=iter+1;
%KOMGE D
if k(xl)>k(x2)
clear all x1=xl;
clc else k(xl)<k(x2)
x2=x2;
k=@(x) 2*sin(x)-0.1*x.^2; end
xmin=0; x_lama = xl;
xmax=4; err = abs(x1-x_lama);
error_max=0.0001; if (error<=error_max ||
iter_max=100; iter>=iter_max)
data = xmin:xmax break;
end
x1=xmin; end
x2=xmax;
iter=0; disp('Root=')
error=1; xr=(x1+x2)/2
while(1) plot(data,k(data));
d= (1.6180339886-1)*(x2-x1); hold on
xl=x1+d plot(xr,k(xr),'*g')