metodos 2

Post on 29-Nov-2015

6 views 0 download

Transcript of metodos 2

METODO DE BISECCIÓNFunction bis1 (función,a,b,n)

i=1;r=(a+b)/2

x=a; fa=eval(funcion);x=r; fr=eval (funcion);

if fa*fr<0b=r;elsea=r;endi=i+1end

METODO DE REGLA FALSAfunction regl (función,a,b,n)

i=1;while i<=n

x=a; fa=eval(funcion);x=b; fb=eval (funcion);

r=a-fa*((b-a)/(fb-fa))x=r; fr=eval(funcion);

if fa*fr<0b=r;elsea=r;endi=i+1end

METODOD DE MULLERfunction mull1 (funcion, x1,x2,x3)

x=x1; fx1=eval (funcion) ;x=x2; fx1=eval (funcion) ;x=x3; fx1=eval (funcion) ;

aa= [x1^2 x1 1;x2^2 x2 1; x3^2 x3 1]bb= [fx1;fx2;fx3]

r=aa\ bb;a=r (1) ; b=r (2) ; c=r (3);

r1= (-b-sqrt (b^2-4*a*c))/(2*a)r2= (-b+sqrt (b^2-4*a*c))/(2*a)

METODO DE PUNTO FIJOfunction fijo1 ( function,x1,n)

i=1;while i˂=n

x= x1;r2=eval (funcion)

x1=r2;i=i+1;end

METODO DE NEWTON 1° ORDEN function newl (función, dfuncion, x0,n)

i=1;while i<=n

x=x0; fx0=eval (funcion);x=x0; dfx0=eval (dfuncion);

x2=x0-fx0/dfx0x1=x2;i=i+1;end

METODO DE VON MISES function vonl (funcion, dfuncion, x0,n)

i=1;x=x0; dfx0=eval (dfuncion);

while i<=nx=x0;

fx0=eval (funcion);x2=x0-fx0/dfx0

x1=x2;i=i+1;end

METODO DE VIRGE VIETTA

function virge1(p,r1,nn)n=length(p)-1;contador=1;

while contador<=nnb(1)=p(1);c(1)=b(1);

for k=2:n+1b(k)=p(k)+r1*b(k-1);c(k)=b(k)+r1*c(k-1);

endr2=r1-b(n+1)/c(n)

r1=r2;