I don't think it's possible to convert a code closure into a symbolic object. Once the lambda is created, we can't know what it does (unless you try to parse the bytecode).
We should be able to sympify the string form of a lambda, but it presently doesn't work. I thought we had an issue for this, but I couldn't find it, so I created http://code.google.com/p/sympy/issues/detail?id=3051. Aaron Meurer On Tue, Jan 10, 2012 at 9:59 AM, [email protected] <[email protected]> wrote: > On related note. Is this a but / missing feature? > > In [69]: sympify(lambda x: x) > SympifyError: SympifyError: "could not parse u'<function <lambda> at > 0x4a4bed8>'" > > > > On 10 January 2012 17:34, [email protected] > <[email protected]> wrote: >> >> The problem of "python functions evaluate immediately sympy functions >> don't" is obvious when one tries to plot/lambdify something that contains >> both Expr and some numerical routine. Try to imagine a way to plot >> nsolve(..)*some_Expr for example. >> >> On 10 January 2012 17:30, [email protected] >> <[email protected]> wrote: >>> >>> Or more likely it's better to use implemented_function that is imported >>> from utilities.lambdify? >>> It seems to me that implemented_function is quite important if one wants >>> for example to have complicated numerical routines accessible as sympy >>> expressions. In my opinion it's actually important enough to be mentioned in >>> the tutorial/pitfalls. Because defining a function to be used in sympy is >>> actually not as simple as defining a python function (python functions >>> evaluate immediately, sympy functions do not). >>> >>> Another question that I need help with is what is Lambda used for. Is >>> there something that Lambda does and implemented_function does not? >>> >>> >>> On 10 January 2012 16:39, [email protected] >>> <[email protected]> wrote: >>>> >>>> How can I represent an unevaluated call to nsolve as a sympy expression? >>>> Is Lambda the best (and standard) solution? >>>> >>>> The expression I want to represent looks like nsolve(x-tanh(x-h),[x],0). >>>> The free symbol is h. It's in the context of plotting phase transition >>>> diagrams. >>> >>> >> > > -- > 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. -- 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.
