% demonstracni priklad pro predvedeni proste iteracni metody 
% sepsal Jan Nejedly 2003
%
% ukazka bude provedena na f(x)=(x/2)^2-sin(x)

a=1;
b=4;
kroku=20;
presnost=.001;
start=1.5;


x0=a:0.01:b;
%yo=(x0/2).^2-sin(x0);
%figure(1);
%plot(x0,yo,'b--');
%hold on;
figure(1);
y=2*sqrt(sin(x0));
plot(x0,y);
axis square;
axis([0 4 0 4]);
hold on;

x=start;
for i=1:kroku
  new=2*sqrt(sin(x));
  if abs(x-new)<presnost
    disp('mame nulu');
    x
    break;
  end;  
  plot(x,0,'rx');
  pause;
  line([x x],[0 new]);
  pause;
  line([x 0],[new new]);
  pause;
  line([0 new],[new 0]);
  plot(new,0,'gx');
  x=new;
  pause;
  
  figure(1);
  hold off;
  y=2*sqrt(sin(x0));
  plot(x0,y);
  axis square;
  axis([0 4 0 4]);
  hold on;
  
end;
     	
