Professional Documents
Culture Documents
Metodos
Metodos
clear
clc
q= abs(log10(TOL));
fprintf('\n');
a=i(1);
b=i(2);
n= (log10(b-a)+q)/log10(2)+1;
y=inline(f);
i=1;
swa=0;
m=0;
FA=y(a);
fprintf('\n');
while i<=n
p=a+(b-a)/2;
e=(b-a)/2;
FP=y(p);
if FA*FP >=0
t=('> 0');
else
t=('< 0');
end
fprintf('%9.0f',m);
fprintf('%9.3f ',a,FA,b,p,FP,e);
fprintf('%10s',t);
fprintf('\n');
swa=1;
t=('PARAR');
break
end
i=i+1;
swb=1;
if FA*FP > 0
a=p;
FA=FP;
else
b=p;
end
end
if swa==0
end
Metodo Newton Raphson
clc
clear
syms x;
i=1;
fx(i)=x0;
f1=subs(f,x,fx(i));
z=diff(f);
d=subs(z,x,fx(i));
ea(1)=100;
while abs(ea(i))>=tol;
ea(i+1)=abs((fx(i+1)-fx(i))/fx(i+1)*100);
i=i+1;
end
for j=1:i;
end