Opened 8 years ago

# Wrap mpmath's root-finding

Reported by: Owned by: eviatarbach major sage-wishlist numerical find_root, mpmath burcin, fredrik.johansson, mforets, nbruin, ppurka, slelievre N/A #13608

### Description

Sage should wrap mpmath's root-finding; it has many algorithms available, arbitrary precision, and support for complex roots, none of which the current `find_root` appears to have.

### comment:1 Changed 7 years ago by ppurka

• Cc ppurka added

### comment:2 Changed 7 years ago by ppurka

• Dependencies set to #13608

This depends on #13608 for it to be of any use. Because of this default behavior:

```sage: from mpmath import findroot
sage: f(x) = log(x+2) - x
sage: findroot(f, (0, 0.5))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-90ff3b38dfea> in <module>()
----> 1 findroot(f, (Integer(0), RealNumber('0.5')))

/home/punarbasu/tmp/sage/local/lib/python2.7/site-packages/mpmath/calculus/optimization.pyc in findroot(ctx, f, x0, solver, tol, verbose, verify, **kwargs)
926             multidimensional = isinstance(fx, (list, tuple, ctx.matrix))
927         except TypeError:
--> 928             fx = f(x0[0])
929             multidimensional = False
930         if 'multidimensional' in kwargs:

/home/punarbasu/tmp/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.__call__ (sage/symbolic/expression.cpp:20616)()

/home/punarbasu/tmp/sage/local/lib/python2.7/site-packages/sage/symbolic/callable.pyc in _call_element_(self, _the_element, *args, **kwds)
475         d = dict(zip(map(repr, self.arguments()), args))
476         d.update(kwds)
--> 477         return SR(_the_element.substitute(**d))
478
479

/home/punarbasu/tmp/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.substitute (sage/symbolic/expression.cpp:19871)()

/home/punarbasu/tmp/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.coerce_in (sage/symbolic/expression.cpp:14074)()

/home/punarbasu/tmp/sage/local/lib/python2.7/site-packages/sage/structure/parent_old.so in sage.structure.parent_old.Parent._coerce_ (sage/structure/parent_old.c:3909)()

/home/punarbasu/tmp/sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.coerce (sage/structure/parent.c:9544)()

TypeError: no canonical coercion from <type 'sage.libs.mpmath.ext_main.mpf'> to Callable function ring with arguments (x,)
sage:
```

### comment:3 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

### comment:4 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

### comment:5 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4

### comment:6 Changed 2 years ago by slelievre

• Cc fredrik.johansson mforets nbruin slelievre added
• Keywords find_root mpmath added
• Milestone changed from sage-6.4 to sage-wishlist
Note: See TracTickets for help on using tickets.