Re: bug related to error message "root not bracketed"

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/bug-related-to-error-message-root-not-bracketed-tp153p154.html

On Thu, 2010-06-03 at 18:37 +0000, Jinping Shi wrote:

> in file ./ql/math/solver1d.hpp, the following bug causes error like
>  
> "root not bracketed: f[2.22045e-16,3] ->
> [-1.534964e-04,-5.486424e-02]"
>  
>  
>     185             fxMin_ = f(xMin_);
>     186             //if (fxMin_ == 0.0)        // Bugfix JSHI
>     187             if (fxMin_ <= accuracy)
>     188                 return xMin_;
>     189
>     190             fxMax_ = f(xMax_);
>     191             //if (fxMax_ == 0.0)        // Bugfix JSHI
>     192             if (fxMax_ <= accuracy)
>     193                 return xMax_;

Yes, I remember this.  The problem is, in this method we don't know if
the accuracy was requested on x of f(x); that differs from solver to
solver.  If f(xMin_) < accuracy, we can return xMin_ if the accuracy was
requested on f(x), since f(xMin_) is close enough to 0; but if it was on
x, we can't return as we're not sure that xMin_ is close enough to the
actual root X (i.e., that xMin_ - X < accuracy.)  The only case in which
we can return is when f(xMin_) is precisely 0, because we found the
root. So, as of now, it's correct for the solver not to return
immediately.  To fix the problem, we could add some logic later (when
the error message is thrown) to ensure that the missing bracketing is
not due to numerical error; or we could add some property to the solvers
so that we know whether the accuracy is on x or f(x), and return when
possible.  Would you mind trying to code that?

Thanks,
        Luigi


--

Quote me as saying I was misquoted.
-- Groucho Marx



------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users