Mathematica:非交换乘法下的下标简化 [英] Mathematica: subscript simplification under noncommutative multiplication

查看:23
本文介绍了Mathematica:非交换乘法下的下标简化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Mathematica 7.0+ 中使用 Subscript[variable, integer],我有以下形式的表达式:

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

我想简化这个表达.

规则:
* 具有相同下标的变量不通勤,
* 具有不同下标的变量可以通勤.

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/

如何展开微分算子的算术运算数学

我会写一些相关的代码.我首先(再次)提到我将定义并使用我自己的非交换运算符,以避免来自内置 NonCommutativeMultiply 的模式匹配问题.此外,我将使用 a[...] 而不是 Subscript[a,...] 以简化 Mathematica 输入/输出的 ascii 符号和剪切粘贴.

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]

我将使用您的输入表单只稍作修改,因此我们会将 ** 表达式转换为使用 ncTimes.

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

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

这种看似费力的方法的一个优点是您可以轻松定义换向器.例如,我们已经(隐式地)在制定上述规则时应用了这一点.

An advantage to this seemingly laborious method is you can readily 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]

每当 j > i 时,您就可以规范化,例如在所有表达式中将 a[i] 放在 a[j] 之前.为此,您需要修改标记为 (!!!) 的规则以考虑此类换向器.

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.

丹尼尔·利希布劳Wolfram 研究

Daniel Lichtblau Wolfram Research

这篇关于Mathematica:非交换乘法下的下标简化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆