Subject: Vector Identities, Redux and more questions
From: Robert Dodier
Date: Wed, 13 Sep 2006 12:05:02 -0600
On 9/13/06, Neilen Marais <nmarais at sun.ac.za> wrote:
> OK, I think I'm up for this. I'd be happy to contribute something to Maxima :)
Terrific!
> /* grad(f*g) = f*grad(g) + g*grad(f) */
> simp: false$
> tellsimpafter (grad (ww*xx), ww*(grad xx) + xx*(grad ww))$
> simp: true$
> declare("grad", additive)$
>
> I get all of the rules except the last working the way I want. The last rule
> just does not seem to get applied at all.
It's not clear to me whether the observed behavior here is a bug or a feature.
Be that as it may, I believe the sticking point is the attempt to
match the arguments of multiplication within another operator
(grad in this case). Instead of trying to directly match the multiplication
arguments, instead match the whole product and then take it apart:
matchdeclare (aa, scalarproduct2p);
scalarproduct2p (e) := not atom(e) and op(e) = "*" and length (e) = 2
and scalarp (first (e)) and scalarp (second (e));
tellsimpafter (grad (aa), first (aa) * grad (second (aa)) + second
(aa) * grad (first (aa)));
declare ([a, b], scalar);
grad (a * b);
=> a grad(b) + grad(a) b
While we're at it, maybe we should make this more general --
probably could handle a product of an arbitrary number of scalars.
> Probably it's not sensible to put all vector identites
> (e.g. http://grus.berkeley.edu/~jrg/ay202/node189.html) in as telsimpafter
> rules... Which ones should be there? For the others it may be nice to have
> pre-defined rules in vect.mac so that a user may apply them as needed.
Well, one approach (which is used elsewhere in Maxima) is to apply
some rules automatically, and allow some more rules to be applied on request.
If someone is motivated to encode all known vector identities as Maxima rules,
I think that would be terrific.
HTH
Robert Dodier