Hi, I hope Aaron could comment as this concerns the plotting problem he was working on (pull request 696).
So for the last day or so I was trying to understand lambdify. According to the docstring it's used for numeric calculations - that's the whole idea behind translating sympy functions to mpmath, numpy, etc. Also according to the docstring lambdify is used for _fast_ calculations. That's why it's not simply a shortcut for .subs(vars).evalf() which is so much simpler but calls subs on every evaluation. (The guy that has created the plotting module few years ago has some benchmarks on his blog) And it seems that the original idea behind lambdify was to be used in the plotting framework (see the author of the first commit in git log), giving numerical values for the coordinates to be plotted. If I'm incorrect here please correct me. But all this falls apart when I look at the tests: - the most hard for me to understand are the following: 256 f = lambdify(x, x * y) 257 assert f(z) == z * y and 250 f = Lambda(x, exp(-x**2)) 251 l = lambdify(x, Integral(f(x), (x, -oo, oo)), modules="sympy") 252 assert l(x) == Integral(exp(-x**2), (x, -oo, oo)) Why would anyone ever want to do this instead of using a simple python lambda? There is no translation to numpy or other modules. The only thing that can happen is to mix numpy functions with sympy expressions, but why would someone want to do this? An enormous amount of the tests for lambdify show behaviour that _should_ be implemented with python lambda. And that makes lambdify that much harder to implement. Why should lambdify care about lists, tuples, dictionaries and whatnot when even in the docstring it's said that it's used for numeric computation? Or probably I'm simply missing the point of lambdify. Could some one explain it to me? notes: the integral tests comes from this commit: commit 558c862ac98e58a1d27bdc57a777d355cabee28d Author: Ondrej Certik <[email protected]> Date: Sun Mar 29 17:49:24 2009 -0700 Make lambdify() work with Integral but it does not address Sums, Products, any single one quantum expression, etc. Why is integral so special (obviously those were not needed until know, but the proposed solution does not scale at all) -- 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.
