disp ('                This is the code of Fixed point iteration method.Is writen by Ali Ashouri and Nima Ashrafi')
format long
disp (' ')
disp (' ')
disp ('    ********Before enter anything read all of introduction that will write. read all of them*******')
disp (' ')
disp (' at first calculate the differential function which used in this method.so write at commond window:')
disp (' ')
disp (' syms y;')
disp (' diff(f(y)) ------- f(y) is your function at term like sin(y) or y.^2')
disp (' ')
disp (' ')
disp ('                 x must be at double class and before play the program write its limit in commond window. like: x=-1:0.00001:1')
disp (' ')
disp ('                real function should be start by @(x) like : @(x) sin(x)')
disp (' ')
disp ('                secondary function should be start by @(x) like : @(x) sin(x)')
disp (' ')
disp ('                differential of secondary function should be start by @(x) like : @(x) sin(x)')
disp (' ')
f=input('enter your real function :  ');
g=input('enter your secondary function :  ');
h=input('enter your differential of secondary function :  ');
a=input('enter the first number of limit :  ');
b=input('enter the final number of limit :  ');
x0=input('enter the x0 number :  ');
disp (' ')
disp (' ')
disp (' If you have not any epsilon, for eps or d enter 0 (zero) ')
disp (' ')
xn=g(x0);
d=input('Enter the epsilon or d number :  ');
while ( max(g(x))>b || min(g(x))<a)
    disp('    your secondary function is uncorrect at inputed limit   ')
    g=input('enter your secondary function :  ');
    h=input('enter your differential of secondary function :  ');
end;
while ( max(abs(h(x)))>max(abs(a),abs(b)))
    disp('    your secondary function is uncorrect at inputed limit   ')
    g=input('enter your secondary function :  ');
    h=input('enter your differential of secondary function :  ');
    while ( max(g(x))>b || min(g(x))<a)
    disp('    your secondary function is uncorrect at inputed limit   ')
    g=input('enter your secondary function :  ');
    h=input('enter your differential of secondary function :  ');
    end;
end;
tic
  if d==0
      c=g(x0);
      n=1;
      disp('n     I             x0           I             xn           ')
      disp ------------------------------------------------------------------------------------------------------------------------------------
      r=[num2str(n),'       I   ',num2str(x0),'           I         ',num2str(c)];
      disp (r)
      while (xn>x0 || xn<x0)
              x0=xn;
              xn=g(x0);
              n=n+1;
              r=[num2str(n),'       I   ',num2str(x0),'           I         ',num2str(xn)];
              disp (r)
      end
  else
      xn=g(x0);
      n=1;
      disp('n     I             x0           I             xn                    |                    f(xn)')
      disp ------------------------------------------------------------------------------------------------------------------------------------
      r=[num2str(n),'       I   ',num2str(x0),'           I         ',num2str(xn),'               |            ',num2str(f(xn))];
      disp (r)
      while abs(f(xn))>d
           x0=xn;
          xn=g(x0);
          n=n+1;
          r=[num2str(n),'       I   ',num2str(x0),'           I         ',num2str(xn),'               |            ',num2str(f(xn))];
          disp (r)
      end;
  end;
disp ('           ')
disp (['                          xn=      ',num2str(xn)])
disp (['                          n=      ',num2str(n)])
toc;