Hi Fabio,
> I tried first to define a vector using
>
> q:[q[x],q[y],q[z]];
>
> and later assigning
>
> q[1] : U;q[2] : V ; q [3] : W;
(then, yor first definition is lost.)
> at this point I am able to compute
> express(div(q));
> while if I put
> A : transpose(q);
> for
> express(div(A));
> I got the following error:
express() is designed only to work with lists, not with matrices (which
are constructed by using transpose()) or other things. Have a look at
the definition of express() in file vect.mac, in the third paragraph,
the error is produced if listp(expn) does not return true:
express1(expn) := block(
[ans],
if mapatom(expn) then
if nonscalarp(expn) then (ans:[],
for jj: dimension step -1 thru 1 do
ans: cons(expn[coordinates[jj]], ans),
return(ans))
else return(expn),
expn: map('express1, expn),
if mapatom(expn) or listp(expn) then return(expn),
if inpart(expn,0)="grad" then (ans:[],
expn: inpart(expn,1),
for jj: dimension step -1 thru 1 do ans:
cons('diff(expn,coordinates[jj])/sf[jj], ans),
return(ans)),
if piece="div" then (expn: inpart(expn,1),
if not listp(expn) then error("div called on scalar arg:",
expn),
return(sum('diff(sfprod*expn[jj]/sf[jj],
coordinates[jj]), jj, 1, dimension)/sfprod)),
if piece="laplacian" then return(sum('diff(sfprod*'diff(
inpart(expn,1),coordinates[jj])/sf[jj]**2,
coordinates[jj]), jj, 1, dimension) / sfprod),
if piece="curl" then (expn:inpart(expn,1),
if listp(expn) then (
if length(expn)=2 then return(('diff(sf[2]*expn[2],
coordinates[1])-'diff(sf[1]*expn[1],
coordinates[2]))/ sf[1]/sf[2]),
if dimension=3 then return([
('diff(sf[3]*expn[3],coordinates[2])-
'diff(sf[2]*expn[2],coordinates[3]))/
sf[2]/sf[3],
('diff(sf[1]*expn[1],coordinates[3])-
'diff(sf[3]*expn[3],coordinates[1]))/
sf[1]/sf[3],
('diff(sf[2]*expn[2],coordinates[1]) -
'diff(sf[1]*expn[1],coordinates[2]))/
sf[1]/sf[2]])),
error("curl used in space of wrong dimension")),
if piece="~" then (
ans: inpart(expn,1), expn:inpart(expn,2),
if listp(ans) and listp(expn) and length(ans)=length(expn)
then (if length(ans)=2 then return(ans[1]*expn[2]
-ans[2]*expn[1]),
if length(ans)=3 then return([ans[2]*expn[3]-
ans[3]*expn[2], ans[3]*expn[1]-ans[1]*expn[3],
ans[1]*expn[2]-ans[2]*expn[1]])),
error("~ used with improper arguments:",ans,expn)),
expn) $