METODO DE LA SECANTE


clc
syms x
f=inline(input('ingrese la funcion :','s'));
x0=input('ingrese intervalo inferior:');
x1=input('ingrese intervalo superior:');
tol=input('ingrese la tolerancia:');
fx0=feval(f,x0);
fx1=feval(f,x1);
n=1;
if(abs(fx0))<(abs(fx1))
     fx2=900;
           disp('n     x0       x1        x2        f(x0)      f(x1)       f(x2) ')
     while (abs(fx2))>tol
        x2=x1-((x1-x0)/(fx1-fx0))*fx1;
        fx2=feval(f,x2);
        fprintf('n%d   %0.4f  %0.4f   %0.4f      %0.4f     %0.4f     %0.4f',n,x0,x1,x2,fx0,fx1,fx2)
         x0=x1;
        x1=x2;
        fx0=feval(f,x0);
       fx1=feval(f,x1);
      n=n+1;
   end
else
    disp('NO SE PUEDE REALIZAR POR ESTE METODO');
    disp('|F(X0)| TIENE QUE SER MENOR A |F(X1)|');
end
  

Hoy habia 13 visitantes (15 clics a subpáginas) ¡Aqui en esta página!
Este sitio web fue creado de forma gratuita con PaginaWebGratis.es. ¿Quieres también tu sitio web propio?
Registrarse gratis