On Mon, Apr 30, 2012 at 9:54 AM, Aaron Meurer <[email protected]> wrote:
> Hi.
>
> Here's what I want to do. I have the semidiscrete free Schrödinger
> equation, I*psi(n, t).diff(t) + (psi(n + 1, t) + psi(n - 1, t) -
> 2*psi(n, t))/h**2 == 0. I want to substitute the particular solution
> psi(n, t) = z**n*exp(-I*omega(z)*t). I can't just use subs, because,
> for example, eq.subs(psi(n, t), z**n*exp(-I*omega(z)*t)) will only
> replace psi(n, t), but not psi(n + 1, t) or psi(n - 1, t). If I had
> first typed def psi(n, t): return z**n*exp(-I*omega(z)*t) and just
> entered the Schrödinger equation, it would work.
This is replace type 1.2 (as described in replace's docstring):
>>> psi=Function('psi') # you have to make this a function (cf issue 1612)
>>> eq= I*psi(n, t).diff(t) + (psi(n + 1, t) + psi(n - 1, t) -
... 2*psi(n, t))/h**2
>>> print filldedent(str(eq.replace(psi, lambda n, t:
>>> z**n*exp(-I*omega(z)*t))))
I*Derivative(z**n*exp(-I*t*omega(z)), t) + (-2*z**n*exp(-I*t*omega(z))
+ z**(n - 1)*exp(-I*t*omega(z)) + z**(n + 1)*exp(-I*t*omega(z)))/h**2
/c
--
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.