https://github.com/boostorg/math/blob/develop/include/boost/math/tools/toms7...
Couldn't `if(boost::math::sign(fa) * boost::math::sign(fb) > 0)` be
simplified to `if (fa * fb > 0)` or is it just a case of being generic
and Boost-ish templatable?
https://github.com/boostorg/math/blob/develop/include/boost/math/tools/toms7...
Is this test of `if((b - a) < 2 * tol * a)` where tol is 2×epsilon
meaningful given that eps_tolerance has a minimum of 4×epsilon? I
would have thought that tol(a, b) will catch this before it ever
arrives here.
Or is it needed because that is relative tolerance and this is absolute?
On Wed, Jan 27, 2021 at 9:47 PM Shriramana Sharma
Thanks for replying. Will ask here if I have any further questions.
On Wed, Jan 27, 2021 at 6:38 PM John Maddock via Boost-users
wrote: On 26/01/2021 15:46, Shriramana Sharma via Boost-users wrote:
Namaste.
This is wrt the TOMS748 math root finding implementation:
Given that `if(fa == 0)` is handled at:
https://github.com/boostorg/math/blob/develop/include/boost/math/tools/toms7...
… and the function returns in case of the above condition, it is not clear to me what the need is for the `if (fa != 0)` at:
https://github.com/boostorg/math/blob/develop/include/boost/math/tools/toms7...
You're quite right - it's superfluous, will fix.
Now I also note similar checks at:
https://github.com/boostorg/math/blob/develop/include/boost/math/tools/toms7... https://github.com/boostorg/math/blob/develop/include/boost/math/tools/toms7...
… but regarding those lines, while I can understand the need for checking there after more bracketing work is done, it is not clear to me why `(fa == 0)` is alone checked for, and not `(fb == 0)` as well. I would have thought the algorithm is not biased towards a or b.
When bracket() is called, it updates either fa or fb with the next value (fc), and when fc is zero then fa is always set to zero, and the result is always a. So checking fb == 0 is unnecessary after a bracket() call.
Indeed, in the last steps from:
https://github.com/boostorg/math/blob/develop/include/boost/math/tools/toms7...,
… both the conditions are checked for,
Somewhat different situation - at this point the loop has terminated, and we're just tightening up our interval in the case that one of a or b is right on the root. This is a nicety not required by the algorithm as such, and indeed the fb == 0 branch *may* be superfluous, but I would want to think very carefully indeed before changing it ;)
Best, John Maddock.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा 𑀰𑁆𑀭𑀻𑀭𑀫𑀡𑀰𑀭𑁆𑀫𑀸
-- Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा 𑀰𑁆𑀭𑀻𑀭𑀫𑀡𑀰𑀭𑁆𑀫𑀸