1 function brent(ax,bx,cx,fb0,f,tol,ftol,xmin,iflag)
5 double precision brent,ax,bx,cx,f,tol,ftol,xmin
6 double precision a,b,d,e,etemp,fu,fv,fw,fx,r,q,p,tol1,tol2,u,v,w,
12 double precision CGOLD,ZEPS
13 parameter(itmax=100,cgold=.3819660d0,zeps=1.0d-10)
44 if(abs(x-xm).le.(tol2-.5d0*(b-a)))
goto 3
46 if(abs(e).gt.tol1)
then
56 if(abs(p).ge.abs(.5*q*etemp).or.p.le.q*(a-x).or.
57 * p.ge.q*(b-x))
goto 1
63 if(u-a.lt.tol2 .or. b-u.lt.tol2) d=sign(tol1,xm-x)
79 2
if(abs(d).ge.tol1)
then
86 if (iflag.lt.0)
go to 3
112 if(fu.le.fw .or. w.eq.x)
then
117 else if(fu.le.fv .or. v.eq.x .or. v.eq.w)
then
125 if (abs(fx-fw).lt.ftol)
goto 3
129 print *,
'Brent exceed maximum iterations.'
130 print *,
'[execution paused, press enter to continue]'
double precision function brent(ax, bx, cx, fb0, f, tol, ftol, xmin, iflag)