Thread Previous • Date Previous • Date Next • Thread Next |
Phil Weir wrote:
The second one allows evaluation of things like sec(pi) by falling over to numericalization (is that a word?) of each argument before passing to eval. This may not work perfectly in every situation (try cos(-1)) but it's progress I think.Just to check, do you get symbolic arguments working OK? e.g. integrate(cos(x), (x,0,1))
No, that says ``cannot create mpf from x'' - which is odd since all symbols in this expression should be sympy ones, so it should never get to the exception. Turning off the mpmath library makes this work. So mpmath's cos is clobbering sympy's cos. I can fix this by changing the def file for cos to have sympy.cos rather than just cos. But is this what we want?
As per http://code.google.com/p/sympy/issues/detail?id=2656 , the sympy function (if one is available) would need to supersede the mpmath function, or catch exceptions, for symbolic manipulations to be handled. If the inclusion into the argument dictionary in Dynamic is reversed (see D.rebuild_globals) this would work, but is there a numerical reason that the mpmath library is preferred when functions are available in both? Or does it improve compatibility and consistency with the other mpmath functions? I'm afraid I'm a bit vague on the sympy core/mpmath differences :s P
The mpmath library should never be preferred if functions are available for both - it should be called as a matter of last resort. That was the aim of the try-except - to convert to numbers any symbol that mpmath didn't like, to allow the calculation to continue. It's a bit of a blunderbuss right now, in that if there's only one bit out of many that mpmath doesn't like, the whole thing is converted. Ideally we should be converting only the symbols that mpmath functions are accessing.
Chris.
Thread Previous • Date Previous • Date Next • Thread Next |