Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Metodo ed la secante

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
x0=x1;
x1=x2;
x2=x1-((x1-x0)*f(x1))/(f(x1)-f(x0))
end
set(handles.edit5,'string',x2);
f=inline(get(handles.edit1,'string'));
ezplot(f),grid on

Mtodo de muller
f=inline(get(handles.edit1,'string'));
x0=str2double(get(handles.edit2,'string'));
x1=str2double(get(handles.edit3,'string'));
x2=str2double(get(handles.edit4,'string'));
E=str2double(get(handles.edit5,'string'));
h0=x1-x0;
h1=x2-x1;
d0=(f(x1)-f(x0))/(x1-x0);
d1=(f(x2)-f(x1))/(x2-x1);
a=(d1-d0)/(h0+h1),
b=a*h1+d1,
c=f(x2)
if b>0
x3=x2-2*c/(b+sqrt(b^2-4*a*c));
else

x3=x2-2*c/(b-sqrt(b^2-4*a*c));
end
while abs((x3-x2)/x3)>E
x0=x1;
x1=x2;
x2=x3;
h0=x1-x0;
h1=x2-x1;
d0=(f(x1)-f(x0))/(x1-x0);
d1=(f(x2)-f(x1))/(x2-x1);
a=(d1-d0)/(h0+h1),
b=a*h1+d1,
c=f(x2);
if b>0
x3=x2-2*c/(b+sqrt(b^2-4*a*c));
else
x3=x2-2*c/(b-sqrt(b^2-4*a*c));
end
end
set(handles.edit6,'string',x3)
ezplot(f),grid on

You might also like