Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3770 by smi...@gmail.com: nsolve could employ scaling while searching for solution
http://code.google.com/p/sympy/issues/detail?id=3770

mp is a polynomial with large coefficients

print filldedent(mp)

(x - 15)**16 - 22216*(x - 15)**14 + 184230412*(x - 15)**12 -
689044484248*(x - 15)**10 + 1067007063010870*(x - 15)**8 -
385661200155268792*(x - 15)**6 + 35979069569359907692*(x - 15)**4 -
1171725834641905675624*(x - 15)**2 + 11624829278428085430481

It is known to have a root between 100 and 101:

Poly(mp).intervals()[-1][0]
(100, 101)

Although this root can be refined with refine_root,

Poly(mp,x).refine_root(100,101,eps=1e-3)
(9145/91, 9346/93)

we can imagine that mp is an arbitrary function, not necessarily a polynomial. When the bisect method is used with nsolve, and error is raised


nsolve(mp, (100, 101), solver='bisect')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy\solvers\solvers.py", line 2250, in nsolve
    return findroot(f, x0, **kwargs)
  File "sympy\mpmath\calculus\optimization.py", line 972, in findroot
    % (norm(f(*xl))**2, tol))
ValueError: Could not find root within given tolerance. (4.38593e+18 > 2.1684e-19)
Try another starting point or tweak arguments.


If we simply scale by a characteristic magnitude near the root of interest, the solution is found

nsolve(mp/abs(mp.subs(x,100)), (100, 101), solver='bisect')
mpf('100.49450956304526')


==> perhaps nsolve could use some sort of scaling heuristic or (if bisect is only using a function norm, perhaps it could use a norm in x so that if either the value of the function or the uncertainty in the x-value falls below a given value then the solution is returned.

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

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to