I would like to define a translation operator that shifts the arguments of a function. I wrote the following code:
What I want is an operator valued application of the translation operator. I would be glad to receive suggestions to bug-fix the code.
Maybe something like this:
t[a_, b_][f_] := Function[{x, y}, f[x + a, y + b]];
t[1, 2][f]
t[1, 2][Power][x, y]
Thanks for the reply. However that would not work, because when “t[a,b]” acts of “f” there is no operator on the right hand side. What is in my mind is the following (for illustrative purposes for a single coordinate):
T[a] f[x] = f[x+a] T[a]
The original function I wrote kind of works, but I would like to remove the parantheses, e.g. in Out[25], and Flatten the expression. Hence f and g would be multiplied in the end, and there will be the T operator on the right hand side.
You want an operator that acts on functions and gives as a result another operator? What do you expect as the result of this:
op1 = t[a][f[x]];
op1[g[x]]
That is right. The output should be an operator as well. Operator valued operations are used, for example, to calculate the commutator [x, del_x] (which is proportional to [x,p]) in quantum mechanics.
In your example, I would expect the output to be:
f[x+a] g[x+a] t[a]
Best wishes.
Ok, maybe I understood. Here is a way, using a replacement rule that brings external factors into Function:
t[a_, b_][f_[x_, y_]] := f[x + a, y + b] t[a, b][#] &;
incorporateFactor := a_*Function[b_] :> Function[a b];
t[x1, x2][f[a, b]][g[c, d]] /. incorporateFactor
t[x1, x2][f[a, b]][g[c, d]][h[e, f]] //. incorporateFactor
If you are willing to use Unprotect, you may try this way:
t[a_, b_][f_[x_, y_]] := f[x + a, y + b] t[a, b][#] &;
Unprotect[Function];
Function /: a_*Function[b_*t[args__][#]] := Function[a*b*t[args][#]];
t[x1, x2][f[a, b]]
t[x1, x2][f[a, b]][g[c, d]]
t[x1, x2][f[a, b]][g[c, d]][h[e, f]]
That worked for me, thank you very much. Best wishes.
Not sure if this works in your context, but I would probably do something along these lines:
T[a_, b_, c_][f_[x_, y_]] := T[a, b, c*f[x + a, y + b]];
T[a_, b_] := T[a, b, 1]
Demonstration:
T[x, y][f[a, b]]
(* T[x, y, f[a + x, b + y]] *)
T[x, y][f[a, b]][g[c, d]][h[e, f]]
(* T[x, y, f[a + x, b + y] g[c + x, d + y] h[e + x, f + y]] *)
Alternatively, you could try this (so that T[x,y] is more explicit:
T[a_, b_, c_][f_[x_, y_]] := T[a, b, c*f[x + a, y + b]]);
T[a_, b_][f_[x_, y_]] := T[a, b, f[x + a, y + b]*T[a, b]];
T[1, 2][f[a, b]][g[c, d]]
(* T[1, 2, f[1 + a, 2 + b] g[1 + c, 2 + d] T[1, 2]] *)
And actually, there might be some advantages to the following:
T[a_, b_][prev_, f_[x_, y_]] := OperatorApplied[T[a, b], 2][prev*f[x + a, y + b]];
T[a_, b_][f_[x_, y_]] := T[a, b][1, f[x, y]];
T[x, y][f[a, b]][g[c, d]][h[e, f]]
(* OperatorApplied[T[x, y], 2][f[a + x, b + y] g[c + x, d + y] h[e + x, f + y]] *)
This is actually a very neat solution.
As an alternative, I tried using NonCommutativeMultiply with the following rule:
ruleCommute := T[a_, b_] ** f_[x_, y_] :> f[x + a, y + b] ** T[a, b]
However soon it became very cumbersome.