Skip to content
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

Merged
merged 3 commits into from
Feb 9, 2016

Conversation

person142
Copy link
Member

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 be xtol + 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.

@person142 person142 closed this Dec 4, 2015
@person142 person142 reopened this Dec 4, 2015
@person142
Copy link
Member Author

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

@charris
Copy link
Member

charris commented Dec 4, 2015

Should mention the change in the 0.18 release notes.

@person142
Copy link
Member Author

I made some changes which made the initial commit message inaccurate, so I forced an update. The new commit message explains the changes made.

@person142
Copy link
Member Author

@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.)

@ev-br
Copy link
Member

ev-br commented Dec 30, 2015

…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.
@codecov-io
Copy link

@@            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

Review entire Coverage Diff as of 9c667a9

Powered by Codecov. Updated on successful CI builds.

@dlax dlax added this to the 0.18.0 milestone Feb 9, 2016
@dlax dlax unassigned charris Feb 9, 2016
dlax added a commit that referenced this pull request Feb 9, 2016
BUG: modify optimize.bisect to achieve desired tolerance
@dlax dlax merged commit 48607cf into scipy:master Feb 9, 2016
@person142 person142 deleted the bisect branch March 29, 2016 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

optimize.bisect does not acheive desired tolerance
5 participants