def quad( self, dir, iter, step_size, base, bloginfo ): coeffs = quad_coef( self.xtrial[ -3: ], self.ftrial[ -3: ] ) delta = ConfBracket.neg_pos[ dir ] delta *= abs( self.xtrial[ -1 ] - self.xtrial[ -2 ] ) lastx = self.xtrial[ -1 ] mroot = demuller( numpy.poly1d( coeffs ), lastx + delta, lastx + 2 * delta, lastx + 3 * delta, tol=1.0e-2 ) xroot = mroot[ 0 ][ 0 ] if xroot is None or numpy.isnan( xroot ): return self.covar( dir, iter, step_size, base ) try: Halley = trace_fcn( self.Halley, bloginfo ) [xroot, froot] = Halley( coeffs, xroot, tol=1.0e-3 ) except ZeroDivisionError: xroot = None if (None != xroot and False == numpy.isnan( xroot )) and \ self.is_same_dir( dir, self.xtrial[ -1 ], xroot ): return xroot else: return self.covar( dir, iter, step_size, base )
def demuller2(fcn, xa, xb, fa=None, fb=None, args=(), maxfev=32, tol=1.0e-6): return demuller(fcn, xa, xb, (xa + xb) / 2.0, args=args, maxfev=maxfev, tol=tol)
def quad(self, dir, iter, step_size, base, bloginfo): coeffs = quad_coef(self.xtrial[-3:], self.ftrial[-3:]) delta = ConfBracket.neg_pos[dir] delta *= abs(self.xtrial[-1] - self.xtrial[-2]) lastx = self.xtrial[-1] mroot = demuller(numpy.poly1d(coeffs), lastx + delta, lastx + 2 * delta, lastx + 3 * delta, tol=1.0e-2) xroot = mroot[0][0] if xroot is None or numpy.isnan(xroot): return self.covar(dir, iter, step_size, base) try: Halley = trace_fcn(self.Halley, bloginfo) [xroot, froot] = Halley(coeffs, xroot, tol=1.0e-3) except ZeroDivisionError: xroot = None if (None != xroot and False == numpy.isnan( xroot )) and \ self.is_same_dir(dir, self.xtrial[-1], xroot): return xroot else: return self.covar(dir, iter, step_size, base)
def demuller2( self, fcn, xa, xb, fa=None, fb=None, args=(), maxfev=32, tol=1.0e-6 ): return demuller( fcn, xa, xb, (xa+xb)/2.0, args=args, maxfev=maxfev, tol=tol)