Issue 233 in mpmath: bisect fails if root is at midpoint of initial range

5 views
Skip to first unread message

mpm...@googlecode.com

unread,
Jan 23, 2013, 11:35:44 PM1/23/13
to mpmath...@googlegroups.com
Status: New
Owner: ----

New issue 233 by smi...@gmail.com: bisect fails if root is at midpoint of
initial range
http://code.google.com/p/mpmath/issues/detail?id=233

What steps will reproduce the problem?
1. findroot(x**2-1,(0,2),solver='bisect')

What is the expected output? What do you see instead?
mpf('1.0')

The following patch will fix the problem. Illinois and Ridder already
detect "flat functions" and return in this situation so it's not a problem
for them. An alternative to the patch below is just to make Bisection
return in the same way as Illinois and Ridder.

--- a/sympy/mpmath/calculus/optimization.py
+++ b/sympy/mpmath/calculus/optimization.py
@@ -320,11 +320,14 @@ def __iter__(self):
while True:
m = self.ctx.ldexp(a + b, -1)
fm = f(m)
- if fm * fb < 0:
+ sign = fm * fb
+ if sign < 0:
a = m
- else:
+ elif sign > 0:
b = m
fb = fm
+ else:
+ yield m, 0
l /= 2
yield (a + b)/2, abs(l)


mpm...@googlecode.com

unread,
Apr 25, 2013, 1:28:52 PM4/25/13
to mpmath...@googlegroups.com
Updates:
Status: Fixed

Comment #1 on issue 233 by fredrik....@gmail.com: bisect fails if root is
Fixed in
https://github.com/fredrik-johansson/mpmath/commit/316f8bf9c7c1a03b7357696f6bb639783704a7d5

Thanks!

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages