-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
igamma_inv query on double_fp_backend #1231
Conversation
One additional comment: I believe, when iterating for |
Hmm, it might end up being necessary, but I don't really like it, and in any case the root finders should be able to cope with a certain amount of random-fuzz down at the sharp end. We shouldn't really be trying to iterate down to the last epsilon anyway for that very reason. Do you have a test case?
It shouldn't be, the functor should be called exactly once per iteration.
Caching where? |
Consider being in A few lines later, here, is the exact check on 0 that I mention. The test case is shown below for a similar I suppose I might have some extreme edges around max/subnormal that catch the fuzz I'm talking about. The reason why I never converged in my case was that But I was simply wondering if this line would be better with a tolerance instead of zero? The parameter values are having denominator and having denominator TEST CASE:
|
For the That's why I stay in the Halley iteration forever untill It is here, that I keep hitting line 394 and nothing changes. |
OK there's some screwiness happening here... the iteration is actually flip flopping between small positive and small negative steps. I think this should be handled by the convergence check here math/include/boost/math/tools/roots.hpp Line 632 in c5d3666
convergence the expression tools::max_value<T>() * delta2 returns a NaN even though delta2 is tiny (actually the result might be infinite or zero, but never a NaN), so the comparison fails and we end up in the wrong code branch. This is with the cpp_double_fp_backend backend.
|
Many thanks for this sanity check, John.
The least-well-trusted and newest code is the Based on your input, I can see where that thing goes haywire on a NaN. I do not think that the parameter ranges in this calculation should over/underflow. So let me shake this thing out a bit more and see what is exactly going haywire. The goal is to leave Math alone since literally every thing passes there. I do, however, really appreciate your sanity check since I had not seen the NaN thing that you picked up. Did I ever mention, these specfun tests are really good. They really build confidence in your backend impl. These tests alone are worth a lot. Cc: @mborland |
Yeah, it's interesting, they shook out a whole load of bugs in the other multiprecision backends as well when testing: no matter how many tests you think you've devised, just the shear quantity of arithmetic going on finds a whole lot of stuff you would never find otherwise! |
Ah OK. John many thanks as usual. Your detailed NaN detection revealed an error in my backend's When performing I need to perform an alternate scaling or dig up some other kind of multiplication algorithm when the leading LHS is already high enough to overflow when multiplied by the split, yet the expected multiplication result will remain finite in the end. I did a quick fix locally and got the entire |
Clesed as expected. These tests revealed yet another weakness in the fledgling backend code. |
Hi John (@jzmaddock)
This may (hopefully) be my last query on specfun for the newly proposed
cpp_double_fp_backend
.The final problems that the
cpp_double_fp_backend<double>
backend are facing in the specfun test-suite arise in the tests ofigamma_inv
. The Halley-iteration in some (very few like two or three) cases would run and not exit (until max-Halley-iterations was reached and throw). The culprit was the exact floating-point delta-comparison needed for exit condition.In the iteration code, I replaced the exact difference of
(f - p)
with either a relative difference or an exact difference. I do not know why, but thecpp_double_fp_backend
would sometimes have 1-eps or so of convergence fuzz that I could neither explain nor eliminate in two or threeigamma_inv
cases.The one, single change you find proposed in
igamma_inverse.hpp
works around this problem. This change seems somewhat bold to me and I'm not exactly sure why my new double-double backend was experiencing 1-eps fuzz. The change was harmless forcpp_dec_float
andcpp_bin_float
tests locally.And I'm now running this change through Math's CI and requesting your opinion on this change?
Cc: @mborland