how to define mathematical operators?
- Subject: how to define mathematical operators?
- From: Barton Willis
- Date: Mon, 1 Dec 2008 06:41:54 -0600
-----maxima-bounces at math.utexas.edu wrote: -----
>(%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.
Try using buildq to define H:
(%i3) H(V):= buildq([V], lambda([f],diff(f(x),x)+V*f(x)));
(%o3) H(V):=buildq([V],lambda([f],diff(f(x),x)+V*f(x)))
(%i4) H(W)@lambda([x],%psi(x));
(%o4) %psi(x)*W+'diff(%psi(x),x,1)
The user documentation for buildq has some nice examples.
Barton