defrule extraction of scalars from symbolic matrix trace



There's no way to apply a user-defined rule to a function with a
variable number of arguments.
There is some code (PART+ and PART*) which handles "+" and "*" separately
from other operators. I've often thought about generalizing that so
it could have other n-ary and/or commutative operators,
but haven't made any progress on it.

At this point I think the only solution is to write a
simplification function in Lisp.

best, Robert Dodier

On 11/30/10, Edwin Woollett <woollett at charter.net> wrote:
> If the symbolic matrix trace has the notation
> tr (mu, a*nu,rh,b*la,....) with (mu,nu,rh,la,..)
> declared nonscalars and (a,b,c,d,...) declared
> scalars, I would like to pull out all scalars so
> that the above becomes
>   a*b*tr (mu,nu,rh,la,...),
>
> and, of course, tr (a*mu) --> a*tr(mu).
> I have tried pulling out scalars using an adaptation
> of Robert Dodier's defrule method in commutators.mac
> but eventually I have the problem that the number of
> args of tr is arbitrary ( >=1).
>
> So I am looking for a way of dealing with such arbitrariness.
> So far, I have the code:
> --------------------------------------
> load (multiadditive)$
>
> declare(tr, multiadditive);
>
> matchdeclare (aa, scalarp);
> matchdeclare (bb, nonscalarp);
> matchdeclare (cc, all);
>
> defrule (rm1, tr (aa * bb), aa * tr (bb));
> defrule (rm2, tr (aa * bb, cc), aa * tr (bb, cc));
> defrule (rm3, tr (cc, aa * bb), aa * tr (cc, bb));
>
> declare ([a,b,c,d,x,y,z], scalar)$
>
> declare ([la,mu,nu,rh,ta,si,al,be], nonscalar)$
>
> ---------------------
>  and the partially successful output:
>
> (%i1) load(tr);
> (%o1) "c:/work5/tr.mac"
>
> (%i2) tr (mu,nu);
> (%o2) tr(mu,nu)
>
> (%i3) tr (mu,nu+rh);
> (%o3) tr(mu,rh)+tr(mu,nu)
>
> (%i4) tr (a*mu);
> (%o4) tr(a*mu)
>
> (%i5) apply1 (tr (a*mu),rm1);
> (%o5) a*tr(mu)
>
> (%i6) apply1 (tr (a*mu,nu),rm2);
> (%o6) a*tr(mu,nu)
>
> (%i7) apply1 (tr (a*mu,nu,rh),rm2);
> (%o7) tr(a*mu,nu,rh)
>
> (%i8) apply1 (tr (mu,a*nu),rm3);
> (%o8) a*tr(mu,nu)
>
> (%i9) apply1 (tr (la,mu,a*nu),rm3);
> (%o9) tr(la,mu,a*nu)
>
> (%i10) apply1 (tr (mu,a*nu,rh),rm3);
> (%o10) tr(mu,a*nu,rh)
>
> ---------------------------
> It looks like I need a replacement for
> matchdeclare (cc, all); that deals with
> the arbitrary number of args problem.
>
> Ted Woollett
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>