Subject: Vector Identities, Redux and more questions
From: Neilen Marais
Date: Mon, 11 Sep 2006 17:13:36 +0200
Hi
Thanks to all who answered on the previous "Applying Vector Identities"
threads. A summary of the solution is to put the following in a file
"more_vect.mac" somewhere on your maxima load path:
matchdeclare (xx, scalar_not1p, yy, nonscalarp, [aa, bb], all)$
scalar_not1p (e) := e # 1 and scalarp (e)$
simp : false$
tellsimpafter (curl (xx*yy), xx*(curl yy) - yy~(grad xx))$
tellsimpafter ((xx * yy) ~ aa, xx * (yy ~ aa))$
tellsimpafter (aa ~ (xx * yy), xx * (aa ~ yy))$
simp : true$
declare (["grad", "laplacian"], nonscalar)$
declare("curl",additive)$
And to use:
(%i116) load("more_vect");
yy*xx partitions `product'
yy*xx partitions `product'
yy*xx partitions `product'
(%o116) /home/brick/akademie/NewCode/working/MaximaTests/more_vect.mac
(%i117) declare ([s,t], scalar);
(%o117) done
(%i118) curl(s*grad(t) - t*grad(s));
(%o118) s*curl(grad(t))-curl(grad(s))*t+grad(s)~grad(t)-(-grad(s))~grad(t)
(%i119) ev(%);
(%o119) 2*grad(s)~grad(t)
Now my questions:
1) Wouldn't it be a good idea to include these definitions in the standard
vect package?
2) How do I get it to work with symbols using subscripts. E.g. this works:
(%i121) declare([lam1, lam2], scalar);
(%o121) done
(%i122) curl(lam1*grad(lam2)-lam2*grad(lam1));
(%o122) lam1*curl(grad(lam2))-curl(grad(lam1))*lam2+grad(lam1)~grad(lam2)-(-grad(lam1))~grad(lam2)
(%i123) ev(%);
(%o123) 2*grad(lam1)~grad(lam2)
This doesn't:
(%i124) declare([lam[1], lam[2]], scalar);
Improper argument to declare:lam[1] -- an error. Quitting.
To debug this try debugmode(true);
Am I being silly wanting this to work? I tend to work with arrays rather than
bunches of "standalone" variables so I'd like the above to work...
Thanks
Neilen
--
you know its kind of tragic
we live in the new world
but we've lost the magic
-- Battery 9 (www.battery9.co.za)