You are on page 1of 12

PRACTICA 02 Curso : mtodos numericos 1.

Determina la raz de: 2sen( -x=0

a) En forma grafica b) Con el mtodo de la Biseccin, e itere hasta que E 0.1%. c) Con el mtodo del punto fijo. Haga una eleccin inicial de X0=0.5, e itere hasta que E 0.001%. d) Con el mtodo de Newton-Raphson, e itere hasta que E 0.1%. e) Con el mtodo de la Secante (tres iteraciones, X0=3 y X1=4), e itere hasta que E 0.1%. DESARROLLO: a) Metodo de la Biseccion.-

PROGRAMACION EN LOS BUTTONS: PushButton(Aceptar).F=inline(get(handles.edit1,'string')); a=str2double(get(handles.edit2,'string')); b=str2double(get(handles.edit3,'string')); E=str2double(get(handles.edit4,'string')); if F(a)*F(b)<0 while abs(b-a)>E

x=(a+b)/2; if F(a)*F(x)==0 a=b; else if F(a)*F(x)<0 b=x; else a=x; end end end set(handles.edit5,'string',x); else set(handles.edit5,'string','no existe raiz'); end

PushButton(Grafica).function pushbutton2_Callback(hObject, eventdata, handles) F=inline(get(handles.edit1,'string')); Intervalo=str2num(get(handles.edit6,'string')); ezplot(F,Intervalo) grid on

b) Metodo del punto fijo.-

Programacion en los Buttons: PushButton(Aceptar).f=inline(get(handles.edit1,'string')); g=inline(get(handles.edit2,'string')); x0=str2double(get(handles.edit3,'string'));

E=str2double(get(handles.edit4,'string')); x1=g(x0); while abs(x1-x0)>E x0=x1; x1=g(x0); end set(handles.edit5,'string',x1);

PushButton(Grafica1).f=inline(get(handles.edit1,'string')); ezplot(handles.axes1,f) grid on

PushButton(Grafica2).g=inline(get(handles.edit2,'string')); ezplot(handles.axes2,g) hold on ezplot(handles.axes2,'x') zoom on grid on hold off

c) Metodo de Newton-Rapshon.-

2*sin(sqrt(x))-x

cos(x^(1/2)/x^(1/2)-1 Programacion en los Buttons: PushButton(Aceptar).f=inline(get(handles.edit1,'string')); g=inline(get(handles.edit2,'string')); x0=str2double(get(handles.edit3,'string')) ;E=str2double(get(handles.edit4,'string')); x1=x0-(f(x0)/g(x0)); while abs(x1-x0)>E x0=x1 x1=x0-(f(x0)/g(x0)) end set(handles.edit5,'string',x1);

PushButton(Grafica).f=inline(get(handles.edit1,'string')); intervalos=str2num(get(handles.edit6,'string')); ezplot(f,intervalos),grid on

d) Metodo de la Secante:

Programacion en los Buttons: PushButton(Aceptar).-

f=inline(get(handles.edit1,'string')); x0=str2double(get(handles.edit2,'string')); x1=str2double(get(handles.edit3,'string')); E=str2double(get(handles.edit4,'string')); x2=x1-(((x1-x0)*f(x1))/(f(x1)-f(x0))); while abs (x2-x1)>E x1=x2; x2=x1-(((x1-x0)*f(x1))/(f(x1)-f(x0))) end set(handles.edit5,'string',x2);

PushButton(Grafica).f=inline(get(handles.edit1,'string')); intervalo=str2num(get(handles.edit6,'string')); ezplot(f,intervalo), grid on

1. Segundo ejercicio: a) Metodo de la biseccion.-

Programacion en los Buttons: PushButton(Aceptar).F=inline(get(handles.edit1,'string')); a=str2double(get(handles.edit2,'string')); b=str2double(get(handles.edit3,'string')); E=str2double(get(handles.edit4,'string'));

if F(a)*F(b)<0 while abs(b-a)>E x=(a+b)/2; if F(a)*F(x)==0 a=b; else if F(a)*F(x)<0 b=x; else a=x; end end end set(handles.edit5,'string',x); else set(handles.edit5,'string','no existe raiz'); end

PushButton(Grafica).function pushbutton2_Callback(hObject, eventdata, handles) F=inline(get(handles.edit1,'string')); Intervalo=str2num(get(handles.edit6,'string')); ezplot(F,Intervalo) grid on

b) Metodo del punto fijo.-

Programacion en los Buttons: PushButton(Aceptar).f=inline(get(handles.edit1,'string')); g=inline(get(handles.edit2,'string')); x0=str2double(get(handles.edit3,'string')); E=str2double(get(handles.edit4,'string')); x1=g(x0); while abs(x1-x0)>E

x0=x1; x1=g(x0); end set(handles.edit5,'string',x1);

PushButton(Grafica1).f=inline(get(handles.edit1,'string')); ezplot(handles.axes1,f) grid on

PushButton(Grafica2).g=inline(get(handles.edit2,'string')); ezplot(handles.axes2,g) hold on ezplot(handles.axes2,'x') zoom on grid on hold off

c) Metodo de Newton-Rapshon.-

2*sin(sqrt(x))-x (8*exp(-x))*sin(x)-1 40/(1+0.25*sec(0.5*(x/3)*0.5))-x

You might also like