Opened 6 years ago

Last modified 7 months ago

#14991 new enhancement

Wrap mpmath's root-finding

Reported by: eviatarbach Owned by:
Priority: major Milestone: sage-wishlist
Component: numerical Keywords: find_root, mpmath
Cc: burcin, fredrik.johansson, mforets, nbruin, ppurka, slelievre Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #13608 Stopgaps:

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.

Change History (6)

comment:1 Changed 5 years ago by ppurka

  • Cc ppurka added

comment:2 Changed 5 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 5 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:4 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:5 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:6 Changed 7 months 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.