On 6 Aug., 19:57, smichr <[email protected]> wrote: > On Aug 5, 9:29 pm, Vinzent Steinberg > > <[email protected]> wrote: > > On Aug 2, 12:14 am, smichr <[email protected]> wrote: > > > > >>> num,den = (1/(.001+a)**3-6/(.9-a)**3).as_numer_denom() > > > >>> nsolve(num,a,.3) # no need for sympy now > > > Maybe solve()/nsolve() should do this for you. What do you think? > > > Vinzent > > I was thinking the same thing, but you would have to watch out that > you didn't introduce spurious roots: e.g. > > >>> (x/(x-1)).diff(x) > > -1/(1 - x) - x/(1 - x)**2>>> n,d=_.as_numer_denom();n/d > > (-x*(1 - x) - (1 - x)**2)/(1 - x)**3 > > Unless we cancel out the common factors (something that isn't working > in general yet but will hopefully work with the new polys module) we > will get a root of x=1.
It should be easy to check for false roots numerically, but yeah, it has to be implemented. > I was also wondering if the routine shouldn't > try to solve the expression symbolically to see if it's possible > before trying to solve it numerically...or should sympy just trust the > user and not waste the time checking symbolic solutions if a numeric > solution has been requested? It would do it this way: The user wants to solve() an equation, if we can't do it symbolically, we return an instance of RootOf(), which can be evalf()'ed to get a numerical approximation. nsolve() should solve it always numerically, possibly doing some symbolic optimizations, which can be disabled. BTW: It's now fixed to find the root of 1/(0.001+a)**3-6/(0.9-a)**3. Vinzent Vinzent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
