Alexey, Robert:
Thank you very much for your responses!! I am very impressed both for
Maxima's capabilities and for your skills with them.
The definition of the @ operator is very close to that of Wolfram's,
although it seems that it does not allow for an arbitrary potential:
(%i1) infix("@");
(%o1) @
(%i2) "@"(f,g):=f(g);
(%o2) f @ g:=f(g)
(%i3) H(V):=lambda([f],diff(f(x),x)+V*f(x));
(%o3) H(V):=lambda([f],diff(f(x),x)+V*f(x))
(%i4) H(W)@lambda([x],%psi(x));
(%o4) %psi(x)*V+'diff(%psi(x),x,1)
Here I would like to see
%psi(x)*W+'diff(%psi(x),x,1)
with W instead of V. The potential V should work as a parameter.
I suppose that it is possible to change slightly the definiton of H to
make it work, but perhaps there is no need for this as Robert's second
construction does exactly what I need:
(%i5) Hamiltonian(V):=buildq([V],lambda([f],diff(f(x),x)+V*f(x)));
(%o5) Hamiltonian(V):=buildq([V],lambda([f],diff(f(x),x)+V*f(x)))
The result is very impressive...
(%i6) Hamiltonian(V[0])(%psi);
(%o6) 'diff(%psi(x),x,1)+V[0]*%psi(x)
(%i7) %psi(x):=exp(%i*k*x);
(%o7) %psi(x):=exp(%i*k*x)
(%i8) Hamiltonian(V[0])(%psi);
(%o8) %i*k*%e^(%i*k*x)+V[0]*%e^(%i*k*x)
(%i9) Hamiltonian(-%omega*x)(%psi);
(%o9) %i*k*%e^(%i*k*x)-%omega*x*%e^(%i*k*x)
Actually, both solutions are of great utility for me (the definiton of
@ is perfect to study compositions of mappings, for example).
As for the question of why to do this: the operator sending a function
f to -df/dx+V.f is, basically, the Schrodinger operator of Quantum
Mechanics for a particle in a potential V (the above expression equated
to zero is Schrodinger's equation). What I'm trying to do is to repeat
certain passages of a popular book on Quantum Mechanics (based on the
use of Mathematica) but using Maxima. The idea is to study the
solutions to Schrodinger's equation with different potentials V. And I
have now a much clearer idea of how to do it, as in the examples above.
Again, thank you both very much!
Jose A.