%bisection method
%author: Miao Chizheng
%f(sigma)=S0*cndf(d1)-K*cndf(d2)*exp(-r*T)-c;
k=0;
eps=0.00000000001;
a=-1;
b=2; 

while abs(b-a)>eps*abs(b)
    
    c=(a+b)/2;
    if sign(f(c))==sign(f(b));
        b=c;
    else
        a=c;
    end
    k=k+1;
end
c
