## Author: M Turhan ÇOBAN
## Created: 2021-10-25
# bisection root finding method
function retval = bisection_secant(f,a,b)
r=0.0;
fa=f(a);
fr=1.0;
eps=1e-6;
i=0;
maxiter=100;
i=0;
for i=1:5
    r=(a+b)/2;
    fr=f(r);
    if(fa==0) 
      retval=a;break;
    elseif(fr==0) 
      retval=r;break;
    elseif(fa*fr<0)
      b=r;
    else
      a=r;
      fa=fr;
    endif
    i=i+1;
  retval =r;
endfor
while(abs(fr)>eps && i<maxiter)
  r=r-fr/df(f,r);
  fr=f(r);
  i=i+1;
endwhile
if(i>=maxiter) disp("maximum iteration limit");
endif 
endfunction