function sige = impSig(sig0,V,r,T,K,S0);

ep = 0.01;

nIter = 4;

sige = sig0;

for k=1:nIter
        bseprime = 0.5/ep*(bse(K,S0,sige+ep,r,T)-bse(K,S0,sige-ep,r,T));
        sige = sige - (bse(K,S0,sige,r,T)-V)/bseprime
end


end

function v = bse(K,S0,sig,r,T)

d1 = (log(S0/K)+(r+sig^2/2)*T)/(sig*sqrt(T));
d2 = (log(S0/K)+(r-sig^2/2)*T)/(sig*sqrt(T));

Nd1 = my_normcdf(d1); Nd2 = my_normcdf(d2);

v  = S0*my_normcdf(d1) - K*exp(-r*T)*my_normcdf(d2);

end
