Mathematics: Substring Simplification for Noncommutative Multiplication

Using the subscript [variable, integer] in Mathematica 7.0+, I have expressions like this:

a_-4 ** b_1 ** a_-4 ** b_-4 ** a_1 ** c_-4 ** c_1 ** c_5 

I would like to simplify this expression.

Rules:
* Variables with the same index do not commute,
* variables with different indices commute.

I need a way to simplify the expression and combine as terms (if possible); the output should look something like this:

 (a_-4)^2 ** b_-4 ** c_-4 ** b_1 ** a_1 ** c_1 ** c_5 

The most important thing I need is to arrange the terms in the expression by index, keeping the rules about what commutes and what doesn't. The second thing I would like to do is combine as terms as soon as the order is correct. I need to at least arrange the expressions as above, as follows:

 a_-4 ** a_-4 ** b_-4 ** c_-4 ** b_1 ** a_1 ** c_1 ** c_5, 

that is, commuting variables with different indices, preserving the non-communicative nature of variables with the same indices.

Any ideas are welcome, thanks.

+1
source share
3 answers

This is the type of thing you are looking for

Sort

These types of rules can be generalized (for example, add switching rules for non-switching objects, force them to process odd indices, etc.) and are packaged in the NCMSort routine. You can also optimize it by sorting in one pass by defining a unique NCMOrder function, for example.

 NCMSort[expr_] := expr /. a_NonCommutativeMultiply :> a[[NCMOrder[a]]] 

Aside: I used this process to generate arXiv results : 1009.3298 - the laptop will be distributed with (soon to be released) longer paper.

+2
source

The other day, I brought a notebook of a library on a related issue.

http://library.wolfram.com/infocenter/Conferences/325/

How to extend the arithmetic of differential operators in mathematics

I will take the appropriate code. First I mention (again) that I will define and work with my own non-commutative operator to avoid matching headaches with the built-in NonCommutativeMultiply. In addition, I will use [...] instead of the subscript [a, ...] to simplify the writing of ascii and cutting out the Mathematica insert / exit.

We will classify certain β€œbasic” entities as scalars or variables, the latter are things that have commutation restrictions. I do not take it almost as far as it would be possible, and I only define scalars to be obvious enough "unchangeable".

 variableQ[x_] := MemberQ[{a, b, c, d}, Head[x]] scalarQ[x_?NumericQ] := True scalarQ[x_[a_]^n_. /; !variableQ[x[a]]] := True scalarQ[_] := False ncTimes[] := 1 ncTimes[a_] := a ncTimes[a___, ncTimes[b___, c___], d___] := ncTimes[a, b, c, d] ncTimes[a___, x_ + y_, b___] := ncTimes[a, x, b] + ncTimes[a, y, b] ncTimes[a___, n_?scalarQ*c_, b___] := n*ncTimes[a, c, b] ncTimes[a___, n_?scalarQ, b___] := n*ncTimes[a, b] ncTimes[a___, x_[i_Integer]^m_., x_[i_]^n_., b___] /; variableQ[x[i]] := ncTimes[a, x[i]^(m + n), b] ncTimes[a___, x_[i_Integer]^m_., y_[j_Integer]^n_., b___] /; variableQ[x[i]] && ! OrderedQ[{x, y}] := (* !!! *) ncTimes[a, y[j]^n, x[i]^m, b] 

I will use your input form, only slightly modified, so we will convert ** expressions to use ncTimes.

 Unprotect[NonCommutativeMultiply]; NonCommutativeMultiply[a___] := ncTimes[a] 

Here is your example.

 In[124]:= a[-4] ** b[1] ** a[-4] ** b[-4] ** a[1] ** c[-4] ** c[1] ** c[5] Out[124]= ncTimes[a[-4]^2, a[1], b[1], b[-4], c[-4], c[1], c[5]] 

The advantage of this seemingly time-consuming method is that you can easily identify switches. For example, we have already (implicitly) applied this when formulating the above rules.

 commutator[x_[a_], y_[b_]] /; x =!= y || !VariableQ[x[a] := 0 

In general, if you have switching rules, such as

 ncTimes[a[j],a[i]] == ncTimes[a[i],a[i]]+(ji)*a[i] 

whenever j> i, you can canonicalize, say, by putting [i] before [j] in all expressions. To do this, you will need to change the rule marked (!!!) to account for such switches.

I must add that in no sense have I fully tested the above code.

Daniel Lichtblow Wolfram Research

+2
source

You can do what you want using NCAlgebra . In the case of your example:

 << NC` << NCAlgebra` expr = Subscript[a, -4] ** Subscript[b, 1] ** Subscript[a, -4] ** Subscript[b, -4] ** Subscript[a, 1] ** Subscript[c, -4] ** Subscript[c, 1] ** Subscript[c, 5] rule = {(Subscript[x_, i_] ** Subscript[y_, j_] /; i > j) -> Subscript[y, j] ** Subscript[x, i]}NCReplaceRepeated[expr, rule] NCReplaceRepeated[expr, rule] 

produces

 Subscript[a, -4] ** Subscript[a, -4] ** Subscript[b, -4] ** Subscript[c, -4] ** Subscript[b, 1] ** Subscript[a, 1] ** Subscript[c, 1] ** Subscript[c, 5] 

It doesn't look so good here, but Subscripts will render well on a laptop.

0
source

All Articles