Login  Register

Brent solver change.

Posted by Francis Duffy on Nov 28, 2012; 11:29pm
URL: http://quantlib.414.s1.nabble.com/Brent-solver-change-tp13747.html

Hi,
 
I believe that the change below should be made to the Brent solver routine. In cases where std::fabs(fxMax_) < std::fabs(froot), then root_ is set equal to xMax_. If the convergence check is then met, root_ is returned but the funtion/funtor f is not updated with this new route. For example, when the routine is used in the iterative bootstrap, the discount factor vector is not updated with the new root_. Would there be any objections to this change?
 
Thanks and regards,
Francis.
 
Index: QuantLib/ql/math/solvers1d/brent.hpp
===================================================================
--- QuantLib/ql/math/solvers1d/brent.hpp        (revision 18356)
+++ QuantLib/ql/math/solvers1d/brent.hpp        (working copy)
@@ -82,8 +82,11 @@
                 // Convergence check
                 xAcc1=2.0*QL_EPSILON*std::fabs(root_)+0.5*xAccuracy;
                 xMid=(xMax_-root_)/2.0;
-                if (std::fabs(xMid) <= xAcc1 || (close(froot, 0.0)))
+                if (std::fabs(xMid) <= xAcc1 || (close(froot, 0.0))) {
+                    f(root_);
+                    ++evaluationNumber_;
                     return root_;
+                }
                 if (std::fabs(e) >= xAcc1 &&
                     std::fabs(fxMin_) > std::fabs(froot)) {
 

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
INSIGHTS What's next for parallel hardware, programming and related areas?
Interviews and blogs by thought leaders keep you ahead of the curve.
http://goparallel.sourceforge.net
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users