Hi,
I'm currently using Sympy in a small Python script to take a user
input function from the command line and turn it into Python lambda,
like this:
print "Enter f in ∇²u = f (0 for Laplace case). f is a 2D equation
in terms of x and y."
f = simplify(raw_input("f = "))
symbols = f.atoms(Symbol)
x = Symbol("x")
y = Symbol("y")
...
return lambdify((x,y),f.subs({'x':x,'y':y}),"math")
Is there a way to easily, automatically replace reasonable constants,
such as e and pi, with their actual value in the python lambda? Right
now, anything that isn't a number is just a symbol, and I would rather
not have to have a long-ish dictionary in each lambdify.
Likewise, is there an easy way to automatically enable recognition/
functionality of all the functions that Sympy can handle? I tried
playing around with mpmath, but that failed on even simple cases, such
as factorial(x), where the factorial function itself is recognized,
but later on when evaluating that function at a given point, I get a
NameError: global name 'gamma' is not defined issue (I imagine it has
something to do with using the gamma function to evaluate a factorial
for non-natural numbers). Thanks for the help again!
Matt
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---