Mathematica:非交换乘法下的下标简化
在 Mathematica 7.0+ 中使用下标[变量,整数],我有以下形式的表达式:
a_-4 ** b_1 ** a_-4 ** b_-4 ** a_1 ** c_-4 ** c_1 ** c_5
我想简化这个表达式。
规则:
* 具有相同下标的变量不交换,
* 具有不同下标的变量可以交换。
我需要一种方法来简化表达式并组合相似的术语(如果可能);输出应该类似于:
(a_-4)^2 ** b_-4 ** c_-4 ** b_1 ** a_1 ** c_1 ** c_5
我需要的最重要的事情是按下标对表达式中的术语进行排序,同时保留有关哪些通勤和哪些不通勤的规则。 (我想做的)第二件事是在顺序正确后合并相似的术语。我至少需要按以下方式对上面的表达式进行排序:
a_-4 ** a_-4 ** b_-4 ** c_-4 ** b_1 ** a_1 ** c_1 ** c_5,
即交换具有不同下标的变量,同时保留具有相同下标的变量的非通信性质。
欢迎所有想法,谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
前几天我引用了一本图书馆笔记本来回答相关问题。
http://library.wolfram.com/infocenter/Conferences/325/
< a href="https://stackoverflow.com/questions/4974251/how-to-expand-the-arithematics-of- Differential-operators-in-mathematica">如何扩展mathematica中微分运算符的算术
我会抄一些相关的代码。我首先(再次)提到我将定义并使用我自己的非交换运算符,以避免内置 NonCommutativeMultiply 带来的模式匹配问题。另外,我将使用 a[...] 而不是 Subscript[a,...] 以便于使用 ascii 表示法和 Mathematica 输入/输出的剪切粘贴。
我们将某些“基本”实体分类为标量或变量,后者是具有交换限制的事物。我并没有尽可能地考虑这一点,而只是将标量定义为相当明显的“非变量”。
我将使用您的输入表单,只需稍微修改一下,因此我们将转换 ** 表达式以使用 ncTimes。
这是你的例子。
这种看似费力的方法的一个优点是您可以轻松定义换向器。例如,我们已经(隐含地)应用了这一点来制定上述规则。
一般来说,如果您有换向器规则,例如
每当 j > 时, i,那么你可以规范化,比如在所有表达式中将 a[i] 放在 a[j] 之前。为此,您需要修改标记为 (!!!) 的规则以考虑此类换向器。
我应该补充一点,我在任何意义上都没有完全测试上述代码。
丹尼尔·利希布劳
沃尔夫勒姆研究公司
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".
I'll use your input form only slightly modified, so we'll convert ** expressions to use ncTimes instead.
Here is your example.
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.
In general if you have commutator rules such as
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.
Daniel Lichtblau
Wolfram Research
这是您正在寻找的东西吗
这些类型的规则可以概括(例如,为非交换对象添加交换规则,使其处理非数字索引等...)并打包到
NCMSort
例程中。您还可以通过定义唯一的NCMOrder
函数在一次传递中进行排序来优化它,例如旁白:
我在生成 arXiv:1009.3298 的结果时使用了这样的过程 - 笔记本将随(即将发布)更长的论文。
Is this the type of thing you are looking for
These types of rules can be generalised (e.g. add commutation rules for noncommuting objects, make it handle nonnumeric indices, etc...) and packaged up into a
NCMSort
routine. You can also optimize it by doing the sorting in a single pass by defining a uniqueNCMOrder
function, e.g.An aside:
I used such a process in generating the results of arXiv:1009.3298 -- the notebook will be distributed with the (soon to be released) longer paper.
您可以使用 NCAlgebra 做您想做的事情。在您的示例中:
生成
它在这里看起来不太好,但
Subscripts
将在笔记本上很好地呈现。You can do what you want using NCAlgebra. In the case of your example:
produces
It does not look so nice here but
Subscripts
will render nicely on a Notebook.