disp ('                This is the code of Bisection method.Is writen by Ali Ashouri')
disp (' ')
disp (' ')
disp ('    ********Before enter anything read all of introduction that will write. read all of them*******')
disp (' ')
format long
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 ('                 function should be start by @(x) like : @(x) sin(x)')
disp (' ')
f=input('enter your function:  ');
a=input('enter the first number of limit : ');
b=input('enter the final number of limit: ');
d=input('Enter the epsilon or d number :  ');
disp (' ')
disp (' ')
tic
double (x);
n=1;
xn=(a+b)/2;
disp('n     I       a                I             b           I             c           I            f(a)            I           f(xn)')
disp ------------------------------------------------------------------------------------------------------------------------------------
r=[num2str(n),'       I   ',num2str(a),'           I         ',num2str(b),'         I         ',num2str(xn),'        I           ',num2str(f(a)),'            I            ',num2str(f(xn))];
disp (r)
while abs(f(xn))>=d
    if (f(xn)*f(a))<0
        b=xn;
    else
        a=xn;
    end
    xn=(a+b)/2;
    n=n+1;
     r=[num2str(n),'       I   ',num2str(a),'           I         ',num2str(b),'         I         ',num2str(xn),'        I           ',num2str(f(a)),'            I            ',num2str(f(xn))];
    disp (r)
end;
disp ('           ')
disp (['                          c=',num2str(xn)])
disp (['                          n=',num2str(n)])
toc;