Definition at line 1549 of file C2Functions.py. 01549 : 01550 "find a very nearby zero of a function based on its derivatives" 01551 a=ypp/2 #second derivative is 2*a 01552 b=yp 01553 c=y 01554 01555 disc=b*b-4*a*c 01556 if disc >= 0: 01557 if b>=0: 01558 q=-0.5*(b+math.sqrt(disc)) 01559 else: 01560 q=-0.5*(b-math.sqrt(disc)) 01561 01562 if q*q > abs(a*c): delta=c/q #since x1=q/a, x2=c/q, x1/x2=q^2/ac, this picks smaller step first 01563 else: delta=q/a 01564 else: 01565 raise C2Exception("Thought a root should be near x= %g, didn't find one" % x) 01566 01567 return delta 01568 def value_with_derivatives(self, x):
|