0% found this document useful (0 votes)
42 views2 pages

SCRIPT PRINCIPAL: Biseccion

The document describes a bisection method algorithm to find the root of a non-linear function within a specified tolerance. It takes input for the lower and upper bounds of the interval, calculates the function value at each bound, then iteratively bisects the interval and calculates the function value at the midpoint until the root is found or the maximum number of iterations is reached.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

SCRIPT PRINCIPAL: Biseccion

The document describes a bisection method algorithm to find the root of a non-linear function within a specified tolerance. It takes input for the lower and upper bounds of the interval, calculates the function value at each bound, then iteratively bisects the interval and calculates the function value at the midpoint until the root is found or the maximum number of iterations is reached.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SCRIPT PRINCIPAL: biseccion

% METODO DE BISECCION
clc
maxite=20;
tol=0.0001;

xi=input('ingrese el limite inferior xi=');


xs=input('ingrese el limite superior xs=');

fxi=feval('ea_nolin2',xi);
fxs=feval('ea_nolin2',xs);

conta=0;
if(fxi*fxs>0)

fprintf('-------------------------------------------------------------\n'
);
fprintf(' METODO DE BISECCION\n');
fprintf('Itera xi xs fxi fxs\n');

fprintf('-------------------------------------------------------------\n'
);
fprintf('%3.0f%12.4f%12.4f%12.4f%12.4f\n',conta,xi,xs,fxi,fxs);
fprintf('\n el intervalo inicial no contiene a la raiz\n');
break
end
clc
fprintf('-------------------------------------------------------------\n'
);
fprintf(' METODO DE BISECCION\n');
fprintf('Itera xi xs xm fxi fxs
fxm\n');
for conta=1:maxite
xm=(xi+xs)/2;
fxm=feval('ea_nolin2',xm);
fprintf('%3.0f%10.4f%10.4f%10.4f%10.4f%10.4f
%10.4f\n',conta,xi,xs,xm,fxi,fxs,fxm);
if(abs(fxm)>tol)
if(fxi*fxm>0)
xi=xm;
fxi=fxm;
else
xs=xm;
fxs=fxm;
end
else
break
end
end
fprintf('-------------------------------------------------------------\n'
);
if(conta>=maxite)
fprintf(' El metodo no Converge\n');
else
fprintf(' La respuesta es:%12.4f\n',xm);
end
ARCHIVO DE FUNCION: ea_nolin2

function f = ea_nolin2(x)
f = 2*x^2-x-5;

RESULTADO:

You might also like