Hi, On 9 June 2011 16:05, Tomo Lazovich <[email protected]> wrote:
> Hi everyone, > > I'm thinking of implementing a Wavefunction class in sympy.physics.quantum, > and as a start I'm wondering about functions in sympy in general. Disclaimer > is that this is a potentially very noobish question. > > Is there already a way in sympy to define an arbitrary functional form? > I.e. to be able to easily say something like f(x) = x**2 and then evaluate > f(2) or whatever else you'd like to do. > The simplest way is to use Lambda: In [1]: f = Lambda(x, x**2) In [2]: f(2) Out[2]: 4 You can also define your own (named) function (I mean subclass Function and provide eval() class method), but this may be unnecessary. > Apologies if this is obvious! > > Tomo > > -- > 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. > Mateusz -- 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.
