Está en la página 1de 3

Universidad pública de el alto

M
Facultad de ingeniería
Ingeniería electrónica

Estudiante: Univ. David Franklin Mamani Ramos Inicial del


apellido Paterno

MÉTODO DE LA SECANTE
PROGRAMACIÓN EN MATLAB
fprintf('METODO DE SECANTE \n')
fun = input('INGRESE LA FUNCION: \n', 'S');
x0 = input('INGRESE EL PUNTO INICIAL x0: \n');
x1 = input('INGRESE EL PUNTO INICIAL x1: \n');
tot = input('INGRESE LA TOLERANCIA: \n');

it = 0;
fprintf('it x0 x1 x2 |x2 - x1| \n');

while(it < 50)


it = it +1;
x = x0;
f_0 = eval(fun);
x = x1;
f_1 = eval(fun);
x2 = x1 - f_1 * (x0 - x1)/(f_0 - f_1);
fprintf('%3.0f %12.8f %12.8f %12.8f %12.8f \n', it, x0, x1, x2, abs(x0 - x1));

if abs(x0 - x1) < tot


fprintf('EL PROCESO SE COMPLETA SATISFACTORIAMENTE: \n');
break
end
x0 = x1;
x1 = x2;
end
fprintf('LA RAIZ BUSCADA ES = %15.9f\n', x2);
ezplot (fun)
grid on
line([-20 0; 20 0], [0 -20; 0 20], 'color', 'r')
FUNCIONAMIENTO DEL MÉTODO

También podría gustarte