-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
find_root() is broken when interval borders cannot be evaluated #4942
Comments
comment:3
This is a critical bug and ought to be fixed in 3.3. Note that #3870 might be a dupe of this bug. Cheers, Michael |
comment:4
It seems this is a problem with Scipy:
|
comment:5
There are at least a couple of issues here. First, brentq is a variant of a bisection-based solver; if you use any bisection-based solver to find a zero of 1/(x-1) between 0 and 2, it will narrow down and return something very close to 1. So if we don't like that, we should use a different solver (or at least try to check the output; for instance, a simple check that f(x) is "small" would detect this particular problem). Second, find_root tries to verify that the function evaluates to different signs at the endpoints of the interval (as required by brentq); but it doesn't check the function evaluation results for NaN. In the original test case, fast_float(f)(0) gives NaN. |
comment:6
Better luck in 3.4.1. Unfortunately this either requires testing of the result of scipy or some deeper surgery in Scipy. Cheers, Michael |
comment:7
If we've released for months and months without fixing this, it doesn't make sense to keep it as a blocker. |
Stopgaps: #12709 |
Author: Eran Assaf |
Commit: |
comment:15
Hi, added two small validity checks:
New commits:
|
comment:17
I am not sure 1 is necessarily the best solution to this because what if you get a function that always evaluates to NaN as you increase/decrease the endpoints? For instance
will be NaN for infinitely many values. So your current test means this runs forever:
(before it simply gave a wrong value). Also, I think for 2 you should raise a |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:20
Fixed the bugs and changed behaviour in both cases, as suggested by tscrim |
Reviewer: Travis Scrimshaw |
comment:21
Thanks. Looks better now. A few more little things:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:23
Thank you. LGTM. |
Changed branch from u/assaferan/find_root___is_broken_when_interval_borders_cannot_be_evaluated to |
Reported in http://groups.google.com/group/sage-support/browse_thread/thread/40da8039090c3e8a
But note the following:
Cheers,
Michael
CC: @kcrisman
Component: numerical
Stopgaps: #12709
Author: Eran Assaf
Branch/Commit:
e6b7c1e
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/4942
The text was updated successfully, but these errors were encountered: