On 13 November 2011 21:10, Aaron Meurer <[email protected]> wrote: > On Sat, Nov 12, 2011 at 9:44 AM, [email protected] > <[email protected]> wrote: > > Hi, > > > > I was bashing lambdify lately, but it seems this function is smarter than > > me. I'll skip the details about what I incorrectly thought the problem > was > > and present the real problem. > > > > This works great: > > > > lambdify(x, Integral(y, (y, 0, x))) > > > > _(2) ---> Integral(y, (y, 0, 2)) > > > > float(_) ---> the right numeric answer > > > > This also works great: > > > > lambdify(x, Integral(sqrt(y), (y, 0, x)), modules='sympy') > > > > _(2) ---> Integral(sqrt(y), (y, 0, 2)) > > > > float(_) ---> the right numeric answer > > > > This does not work because sqrt is translated to the numpy function > > > > lambdify(x, Integral(sqrt(y), (y, 0, x))) > > > > _(2) ---> ValueError: Symbolic value, can't compute > > > > Any ideas? That is not a bug a priori but it should at least be very well > > documented. > > That looks like a bug to me. It shouldn't use the numpy sqrt unless > you pass "numpy" as the third argument. > Ok, but if I want to use numpy and sympy (eg np.sqrt(y)*Integral(sympy.sqrt(x))) I can't do it. I would want to do this for fast sqrt outside the integral, and for valid integral expression inside the integral. But now I can not lambdify integrals containing sqrt and at the same time translate the rest of the functions to numpy.
The experimental_lambdify that I wrote fixes this problem by not making translation for arguments of functions if the function itself is not translatable. Integral is not translatable, so only the sqrt outside the integral will be translated. > > Aaron Meurer > > > > > > > P.S. And the docstring should not tell people that lambdify is for > numeric > > calculation when it does not return floats. > > P.P.S The fact that lambdify can not do Sums, stuff from the physics > module, > > etc is another problem. > > > > -- > > 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. > > -- 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.
