#NEWLINE# def __iter__( self ) : #NEWLINE# #INDENT# ctx = self . ctx #NEWLINE# f = self . f #NEWLINE# x1 = self . x1 #NEWLINE# fx1 = f ( x1 ) #NEWLINE# x2 = self . x2 #NEWLINE# fx2 = f ( x2 ) #NEWLINE# while True : #NEWLINE# #INDENT# x3 = ( 0.5 * ( x1 + x2 ) ) #NEWLINE# fx3 = f ( x3 ) #NEWLINE# x4 = ( x3 + ( ( ( ( x3 - x1 ) * ctx . sign ( ( fx1 - fx2 ) ) ) * fx3 ) / ctx . sqrt ( ( ( fx3 ** 2 ) - ( fx1 * fx2 ) ) ) ) ) #NEWLINE# fx4 = f ( x4 ) #NEWLINE# if ( abs ( fx4 ) < self . tol ) : #NEWLINE# #INDENT# if self . verbose : #NEWLINE# #INDENT# print_ ( 'canceled with f(x4) =' , fx4 ) #NEWLINE# #UNINDENT# ( yield ( x4 , abs ( ( x1 - x2 ) ) ) ) #NEWLINE# break #NEWLINE# #UNINDENT# if ( ( fx4 * fx2 ) < 0 ) : #NEWLINE# #INDENT# x1 = x4 #NEWLINE# fx1 = fx4 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# x2 = x4 #NEWLINE# fx2 = fx4 #NEWLINE# #UNINDENT# error = abs ( ( x1 - x2 ) ) #NEWLINE# ( yield ( ( ( x1 + x2 ) / 2 ) , x2 ) )