clear,clc,close all % Caso convergente, pendiente positiva a=0;b=1; g=@(x)0.5*x.^2+0.3; x0=0.95; xx=linspace(a,b); plot(xx,g(xx),'r-'), hold on plot([a b],[a b],'k-') axis([a,b,a,b]) set(gca,'XTick',[],'YTick',[]) hold on title('CASO CONVERGENTE: 0 < g''(x) < 1','Fontsize',16,'Fontweight','b') x1=g(x0); plot([x0 x0],[0 x1]) text(x0+0.01,0.03,['x_',num2str(0)],'Fontsize',16,'Fontweight','b') pause for i=1:5 plot([x0 x1],[x1 x1]) text(x1+0.01,0.03,['x_',num2str(i)],'Fontsize',16,'Fontweight','b') text(x1,0,'I','Fontsize',16,'Fontweight','b') pause x0=x1;x1=g(x0); plot([x0,x0],[x0 x1]) pause end clear,clc,close all % Caso convergente, pendiente negativa a=0;b=1; g=@(x)-0.5*x.^2+0.7; x0=0.95; xx=linspace(a,b); plot(xx,g(xx),'r-'), hold on plot([a b],[a b],'k-') axis([a,b,a,b]) set(gca,'XTick',[],'YTick',[]) hold on title('CASO CONVERGENTE: -1 < g''(x) < 0','Fontsize',16,'Fontweight','b') x1=g(x0); plot([x0 x0],[0 x1]) text(x0+0.01,0.03,['x_',num2str(0)],'Fontsize',16,'Fontweight','b') pause for i=1:5 plot([x0 x1],[x1 x1]) text(x1+0.01,0.03,['x_',num2str(i)],'Fontsize',16,'Fontweight','b') text(x1,0,'I','Fontsize',16,'Fontweight','b') pause x0=x1;x1=g(x0); plot([x0,x0],[x0 x1]) pause end clear,clc,close all % Caso divergente, pendiente positiva a=0;b=1; g=@(x)1.3*x.^2-0.1; x0=0.83; xx=linspace(a,b); plot(xx,g(xx),'r-'), hold on plot([a b],[a b],'k-') axis([a,b,a,b]) set(gca,'XTick',[],'YTick',[]) hold on title('CASO DIVERGENTE: g''(x) > 1','Fontsize',16,'Fontweight','b') x1=g(x0); plot([x0 x0],[0 x1]) text(x0+0.01,0.03,['x_',num2str(0)],'Fontsize',16,'Fontweight','b') pause for i=1:5 plot([x0 x1],[x1 x1]) text(x1+0.01,0.03,['x_',num2str(i)],'Fontsize',16,'Fontweight','b') text(x1,0,'I','Fontsize',16,'Fontweight','b') pause x0=x1;x1=g(x0); plot([x0,x0],[x0 x1]) pause end clear,clc,close all % Caso divergente, pendiente positiva a=0;b=1; g=@(x)-1.3*x.^2+1; x0=0.6; xx=linspace(a,b); plot(xx,g(xx),'r-'), hold on plot([a b],[a b],'k-') axis([a,b,a,b]) set(gca,'XTick',[],'YTick',[]) hold on title('CASO DIVERGENTE: g''(x) < - 1','Fontsize',16,'Fontweight','b') x1=g(x0); plot([x0 x0],[0 x1]) text(x0+0.01,0.03,['x_',num2str(0)],'Fontsize',16,'Fontweight','b') pause for i=1:7 plot([x0 x1],[x1 x1]) text(x1+0.01,0.03,['x_',num2str(i)],'Fontsize',16,'Fontweight','b') text(x1,0,'I','Fontsize',16,'Fontweight','b') pause x0=x1;x1=g(x0); plot([x0,x0],[x0 x1]) pause end