本文介绍了Mathematica 中的非交换扩展超过加法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个函数来完全扩展非交换乘法而不是加法?
例如:
a ** (b + c^2)将扩展为
a ** b + a ** c^2
同样从右边开始.

I need to write a function(s) that completely expands noncommutative multiplication over addition?
For example:
a ** (b + c^2)would expand to
a ** b + a ** c^2
and similarly from the right.

我正在使用 ReplaceRepeated (.//).由于我使用的是 NonCommutativeMultiply 而不是 Times,因此 Expand 不起作用.我正在使用具有 NCExpand 的 NCAlgebra 包,但是在使用此包时 ReplaceRepeated 不起作用(如 NCAlgebra 文档中所述...argh).

I am using ReplaceRepeated (.//). Since I am using NonCommutativeMultiply instead of Times, Expand does not work. I was using the NCAlgebra package which has NCExpand, however ReplaceRepeated does not work when using this package (as stated in the NCAlgebra documentation...argh).

为了避免破坏 ReplaceRepeated ,我需要编写我自己的不会发生冲突的 NCExpand 代码.

To avoid breaking ReplaceRepeated , I need to code my own NCExpand that is not going to conflict.

欢迎所有想法,谢谢...

All ideas are welcome, thanks...

推荐答案

尝试 this 包,其中包括非交换扩展以及为 NC 计算重写的其他函数.

Try this package which includes a noncommutative Expand as well as other functions rewritten for NC calculations.

来自那个包:

GExpand[a_, patt___] := Expand[a //. {x_NonCommutativeMultiply :> Distribute[x]}, patt];

In[1]  := GExpand[a ** (b + c^2)]
Out[1] := a ** b + a ** c^2

In[2]  := GExpand[a ** (b + c^2)] //. a -> foo
Out[2] := foo ** b + foo ** c^2

这篇关于Mathematica 中的非交换扩展超过加法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 01:14