Re: Mathematica: subscript simplification under non-communicative multiplication.

• To: mathgroup at smc.vnet.net
• Subject: [mg116429] Re: Mathematica: subscript simplification under non-communicative multiplication.
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Tue, 15 Feb 2011 06:33:02 -0500 (EST)

```Cantormath wrote:
> Using Subscript[variable, integer] in Mathematica 7.0+, I have
> expressions of the following form:
>
> 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 subscript to don't commute,
> variables with different subscripts do commute.
>
> I need a way to simplify the expression and combine like terms (if
> possible); the output should be something like:
>
> (a_-4)^2 ** b_-4 ** c_-4 ** b_1 ** a_1 ** c_1 ** c_5
>
> The most important thing I need is to order the terms in the
> expression by subscripts while preserving the rules about what
> commutes and what does not. The second thing (I would like) to do is
> to combine like terms once the order is correct. I need to at least
> order expressions like above in the following way:
>
> a_-4 ** a_-4 ** b_-4 ** c_-4 ** b_1 ** a_1 ** c_1 ** c_5,
>
> that is, commute variables with different subscripts while preserving
> the non-communicative nature of variables with the same subscripts.
>
> All Ideas are welcome, thanks.

I cited a library notebook the other day for a related question.

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

How to expand the arithematics of differential operators in mathematica

I'll crib some relevant code. I first mention (again) that I'm going to
define and work with my own noncommutative operator, to avoid pattern
matching headaches from built-in NonCommutativeMultiply. Also I will use
a[...] instead of Subscript[a,...] for ease of ascii notation and
cut-paste of Mathematica input/output.

We will classify certain "basic" entities as scalars or variables, the
latter being the things that have commutation restrictions. I am not
taking this nearly as far as one might go, and am only defining scalars
to be fairly obvious "non-variables".

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'll use your input form only slightly modified, so we'll convert **

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

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]]

define commutators. For example, we already have (implicitly) applied
this one in formulating the rules above.

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

In general if you have commutator rules such as

ncTimes[a[j],a[i]] == ncTimes[a[i],a[i]]+(j-i)a[i]

whenever j>i, then you could canonicalize, say by putting a[i] before
a[j] in all expressions. For this you would need to modify the rule
marked (!!!*) to account for such commutators.

I should add that I have not in any sense fully tested the above code.

Same response (unless I edit it some more) is posted here.

http://stackoverflow.com/questions/4988323/mathematica-subscript-simplification-under-noncommunative-multiplication/4998375#4998375

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Numerical convolution
• Next by Date: Re: k-permutations enumeration
• Previous by thread: Re: Mathematica: subscript simplification under non-communicative multiplication.
• Next by thread: Re: Mathematica: subscript simplification under non-communicative multiplication.