SymPy: How do I create symbolic lambda function?

Viewed 391

For example I have this expression:

x = Symbol('x')
f = sin(x) * x

I want the following code to work:

>>> a = Symbol('a')
>>> f(a)
TypeError: 'Mul' object is not callable

I can turn this expression into a lambda function that will work with numbers:

>>> f = lambdify(x, f)
>>> f(10)
-5.440211108893697

But it is not worked for symbols:

>>> f = lambdify(x, f)
>>> f(a)
TypeError: loop of ufunc does not support argument 0 of type Symbol which has no callable sin method

I know about the *.subs method, but I'm interested in the this notation:

>>> a = Symbol('a')
>>> f(a)

How to do it?

0 Answers
Related