[SciPy-User] Brentq
Charles R Harris
charlesr.harris@gmail....
Thu Jul 26 22:46:11 CDT 2012
On Thu, Jul 26, 2012 at 8:33 PM, The Helmbolds <helmrp@yahoo.com> wrote:
> The user guide says the algorithm for brentq should be obvious from
> inspecting the code.
> Unfortunately, I can't find the code.
> The entire code in the definition of the brentq function (located in the
> zeros section of scipy.optimize) reads:
>
> if type(args) != type(()) :
> args = (args,)
> r = _zeros._brentq(f,a,b,xtol,maxiter,args,full_output,disp)
>
> So it just calls _zeros._brentq.
> The module in which the brentq function is defined imports _zeros.
> I searched but the only _zeros file I could find in scipy.optimize is a
> _zeros.pyd file,
> and that's a DLL file, not a Python code object.
> So I'm at a loss as to where the brentq code is located.
>
I wrote the code, but I would never call it obvious :0 It's rather subtle,
and not as clear in its structured form as when written out with gotos
since it is best understood as a state machine. The inverse quadratic
interpolation isn't the subtle part, it's the control. Note that the form
of the interpolation isn't that found in the original paper.
Chuck
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120726/5e48adfb/attachment.html
More information about the SciPy-User
mailing list