-
Notifications
You must be signed in to change notification settings - Fork 34
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
Really bad regime selection on quadratic formula #326
Comments
You know, that's pretty interesting and I'll look into it. (Both quadratics are in our nightlies and generally do equally well, but looks like with this seed Herbie didn't find the right branch to add.) |
@msullivan Just to let you know, if you set pre-conditions, it works much better. I limited a, b, and c to go from -1e6 to 1e6, and it gave me much better results, but still not ideal. |
Just checked this. This still happens although rarely. For seeds 0-29 (inclusive), bad regime selection only happens once (seed 12). |
I (independently) tried the -b +sqrt(...) case and got the terrible answer below, three times-- maybe it just cached the answer it already gave me? By the way, the error graph indicates my version and herbie's version are both pretty accurate on ordinary arguments... !? My test cases have a, b and c uniform-random between -10 and +10 (only using cases where the determinant >= 0 and abs(a) > .01). Numerical Recipes in C 2nd Ed. p. 184 has this method:
Here is my input and herbie's output:
|
Interesting. I know that Herbie can produce the NR answer, and in fact usually does so. In the original issue, it does (mostly) find the NR answer, but decides not to use it. This feels like an issue in regimes. I know that I've fixed some regimes bugs recently, but I don't think either of them would fix the original post, or this one. It needs more triage. @bksaiki's seed survey is definitely helpful, we should do more of those for Herbie. |
I tried the web demo out on the two cases of the quadratic formula, and the negative case
(-b - sqrt(b^2 - 4*a*c)) / (2a)
produced this output: https://herbie.uwplse.org/demo/7c3b374107c5177485bdae893a16bc32fd361b84.b7c88a7d879b959f14e63c59c9c933cbdc874ea9/graph.html#reproduceThis features the answer
-0.5 * (2 * (c/b))
(the result of taylor expanding around-inf
) forb < -something*10^-93
. This produces super wrong results for totally normal negative b values (for example, at a=1, b=-1, c=-6, it produces -6 instead of the correct -2).When I tried the positive case, it worked great, splitting into 4 regimes: https://herbie.uwplse.org/demo/500fb1a758f004adc50b440bb74877e556b2c3b7.b7c88a7d879b959f14e63c59c9c933cbdc874ea9/graph.html.
The text was updated successfully, but these errors were encountered: