Help building a matrix-calculus package



>  I don't know how to tell maxima how write rules that extend to N
>  variables. For example:
> (A_1 . A_2 ... A_n)^^-1 = A_n^^-1 ... A_2^^-1 . A_1^^-1

One method is to substitute a lambda form for noncommuting exponentiation: 

 (%i1) ncprod_p(e) := not mapatom(e) and op(e)="."$

 (%i2) nc_subst(e) := subst("^^" = 
    lambda([e,n], if n = -1 and ncprod_p(e) then map(lambda([s], s^^-1), reverse(e)) else e^^n), e);
 (%o2) nc_subst(e):=subst("^^"=lambda([e,n],if n=-1 and ncprod_p(e) then map(lambda([s],s^^(-1)),reverse(e)) else e^^n),e)

 (%i3) nc_subst(%pi * c.(a.b.c)^^-1 . a);
 (%o3) %pi*b^^(-1)

 (%i4) nc_subst((a  * b)^^-1 - (a.b)^^-1);
 (%o4) (a*b)^^(-1)-b^^(-1) . a^^(-1)

Also: Simplification of noncommuting multiplication is controlled by numerous option variables; enter ?? dot.

--Barton