def analysis.numerov_solve.zbrent (   func,
  x1,
  x2,
  tol,
  itmax = 100,
  trace = 0 
)

Definition at line 38 of file numerov_solve.py.

00038                                                  :
00039     "find zeros using the van Wijngaarden-Dekker-Brent method a la Numeric Recipes"
00040     a=x1; b=x2
00041     fa=func(a); fb=func(b)
00042 
00043     assert fb*fa < 0.0, "Root must be bracketed in ZBRENT"
00044     fc=fb
00045     for iter in range(itmax):
00046         if trace: print iter, a, b, fa, fb
00047         if (fb*fc > 0.0):
00048             c=a
00049             fc=fa
00050             e=d=b-a
00051         if abs(fc) < abs(fb):
00052             a=b
00053             b=c
00054             c=a
00055             fa=fb
00056             fb=fc
00057             fc=fa
00058         tol1=2.0*1e-14*abs(b)+0.5*tol
00059         xm=0.5*(c-b)
00060         if abs(xm) <= tol1 or fb == 0.0: return b
00061         if abs(e) >= tol1 and abs(fa) > abs(fb):
00062             s=fb/fa
00063             if a==c:
00064                 p=2.0*xm*s
00065                 q=1.0-s
00066             else:
00067                 q=fa/fc
00068                 r=fb/fc
00069                 p=s*(2.0*xm*q*(q-r)-(b-a)*(r-1.0))
00070                 q=(q-1.0)*(r-1.0)*(s-1.0)
00071             if p>0.0: q = -q
00072             p=abs(p)
00073             min1=3.0*xm*q-abs(tol1*q)
00074             min2=abs(e*q)
00075             if 2.0*p < min(min1,min2):
00076                 e=d
00077                 d=p/q
00078             else:
00079                 d=xm
00080                 e=d
00081         else:
00082             d=xm; e=d
00083         a=b
00084         fa=fb
00085         if abs(d) > tol1:
00086             b += d
00087         elif xm > 0.0:
00088             b+=tol1
00089         else:
00090             b-=tol1 
00091         fb = func(b);
00092         
00093     assert 0, "Maximum number of iterations exceeded in ZBRENT"
00094 
def single_well_numerov_match(V0, dx, parity=1, overlapsize=5):


Generated on Wed Nov 21 10:18:33 2007 for analysis by  doxygen 1.5.4