boostorg/math

Missing code line?

rp-47 opened this issue · 1 comments

Looking at the code line


and the block following it, I am thinking: Are you missining fmax = fmid; there?

Also, are you sure that the condition

if (max_range_f * min_range_f > 0)

is generally valid and robust? I do get new exceptions because of that. If I ignore them, the root is found as before. (Unfortunately, my solved function can't be easily reproduced for your testing, sorry.)

and the block following it, I am thinking: Are you missining fmax = fmid; there?

No... I think if anything the fmin = fmid in the following block is superfluous: the only thing fmin and fmax are used for within the inner loop of bisection is to check their sign to see which side of the root mid is.

Also, are you sure that the condition
is generally valid and robust? I do get new exceptions because of that. If I ignore them, the root is found as before. (Unfortunately, my solved function can't be easily reproduced for your testing, sorry.)

Generally, I think error handling here is a good thing - if the test fails then the two end points of the range do not bracket the root, so something has clearly gone wrong. It would certainly be useful to have an example in hand to try and see what has gone wrong, I guess there may be some numerical instability in the function being inverted?