## Author: M. Turhan ÇOBAN
## Created: 2021-11-03

function retval = newton_opt(f,x)
## root finding newton-raphson program
   nmax=500;
   tolerance=1.0e-15;
   i=1;
   fx=df(f,x);
   while abs(fx)>tolerance && i<nmax
     fx=df(f,x);
     dfx=df(f,x,2);
     x-=fx/dfx;
     i++;
   endwhile
retval =x;
endfunction
