def _bracket(self, qinit, f0, fun):
self.num_bracket = <NUM_LIT:0><EOL>qa = qinit<EOL>fa = fun(qa)<EOL>counter = <NUM_LIT:0><EOL>if fa >= f0:<EOL><INDENT>while True:<EOL><INDENT>self.num_bracket += <NUM_LIT:1><EOL>qb, fb = qa, fa<EOL>qa /= <NUM_LIT:1>+phi<EOL>fa = fun(qa)<EOL>if qa < self.qtol:<EOL><INDENT>return<EOL><DEDENT>if fa < f0:<EOL><INDENT>return (<NUM_LIT:0>, f0), (qa, fa), (qb, fb)<EOL><DEDENT>counter += <NUM_LIT:1><EOL>if self.max_iter is not None and counter > self.max_iter:<EOL><INDENT>return<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self.num_bracket += <NUM_LIT:1><EOL>qb, fb = qa, fa<EOL>qa *= (<NUM_LIT:1>+phi)<EOL>fa = fun(qa)<EOL>if fa >= fb:<EOL><INDENT>return (<NUM_LIT:0>, f0), (qb, fb), (qa, fa)<EOL><DEDENT>while True:<EOL><INDENT>self.num_bracket += <NUM_LIT:1><EOL>qc, fc = qb, fb<EOL>qb, fb = qa, fa<EOL>qa = qb*(<NUM_LIT:1>+phi) - qc<EOL>fa = fun(qa)<EOL>if fa >= fb:<EOL><INDENT>return (qc, fc), (qb, fb), (qa, fa)<EOL><DEDENT>counter += <NUM_LIT:1><EOL>if self.max_iter is not None and counter > self.max_iter:<EOL><INDENT>return<EOL><DEDENT><DEDENT><DEDENT>
Find a bracket that does contain the minimum