Lets suppose I have a family of operators $f_i$, and unknown c-numbers $a,b,c$.
I want to expand such products:
$(f_1+f_2+c)(f_3+f_2+b)$ into $b c+b f_2+b f_1+c f_2+c f_3+f_2^2+f_1 f_2+f_2 f_3+f_1 f_3$.
Equivalently, the action of the product on $x$:
(f1+f2+c)@(f3+f2+b)[x]
should turn into
b*c*x + b*f2[x]+b*f1[x]+c*f2[x]+c*f3[x]+f2@f2[x]+f1@f2[x]+f2@f3[x]+f1@f3[x]
The problem I run into is making Mathematica assume that the symbols $a,b,c$ are numbers and not operators.
EDIT:
1) The operators $f_i$ should act linearly: f[a x]= a f[x]
.
2) Using NonCommutativeMultiply
I have been able to get an expansion of the form:
b*c + b*f2+b*f1+c*f2+c*f3+f2**f2+f1**f2+f2**f3+f1**f3
After using a rule to replace **
with Composition
I get:
b*c + b*f2+b*f1+c*f2+c*f3+Composition[f2,f2]+Composition[f1,f2]+Composition[f2,f3]+Composition[f1,f3]
The problem is that the action of $(3a + 2b \, f1\circ f2)(x)$ on $x$
(3*a + 2*b*Composition[f1,f2])[x] //Through
gives
(3 a)[x] + (2 b Composition[f1, f2])[x]
I have tried multiplying the scalars by Identity
:
(3*a Identity + 2*b*Composition[f1,f2])[x] //Through
But Mathematica still treats (3*a*Identity)[x]
as a function.
What I want to get is this:
3*a*Identity[x] + 2*b*Composition[f1,f2][x]
f1[b x]
in the result instead of what you have. $\endgroup$_
for subscripts. Instead, usef[1][x]
, etc. Maybe you can use this? $\endgroup$f[a x]=a f[x]
. $\endgroup$