Here is something which might help you get started.
Define a new symbolic matrix type in maxima.
(%i1) declare(sym_matrix, feature);
(%o1) done
This shows how to define A to be a symbolic matrix.
(%i2) declare(A, sym_matrix);
(%o2) done
(%i3) featurep(A, sym_matrix);
(%o3) true
(%i4) sym_matrixp(A) := featurep(A, sym_matrix);
(%o4) sym_matrixp(A):=featurep(A,sym_matrix)
Use rules to define relations.
A and B will match symbolic matrices (B comes before A in internal ordering).
(%i5) matchdeclare(A, sym_matrixp, B, lambda([u], sym_matrixp(u) and
orderlessp(u,A)));
(%o5) done
(%i6) declare(tr, linear);
(%o6) done
(%i7) tellsimpafter(tr(A.B), tr(B.A));
(%o7) [trrule1,simpargs1]
Example for x and y.
(%i8) declare([x,y], sym_matrix);
(%o8) done
(%i9) tr(x.y);
(%o9) tr(x . y)
(%i10) tr(y.x);
(%o10) tr(x . y)
(%i11) tr(x.y + y.x);
(%o11) 2*tr(x . y)
The x^^0 rule is a bit tricky - you need to disable the default simplification.
(%i15) x^^0;
(%o15) 1
(%i16) block([simp:false], tellsimp(A^^0, I));
(%o16) [^^rule1,simpncexpt]
(%i17) x^^0;
(%o17) I
(%i18) tellsimpafter(A.I, A);
(%o18) [.rule1,simpnct]
(%i19) x.I;
(%o19) x
The rule only works for symbolic matrices.
(%i20) k^^0;
(%o20) 1
Andrej
On Fri, Feb 27, 2009 at 8:25 PM, Paulo Grahl <pgrahl at gmail.com> wrote:
> Dear list members:
> I need some advice on how to implement some symbolic calculations with matrices.
> For example, let's say I declare F and G as matrices. (nonscalar)
> Then I am interested in, for example, simplifying tr(F.G+G.F) to
> 2*tr(F.G), where "tr" is declared as a linear function (matrix trace).
> I would also be interested in obtaining differentials of the form
> dF^^-1 = -F^^-1.dF.F^^-1 (provided the inverse exists)
> or
> d ln |F| = tr(F^^-1 dF)
> or
> d tr(F) = tr(dF)
> or
> ?declaring a symbolic identity matrix "I" and making sure F.I=F, ?F^^0=I, etc.
>
> among others.
>
> Is there a symbolic matrix package where one could implement such rules ?
> I have already looked into Richard Fateman's excellent article
> "Manipulation of Matrices Symbolically", but that is much more general
> that what I need. In my case all matrices are square, with same nxn
> dimension, the inverses are assumed to exist, etc.
>
> Any help is appreciated.
> best
> Paulo
>
>
> Paulo Gustavo Grahl, CFA
> ------------------------------------------
> pgrahl at gmail.com
> pgrahl at fgvmail.br
> +55(21) 8809-9254
> www.linkedin.com/in/pgrahl
> ------------------------------------------
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>