-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
BUG: modify optimize.bisect to achieve desired tolerance #5557
Conversation
Realized that I forgot to change the documentation; will fix this later today. |
@@ -3,14 +3,14 @@ | |||
#include <math.h> | |||
#include "zeros.h" | |||
|
|||
#define MIN(a, b) ((a) < (b) ? (a) : (b)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used?
Should mention the change in the 0.18 release notes. |
I made some changes which made the initial commit message inaccurate, so I forced an update. The new commit message explains the changes made. |
@charris: it looks like the 0.18 release notes haven't been created yet. Is there someone I should ask about creating them? (It seems like the sort of thing I shouldn't do myself.) |
…rance Given an initial interval [a, b], an absolute tolerance xtol, and a relative tolerance rtol, the methods currently achieve the following tolerances: - bisect, ridder: |x - x0| < xtol + rtol (|a| + |b|) - brentq, brenth: |x - x0| < 2(xtol + rtol |x0|). Here x0 is the computed root and x is the exact root. This commit changes the functions so that they all achieve a tolerance of |x - x0| < xtol + rtol |x0|; in other words they should satisfy ``np.allclose(x, x0, atol=xtol, rtol=rtol)``. It also changes the tests to check for this criterion and documents the tolerance used. Closes scipygh-5555.
@@ master #5557 diff @@
======================================
Files 234 234
Stmts 43122 43122
Branches 8157 8157
Methods 0 0
======================================
+ Hit 33426 33428 +2
+ Partial 2605 2604 -1
+ Missed 7091 7090 -1
|
BUG: modify optimize.bisect to achieve desired tolerance
The functions optimize.{brentq, brenth, ridder} all achieve a tolerance of
xtol + rtol*res
, where xtol is the absolute tolerance, rtol is the relative tolerance, and res is the computed root. The function optimize.bisect, on the other hand, does not achieve this tolerance because the routine fixes the tolerance to bextol + rtol*(|a| + |b|)
, where [a, b] is the initial interval. This pull request modifies optimize.bisect to update the tolerance along with improved guesses for res so that it achieves the same tolerance as optimize.{brentq, brenth, ridder}. Closes gh-5555.