#NEWLINE# def _quadmin( a , fa , fpa , b , fb ) : #NEWLINE# #INDENT# '\n    Finds the minimizer for a quadratic polynomial that goes through\n    the points (a,fa), (b,fb) with derivative at a of fpa,\n\n    ' #NEWLINE# with np . errstate ( divide = 'raise' , over = 'raise' , invalid = 'raise' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# D = fa #NEWLINE# C = fpa #NEWLINE# db = ( b - ( a * 1.0 ) ) #NEWLINE# B = ( ( ( fb - D ) - ( C * db ) ) / ( db * db ) ) #NEWLINE# xmin = ( a - ( C / ( 2.0 * B ) ) ) #NEWLINE# #UNINDENT# except ArithmeticError : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# if ( not np . isfinite ( xmin ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return xmin