On 11/27/08, Jose A. Vallejo <jvallejo at fciencias.uaslp.mx> wrote:
> f -> df/dx+Vf.
> Of course, I could define
> H(V,f):=diff(f(x),x)+V*f(x)
> but this is not what I want. I want to be able to define H(V) and then
> to make it act on a function.
Maybe one of the following does what you want.
H1[V](f) := diff(f(x), x) + V*f(x);
H1[a];
=> lambda([f],'diff(f(x),x,1)+a*f(x))
H1[a](sin);
=> 'diff(sin(x),x,1)+a*sin(x)
%, nouns;
=> a*sin(x)+cos(x)
H1[c](lambda([x], x^5));
=> 'diff(x^5,x,1)+c*x^5
%, nouns;
=> c*x^5+5*x^4
H2(V) := buildq ([V], lambda ([f], diff(f(x), x) + V*f(x)));
H2(b);
=> lambda([f],diff(f(x),x)+b*f(x))
H2(b)(cos);
=> b*cos(x)-sin(x)
H2(d)(lambda([x], x^5));
=> d*x^5+5*x^4
Not sure what you're trying to accomplish, maybe you need to
give an example of how you want this to work.
HTH
Robert Dodier