Paper 03411740007001 - Joana Maria Soares Sarmento

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

BISECTION AND GOLDEN-SECTION "MATLAB" MATRIKS

JOANA MARIA SOARES SARMENT


TECHNICAL DEPARTMENT OF GEOFISKA
FACULTY OF CIVIL ENGINEERING AND CIVIL ENGINEERING
2018/2019
joanasarmento289@gmail.com

ABSTRACT
In another post, you can find the function for implementing this special golden search method
and the script for minimizing the above function with the cusp. This script is basically the
same as the one written by Braun and Murdoch on Pages 134-135 in their book. My script
used slightly more self-evident variable names and included debugging statements to help
me to identify why my function was not working properly when I first wrote it. Debugging
statements are statements that show the values of key variables being computed in the flow
of a script (and often within loops or branches) to identify the point in the flow at which the
script stopped working properly. My mathematical and statistical programming skills
became much better when I began using debugging statements. They are good
for debugging, but should generally be commented out when the script is corrected and
working properly.

 Keybord: ( Bisection Method, Golden-section search)

a. as a lower limit. as the upper limit of the T as


1. INTRIDUCTION the midpoint When f (a)> 0 and f (b) <0 then the
multiplication of both produces a number
The method for two (bisection) is based on the smaller than 0 or f (a) ∙ f (b) <0. This means that
value theorem between continuous functions, the hose [a, b] has at least one root. This method
namely that a interval [a, b] must contain f (x) = requires two values as initial guesses, call a and
0, if f (a) and f (b) are opposite signs such as f b, a <b, which must fulfill (a), f (b) <0; interval
(a)> 0 danf (b) <0. The process is carried out by (a, b) contains one root. Initially determined the
repeating dividing the interval [a, b] into two in midpoint of the interval (a, b) or interval (a, b)
each step taken half the hose that meets these divided by two equal lengths, call the point T pah
requirements. This process has the same T. Two new hoses obtained are (a, T) and (T, b),
accuracy as the last [a, b] interval. In the one of which is a material containing roots. The
algorithm variables are used: process is repeated by dividing the two hoses and
checking which interval contains the roots. This
interval is continued until the hose width extremum is known to exist. The technique
reviewed is quite small. derives its name from the fact that the algorithm
 Bisection Method maintains the function values for triples of points
whose distances form a golden ratio. The
In mathematics, the bisection method is a root-
finding method that applies to any continuous
functions for which one knows two values with
opposite signs. The method consists of
repeatedly bisecting the interval defined by
these values and then selecting the subinterval in
which the function changes

sign, and therefore must contain a root. It is a


algorithm is the limit of Fibonacci search (also
very simple and robust method, but it is also
described below) for a large number of function
relatively slow. Because of this, it is often used to
evaluations. Fibonacci search and golden-section
obtain a rough approximation to a solution which
search were discovered by Kiefer (1953) (see
is then used as a starting point for more rapidly
also Avriel and Wilde (1966)).
converging methods.
The discussion here is posed in terms of
The method is also called the interval
searching for a minimum (searching for a
halving method the binary search method, or
maximum is similar) of a unimodal function.
the dichotomy method.
Unlike finding a zero, where two function
For polynomials, more elaborated methods exists evaluations with opposite sign are sufficient to
for testing the existence of a root in an interval bracket a root, when searching for a minimum,
(Descartes' rule of signs, Sturm's three values are necessary. The golden-section
theorem, Budan's theorem). They allow search is an efficient way to progressively reduce
extending bisection method into efficient the interval locating the minimum. The key is to
algorithms for finding all real roots of a observe that regardless of how many points have
polynomial; see Real-root isolation. been evaluated, the minimum lies within the
interval defined by the two points adjacent to the
point with the least value so far evaluated.
 Golden-section search

The golden-section search is a technique for


finding the extremum (minimum or maximum)
of a strictly unimodal functionby successively
narrowing the range of values inside which the
2. METHODOLOGY selecting the subinterval in which the function
Figure 1. Tahapan pelaksanaan penelitian changes.
untuk Golden Secction melalui Matlab: 5. REFERENCES
https://dokumen.tips/documents/metode-
bissection.html
start
https://www.academia.edu/28843518/laporan_p
raktikun_komputasi_proses_bab7_optimasi_vari
Analisis avel_dengan_cara_golden_section.
6. ANNEX
Instalation Matlab
Assignment R04
Insert data GOLDEN SECTION 1. Find for roots numerically with the
Bisection Method in Matlab
a. f(x) = x3 – x – 6 = 0
Run Program b. f(x) = x2.5 – x – 6 = 0
2. Use the golden-section search method to
determine the maximum of the
Analyses Result functions:

a. If xl = 0 and xu =4

3. DISCUSSION
MATLAB

Script One :

clear all
clc
%BISECTION
%untuk mencari xmin dan xmax yang lama
f=@(x) x.^3-x-6 ; %dot (.) berfungsi jika d
pangkatkan pada matriks
xmin=-10 ;
xmax =10;
error_max=0.00001; %error sekecil kecilnya
iter_max=1000; % iter sebagai
pengulangan
data=xmin:xmax;

x1=xmin ; %mendefinisikan yang


baru, buat fungsinya tak terlalu panjang
4. CONCLUSION xu=xmax ;
iter=0 ;
The method consists of repeatedly bisecting the
error=1 ; %start error dari 1
interval defined by these values and then
while (1)
iter=iter+1 ; xmax =10; %contoh x^3 maka x min
xr=(x1+xu)/2 ; %nilai tengah dan x max terdapat pada ujung satu gelombang
error=abs(f(xr)) ; error_max=0.00001; %error sekecil kecilnya
if (error <= error_max || iter >= iter_max) iter_max=1000; % iter sebagai
%untuk garis(|) 2 or 1 and pengulangan
break data=xmin:xmax;
end
if (f(xr)*f(x1)) > 0 %x1=xr, x1=xmin;
(f(xr)*f(x1))>0 xu=xmax;
x1=xr; %xu=xr, iter=0;
(f(xr)*f(x1))<0 while (1)
else (f(xr)*f(x1)) < 0; % syarat lain d=(1.6180339886-1)*(xu-x1);
(pause), error <=error max atau x1=x1+d
xu=xr; % x2=xu-d
iterasi >=iterasi max iter= iter +1
end
end if f(x1)>f(x2)
x1=x1;
disp('Root=') else f(x1)<f(x2)
disp(xr) xu=x2;
end
plot (data, f (data)) x_lama=x1;
hold on err=abs((x1-x_lama));
plot (xr, f(xr), '*') if (err<=error_max || iter >= iter_max)
break
end
end

disp('Root=')
xr=(x1+xu)/2

plot (data, f (data));


hold on
plot (xr, f(xr), '*');

% yang harus ada:


% penjelasan script,
Scrip Two % variasi ( xmin, xmax, iterasi,
error)&pengaruh variasi
clear all % analisa grafik,
clc
%GOLDEN SECTION
%untuk mencari xmin dan xmax yang baru

f=@ (x)x-x.^2/10;
xmin=-10 ; % xmin dan xmax
ditentukan berdasarkan dilihat dari titik tengah
suatu grafik.
%dari titik terdekat dari titik
tengah.

You might also like