Take the 2-minute tour ×

I would like to construct an operator in Mathematica of the following form,

$$D_i=\partial_i +\sum_{i \neq j}^n\frac{1}{x_i-x_j}p_{ij}, \quad i=1,...,n$$

where $p_{ij}$ is a (symmetric) permutation operator and does not commute with the $x_i$ and $\partial_i$,

$$p_{ij}x_i=x_jp_{ij}, \quad p_{ij}\partial_i=\partial_j p_{ij}, \quad p_{ij}^2=1$$

I was trying using the NCAlgebra package, making all the operators non-commutative and defining the proper rules, but the result is far to be efficient when many operators (for instance $D_i^6$ ) are applied. The most efficient way I have found is to try to push always the permutation operator to the right and behind the derivatives. The problem appears when some properties of the powers and derivatives of the functions $\frac{1}{x_i-x_j}$ are not simplified when are defined as non-commutative objects and also that for large powers of the operator the number of terms heavily increases.

But maybe the NCAlgebra package is not longer needed, and such operator can be defined in the normal Mathematica environment

Thanks in advance!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If I understand the question correctly, you want an operator like this:

ClearAll[x, dOp];

dOp[i_, n_] = Function[{f}, D[f, x[i]] + Sum[
     1/(x[i] - x[j]) Permute[f, Cycles[{{i, j}}]], {j, 
      Drop[Range[n], {i}]}

dOp[2, 3][f[x[1], x[2], x[3]]]

$$f^{(0,1,0)}(x(1),x(2),x(3))+\frac{f(x(1),x(3),x(2))}{x(2)-x(3)} +\frac{f(x(2),x(1),x(3))}{x(2)-x(1)}$$

Here, I assume the dimension is $n = 3$, and the variables are named x[i]. The operator is defined as a Function that can act on a symbolic function f[x[1], x[2], x[3]] and performs the differentiation and the sum as indicated. The limitation in Mathematica in terms of symbolics is that the dimension n has to be provided as a numerical parameter. So the operator dOp defining your $D_i$ takes both the coordinate index i and the dimension n as arguments.

Since x is used as a symbol for the coordinates, you have to make sure it's cleared before doing the calculations.

When defining operators explicitly in this way, you can prove relationships by applying them to test functions f and using Simplify. See also this link.


There is an ambiguity in how the permutation operator should act: swap the slots of the function or literally swap $x_i \leftrightarrow x_j$. Looking at the definitions in the post, I think we need to use the latter (but I'll leave my frist version up in case it's what you want), which would have to be implemented a little differently:

     1/(x[i] - x[j]) (f /. {x[i] -> x[j], x[j] -> x[i]}), {j, 
      Drop[Range[n], {i}]}

It gives the same result in the above case, but not in general.

To get powers of the operator, $D_i^\nu$, you would apply it in the form of a composition, as in dOp[1,2][dOp[2,3][f[x[1],x[2],x[3]]]].

share|improve this answer
Hi Jens, I really appreciate your help and your quick answer. As far I have verified with many examples your last code works flawlessly doing exactly what I wanted. I also learned the advantages of use the Function command. Then I needed to make the functions symmetric again, I couldn't find a way to symmetrize the derivatives of the function quickly [for just the function it is possible to use SetAtrributes- > Orderless], but finally I make it manually, with replacements formulaes. Thanks again! –  moroder Jul 24 '13 at 10:19

Your Answer


