Following the MMa's documentations, the ExpandNCM[] function expands a**(b+c) without efforts (although I don't have very good idea how it works). However it got stuck if I tried use it to expand summations of two expressions for example: a1**(b1+c1)+a2**(b2+c2), the output is itself with no expansions. The function is defined below. Please help! Thanks a lot.
ExpandNCM[(h : NonCommutativeMultiply)[a___, b_Plus, c___]] :=
Distribute[h[a, b, c], Plus, h, Plus, ExpandNCM[h[##]] &]
ExpandNCM[(h : NonCommutativeMultiply)[a___, b_Times, c___]] :=
Most[b] ExpandNCM[h[a, Last[b], c]]
ExpandNCM[a_] := ExpandAll[a]
NCAlgebrapackage for non-commutative algebra. I haven't used it yet. – Bruno Le Floch Apr 12 '16 at 15:04