Noncommutative Expand over addition in Mathematica

后端 未结 2 1212
北荒
北荒 2021-01-07 08:27

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<

相关标签:
2条回答
  • 2021-01-07 09:01

    The newest version of NCAlgebra supports ReplaceRepeated through NCReplaceRepeated.

    0 讨论(0)
  • 2021-01-07 09:15

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

    From that package:

    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
    
    0 讨论(0)
提交回复
热议问题