Just for reference, this is what exists so far of the Wavefunction class. It
also has some doctests so you can see the usage.

https://github.com/lazovich/sympy/blob/c9a3ceb0d1addd9c89c30b90cbe0e55c9467fe0a/sympy/physics/quantum/state.py#L521

On Sun, Jun 12, 2011 at 7:25 PM, Aaron Meurer <[email protected]> wrote:

> I think it will be cleaner to make it a class, even with the little
> you are doing.  Note that if you just want something to return some
> expression (i.e., eval() would always return something), you could
> just use a Python function.
>
> By the way, Lambda really shouldn't even be in consideration.   If you
> are naming something, that's a sign that you shouldn't use Lambda.
> It's similar with Python's lambda.  You would never do
>
> mul = lambda x, y: x*y
>
> instead of
>
> def mul(x, y):
>    return x*y
>
> Aaron Meurer
>
> On Sun, Jun 12, 2011 at 4:21 PM, Tomo Lazovich <[email protected]>
> wrote:
> > I think Wavefunction applies more to the latter case, where there's a
> known
> > function that we want to return. I sort of saw it as more of a
> convenience
> > than anything else. For one, returning the expression itself, like
> > sin(n*pi*x/L), means that if you want to actually evaluate it at a point
> you
> > have to use subs() (which I guess is not too bad, but its a little less
> > intuitive than simply getting the function and being able to call
> psi(2)).
> > It also can provide some basic helper functions for calculating
> > probabilities (f*conjugate(f)) or normalization constants. The final
> reason
> > I had is that it ended up making DifferentialOperator quite simple...as
> > simple as defining an _apply_operator_Wavefunction function (though I
> guess
> > it's just as simple to write _apply_operator_Function or
> > _apply_operator_Lambda). I can go either way on this.
> >
> > Tomo
> >
> > On Sun, Jun 12, 2011 at 4:29 PM, Brian Granger <[email protected]>
> wrote:
> >>
> >> I am -1 on having a Wavefunction class.  The reason is that a
> >> wavefunction is just a plain old function.  There is no additional
> >> logic needed over a regular function.  But I want to understand what
> >> you are using these functions for.  I can think of two types of
> >> functions needed in quantum:
> >>
> >> * An undefined function for use in representing an unknown or abstract
> >> state:  <x|psi> => psi(x).  For this I would just use
> >> Function('psi')('x').  The name of the state (psi) can just be used
> >> for the name of the function.
> >> * A function for a known quantum state like the particle in a box.
> >> For this case, we should just return the special function, such as
> >> sin(n*pi*x/L), etc.
> >>
> >> Can you clarify how the functions you are using relate to these two
> cases?
> >>
> >> Cheers,
> >>
> >> Brian
> >>
> >> On Sat, Jun 11, 2011 at 2:56 PM, Tomo Lazovich <
> [email protected]>
> >> wrote:
> >> > Lambda seems to work for me except for one thing.
> >> >
> >> > I have a class Wavefunction for representations of states in
> continuous
> >> > bases. It subclasses Lambda and provides some additional convenience
> >> > functions. One thing it would like to do internally is calculate
> >> > self.expr*conjugate(self.expr). I've found, however, that because the
> >> > Lambda
> >> > uses dummy variables internally, even if I initialize the function
> with
> >> > a
> >> > symbol set to real=True, that doesn't carry over to the internal
> >> > expression
> >> > and so the conjugate isn't very well simplified. Is there a way to get
> >> > around this?
> >> >
> >> > Thanks!
> >> >
> >> > On Fri, Jun 10, 2011 at 9:19 PM, Aaron Meurer <[email protected]>
> >> > wrote:
> >> >>
> >> >> If you just want a placeholder to keep args, use UndefinedFunction.
> >> >> If you want it to have any more advanced functionality at all, create
> >> >> a subclass of Function.  I admit I don't know anything at all about
> >> >> what you are doing, but it's very likely that the case is the latter.
> >> >>
> >> >> Aaron Meurer
> >> >>
> >> >> On Fri, Jun 10, 2011 at 5:08 PM, Vinzent Steinberg
> >> >> <[email protected]> wrote:
> >> >> > On 10 Jun., 02:08, Brian Granger <[email protected]> wrote:
> >> >> >> Definitely use the existing Function stuff in sympy.  I am not
> sure
> >> >> >> you will even have to subclass to do this.
> >> >> >
> >> >> > There is also UndefinedFunction (BTW, I think we should rename it
> to
> >> >> > AbstractFunction or similar) if you want a rather abstract
> function.
> >> >> > If you want to implement something like sin, you should probably
> use
> >> >> > Function.
> >> >> >
> >> >> > Vinzent
> >> >> >
> >> >> > --
> >> >> > 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.
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Tomo Lazovich
> >> > Harvard College '11
> >> > 278 Winthrop House Mail Center
> >> > Cambridge, MA 02138
> >> >
> >> > --
> >> > 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.
> >> >
> >>
> >>
> >>
> >> --
> >> Brian E. Granger
> >> Cal Poly State University, San Luis Obispo
> >> [email protected] and [email protected]
> >>
> >> --
> >> 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.
> >>
> >
> >
> >
> > --
> > Tomo Lazovich
> > Harvard College '11
> > 278 Winthrop House Mail Center
> > Cambridge, MA 02138
> >
> > --
> > 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.
>
>


-- 
Tomo Lazovich
Harvard College '11
278 Winthrop House Mail Center
Cambridge, MA 02138

-- 
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.

Reply via email to