Documente Academic
Documente Profesional
Documente Cultură
la funcin:
2
f(x)=ln( x +1 e
x/ 2
cos ( x )
METODO DE BISECCION
------------------INGRESE LIMITE INFERIOR DEL INTERVALO:0.1
INGRESE LIMITE SUPERIOR DEL INTERVALO:0.5
INGRESE PORCENTAJE DE ERROR:0.01
It. Xa Xr Xb Error aprox
1
0.1000000
0.3000000
0.5000000
2
0.3000000
0.4000000
0.5000000
3
0.4000000
0.4500000
0.5000000
4
0.4500000
0.4750000
0.5000000
5
0.4500000
0.4625000
0.4750000
6
0.4500000
0.4562500
0.4625000
0.100
0.050
0.025
0.012
0.006
10
8
6
4
2
0
-2
-4
-6
-6
-4
-2
0
x
posible raz con una tolerancia de 0.01, luego analizar con todos los
mtodos (grficamente) y explique cuando X0 es -1.
>> newtonrapmetodos
Ingrese el valor inicial: -1
Ingrese el porcentaje de error: 0.01
Ingrese la funcin: cos(x)+(1/(1+2*x))
i
fx(i)
Error
aprox (i)
-1.0000000
100.000
-1.3967943
28.407
-0.3383648
312.807
-0.1237174
173.498
0.5573787
122.196
1.9111501
70.835
1.7882203
6.874
1.7908281
0.146
1.7908291
0.000
x1
f(x)= ( x1)2+ 0.01
para -2<x<2.
ea(1)=100;
while abs(ea(i))>=tol;
fx(i+1)=fx(i)-f1/d; f1=subs(f,x,fx(i+1)); d=subs(z,x,fx(i+1));
ea(i+1)=abs((fx(i+1)-fx(i))/fx(i+1)*100);
i=i+1;
end
fprintf('i
fx(i)
Error aprox (i) \n');
for j=1:i;
fprintf('%2d \t %11.7f \t %7.3f \n',j-1,fx(j),ea(j));
end
>> newtonrapmetodos
Ingrese el valor inicial: 1.01
Ingrese el porcentaje de error: 0.01
Ingrese la funcin: (x-1)/(((x-1).^2)+0.01)
i
fx(i)
1.0100000
100.000
0.9997980
1.020
1.0000000
0.020
1.0000000
0.000
Mtodo de la secante:
function secante
global fun
fprintf('METODO DE SECANTE:\n');
fun=input('ingrese la funcion:\n','s');
x0=input('INGRESE EL PUNTO INICIAL X0:\n');
x1=input('INGRESE EL PUNTO INICIAL X1:\n');
tol=input('INGRESE TOLERANCIA:\n');
it=0;
fprintf('it x0 x1 x2 |x2-x1|');
while(it<50)
it=it+1;
x=x0;
f_0=eval(fun);
x=x1;
f_1=eval(fun);
x2=x1-f_1*(x0-x1)/(f_0-f_1);
fprintf('n%3.0f%12.8f%12.8f%12.8%12.8f\n',it,x0,x1,x2,abs(x0-x1));
end
if(abs(x1-x0)<tol)
fprintf('el proceso se completo satisfactoriamente:\n');
break
end
x0=x1;
x1=x2;
>> secante11
funcion:
(x-1)*(((x-1)^2)+0.01)^-1
ingrese el punto inicial x0:
-1
punto inicial x1:
1
tolerancia:
0.01
it x0 x1 x2 |x2-x1|n 1 -1.00000000 1.00000000n 2 1.00000000
1.00000000el proceso se completo satisfactoriamente:
la raiz buscada es=
nan
1 /3
1 /3
1
1
(2+ 321 2 ) +(2 321 2 )
redondear los clculos a cinco cifras
9
9
function v=falsap(f,a,b,tol,n)
f=inline(f );
v=[];
c=a-(f(a)*(b-a))/(f(b)-f(a));
i=0;
v=[v; i a b c f(c)];
while (i<n && abs(b-a)/2>tol)
if f(a)*f(c)<0
i=i+1;
b=c;
else f(c)*f(b)<0
i=i+1;
a=c;
end
if i<n
c=a-(f(a)*(b-a))/(f(b)-f(a));
v=[v; i a b c f(c)];
end
end
ans =
1.0000
2.0000
1.6667 -1.0370
1.0000
1.6667
2.0000
1.7805 -0.1361
2.0000
1.7805
2.0000
1.7945 -0.0160
3.0000
1.7945
2.0000
1.7961 -0.0019
4.0000
1.7961
2.0000
1.7963 -0.0002
5.0000
1.7963
2.0000
1.7963 -0.0000