Vinzent Steinberg wrote: > On May 16, 10:25 pm, Ondrej Certik <ond...@certik.cz > <mailto:ond...@certik.cz>> wrote: > > > > Just pull my branch and run tests. Then change the findroot code and > you'll see. > > > > Ondrej > > This is interesting. The secant method (used by default by findroot()) > needs two starting values. If the user specifies only one value x, the > second is automatically x + 0.25. Due to this, it sometimes did not > find the correct root. You just found a case where this happens. :) > The easiest solution is to use (x, x + 0.01) instead of x as a > starting point. Maybe Newton's method should be implemented in mpmath. > I thought secant would be superior in any case, so I didn't do so... > Or maybe we should choose a more sane default starting point for secant. > > I attached a patch which fixes the issues with findroot in this case. > If you want to play around with it, uncomment the debug print > statements, it compares findroot's solution with scipy's. > > Vinzent > > > A standard technique is to search by halves until you get an interval you know you have a root in and switch to the secant, newton, or some higher order method to polish the root. Secant might fail if there are multiple roots in the interval determines by searching by halves, but you will know immediately if that happens if any step of the secant method goes outside the search by halves interval.
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---