# Defining a differential operator that acts on a non-commutative basis

Given a non-commutative basis $${x_0,x_1,x_2}$$ I'd like to define a differential operator that acts as so

$$\Delta_i (\sum_{n=0}^\infty c_n x_i^n) = \sum_{n=1}^\infty c_n x_i^{n-1}, \quad \Delta_i x_j = 0 \quad\text{if} \quad i\neq j$$

So if this operator was a "derivative" with respect to $$x_0$$, when it operators on a series in $$x_0$$ it will just reduce the power of $$x_0$$ by one. Furthermore I would like to define it so that it specifically acts from the left, such that if I had a string

$$\Delta_0 (x_0 x_0 x_0 x_1 + x_1 x_0 x_2 x_0 + x_2 x_2 x_1) = x_0 x_0 x_1$$

so if a $$\Delta_0$$ meets anything that isn't $$x_0$$ on the left, it will annihilate it.

To generate the non-commutativity I understand that I can just write out the functions I wish to operate on with ** between basis elements. However I am struggling to figure out a way of writing down an operator that matches the properties that I want, described above.

Any help would be greatly appreciated!

You could start as follows:

ClearAll[Δ]
Δ[HoldPattern[x : Plus[y__]]] := Plus @@ (Δ /@ List[y])
Δ[NonCommutativeMultiply[x0, x_]] := x
Δ[NonCommutativeMultiply[x0, x__]] := NonCommutativeMultiply[x]
Δ[NonCommutativeMultiply[y : Except[x0], x__]] := 0

Δ[x0 ** x0 ** x0 ** x1 + x1 ** x0 ** x2 ** x0 + x2 ** x2 ** x1]


x0 ** x0 ** x1

• Thank you! Is there any way of attaching ordinary commuting coefficients in front without them being affected by the operator?
– Aran
Feb 21, 2019 at 22:46
• That is going to become complicated. The pattern matching needs a way to discern commutative variables from other variables. You may use heads for that. Maybe it helps you to have a look at the Quaternions package (execute << Quaternions; ?? Quaternion). Feb 21, 2019 at 22:52

May I suggest using NCAlgebra? Your functionality with or without commutative coefficients can be obtained using something in the lines of:

SetNonCommutative[x0, x1, x2]
expr1 = x0^3 ** x1 + x1 ** x0 ** x2 ** x0 + x2^2 ** x1
expr2 = 2 x0^3 ** x1 + 3 x1 ** x0 ** x2 ** x0 + 4 x2^2 ** x1


to define your text expressions and a combination of our directional derivative NCDirectionalD with rules as in:

SNC[h0]
NCReplaceAll[NCDirectionalD[expr1, {x0, h0}], {x_ ** h0 ** y___ -> 0, h0 -> 1}]
(* x0 ** x0 ** x1 *)
NCReplaceAll[NCDirectionalD[expr2, {x0, h0}], {x_ ** h0 ** y___ -> 0, h0 -> 1}]
(* 2 x0 ** x0 ** x1 *)
`