Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize
your function to return an output with the same size and shape as the input arguments.
grid on
1
14 -1.75766 0.000263779 interpolation
15 -1.75756 -1.20619e-06 interpolation
16 -1.75756 -4.67286e-11 interpolation
17 -1.75756 0 interpolation
2
fx = -1.1102e-16
%% Iniciando variables
%% Iniciando variables
x1 = 1; %Aproximacion Inicial de la Raiz 0.3129
x2 = 0.5; %Aproximacion Inicial de la Raiz 0.3129
x4 = 0.1; %Aproximacion Inicial de la Raiz 0.0858
x5 = 0.09; %Aproximacion Inicial de la Raiz 0.0858
x7= -1.65; %Aproximacion Inicial de la Raiz -1.7576
x8= -1.70; %Aproximacion Inicial de la Raiz -1.7576
es = 0.001; %Tolerancia
maxit = 50; %Maximo Numero de iteracciones
ea = 100;
eb = 100;
ec = 100;
iter = 1;
jter = 1;
zter = 1;
%% Inicio del Bucle
disp(' k xi xj ea(%)')
k xi xj ea(%)
while (1)
xrold1 = x1;
x3=x1;
x1 = x1-(func(x1)* ((x1 - x2)/(func(x1)-func(x2))));
x2 = x3;
fprintf('%3i%11.4f\t%11.4f\t%11.6f\n',iter,x1,x2,ea)
iter = iter + 1;
if x1 ~= 0
ea = abs((x1-xrold1)/x1)*100;
end
if ea <= es || iter >= maxit
break;
end
end
root1 = x1;
fprintf('La primera raiz es: %11.4f\n',root1);
disp(' k xi xj ea(%)')
k xi xj ea(%)
3
while (1)
xrold2 = x4;
x6=x4;
x4 = x4-(func(x4)* ((x4 - x5)/(func(x4)-func(x5))));
x5 = x6;
fprintf('%3i%11.4f\t%11.4f\t%11.6f\n',jter,x4,x5,eb)
jter = jter + 1;
if x4 ~= 0
eb = abs((x4-xrold2)/x4)*100;
end
if eb <= es || jter >= maxit
break;
end
end
root2 = x4;
disp(' k xi xj ea(%)')
k xi xj ea(%)
while (1)
xrold3 = x7;
x9=x7;
x7 = x7-(func(x7)* ((x7 - x8)/(func(x7)-func(x8))));
x8 = x9;
fprintf('%3i%11.4f\t%11.4f\t%11.6f\n',zter,x7,x8,ec)
zter = zter + 1;
if x7 ~= 0
ec = abs((x7-xrold3)/x7)*100;
end
if ec <= es || zter >= maxit
break;
end
end
root3 = x7;
fprintf('La tercera raiz es: %11.4f\n',root3);
4
5