Divergence of a matrix



You could consider using the tensor packages.

The indicial tensor package (itensor) can deal with divergences quite
easily. You could use this package to derive the final form of your
equations using index notation, and then use the ic_convert function to
convert an itensor expression into a ctensor program. The ctensor package is
the component tensor manipulation package, in which tensors are represented
by matrices; the program produced by ic_convert manipulates these matrices.
Don't be put off by the fact that the packages were obviously developed with
general relativity in mind; they can be applied in other contexts.

For example, code like this may be of some use:

derivabbrev:true;
load(itensor);
load(ctensor);
ct_coordsys(cartesian3d);
cmetric();
christof(mcs);
depends([p,T],ct_coords);
ishow(DvDt([a],[])=(1/rho)*(-p([],[],a)+covdiff(T([a],[b]),b)+f([a],[])))$
ic_convert(%);
DvDt:[0,0,0];
%th(2),ev;
DvDt;

The first three lines just load the appropriate packages and set the
abbreviated display mode for derivatives. The fourth line selects the 3D
Cartesian coordinate system to be used by the ctensor package (equations
developed using itensor are coordinate-system independent, so long as
covariant derivatives are used as appropriate; when we go from the indicial
to the component notation, however, the choice of a coordinate system must
be made.) Lines 5 and 6 just set up the metric and calculate the Christoffel
symbols (which, for the Cartesian system, will all be trivially zero of
course.) Line 7 establishes the coordinate dependence of the fields p and T.
Line 8 is a form of the Navier-Stokes equation, written in such a form that
it can become an assignment suitable for conversion by ic_convert (line 9).
Line 10 initializes the symbol DvDt as a zero vector, allowing the next line
to compute this vector's components using the Navier-Stokes equation; the
result is displayed in line 11.

Now this may not be exactly what you want but hopefully, it's not too far
off the mark and it demonstrates how these packages could be used. Further,
the result can be quite easily computed in another coordinate system; for
instance, if you replace line 4 with

ct_coordsys(spherical);

you get the final result in a spherical coordinate system (so long as the
covariant derivative was used correctly in the appropriate places).


Viktor




-----Original Message-----
From: maxima-bounces at math.utexas.edu [mailto:maxima-bounces at math.utexas.edu]
On Behalf Of Fabio
Sent: Wednesday, December 16, 2009 6:23 AM
To: maxima at math.utexas.edu
Subject: Divergence of a matrix

Dear all,
as a newbie I am still struggling with maxima.
It looks like the divergence of a matrix in the form

div(A);

is not possbile in the "vect" package.
Should I use a differente package?
Anyway I would like to re-write my set of equations (Navier-Stokes -
momentum equations) in a compact way using divergences and gradients in
vectorial form to be able to derive the different components at a later time
being "sure" of the original input.
Having such a description, I could manipulate my equation in the more
compact form and deriving the expressions on a case by case basis.
how should I cope with the problem?

Regards

Fabio