kill(all)$

maxima : load(vect), relation div ,grad ,vector ,scalar, operator ,version 1.0a ,corrected :1.0
peter.vlasschaert@gmail.com, 21/09/2021

load packages , option :
===================

load(vect)$ ratprint:false$

load(lrats)$

declare : cartesian" unit vectors ",(two types)
----------------------------------------------------------

→  direct calculation:  see 'below' ,how to use : infix  ' new operator'.

unit vector : x-direction   → i=[1,0,0]
unit vector : y-direction   → j= [0,1,0]
unit vector : z-direction   → k= [0,0,1]

i:[1,0,0];
j:[0,1,0];
k:[0,0,1];

→ list of unit vectors
ii1  x-direction  = i
ii2  y-direction  = j
iι3  z-direction  = k

→ symbolic calculation:

ordergreat(ii1,ii2,ii3);

un:[ii1,ii2,ii3];

→ otherway

un1:makelist(concat(ii,iii),iii,1,length(un));

→ otherway

un2:makelist(sconcat(ii,iii),iii,1,length(un));

rem : p = predicate check the command =' list ' =listp→,result : 'true  or false '

listp(un2);

a)  div(a*A)
==========
a=scalar  , dependencies :{x,y,z}
A = vector

declare(A,nonscalar,a,scalar)$

v1:express(A);

v1a:express(a);

depends(a,[x,y,z]); /*don't forget this declaration */

→ command : from 'load(vect)', 
div ,curl,grad,...........

v2a:a;

pa:div(a*A);

definition : divergence(A)
====================

pb:div(A)= express(div(A));

ll:map("=",v1,[1,1,1]);

v2:vectorsimp(pa),expandall;

v3:express(v2);

listp(v3);

v3a:makelist(v3);

v3a1:flatten(v3a);

listp(v3a);

v3a1[1];

rem :1+[1,1,1] = [2,2,2]

v3b1:part(v3a,1,1);

v3b2a:part(v3a,1,2);

v3b2a1:listp(v3b2a);

vb32b:sum(v3b2a[i],i,1,length(v3b2a));

result:v3a
========

vc3:v2=v3b1+vb32b;

v4:lratsubst(ll,v3);

→ first element of list

v4[1];

 => otherway 'select elements from a list '

[first(v4),second(v4),last(v4)];

we become : div(a*A) → grad(a)

1e) definition :grad(a)
------------------------------

v4a:grad(a)=sum(v4[ii]*un1[ii],ii,1,length(v4));

→ see 'above': only use un,un1 into v4a, ' un2 :result error message'

v4b:express(v4a),expandall;

rem :reverse doesn't work here.

v4b1:[rhs(v4b)=lhs(v4b)];

2e) definition :grad(a)
------------------------------

v4b2:subst(v4b1,v4a);

b) how to use : infix  ' new operator'
============================

new : operator :° , 'used for vector product', 'easy to use keyboard'

infix("°");
uu°vv :=express(uu~vv);

rem : see  operator  :=  'see above'

unit vector : x-direction   → i=[1,0,0]
unit vector : y-direction   → j= [0,1,0]
unit vector : z-direction   → k= [0,0,1]

new definition : 'vector product'use x',

 print ("ixj =i°j =k =",i°j)$

k.(i°j);

sum :

→  first vector :

s1:print ("2*i+3*j =",2*i+3*j);

s1;

→ second vector:

s2:print ("2*i-4*j =",2*i-4*j)$

s2;

→ s3:sum (first vector & second vector)

s3:print("vectorsum(s1+s2) = ",s1+s2);

s3;

definition 'triple': ww.(uu°vv)

triple(ww,uu,vv):=ww.(uu°vv);

triple(k,i,j);

kill(u,v,w)$

aa:[u[1],u[2],u[3]];
bb:[v[1],v[2],v[3]];
cc:[w[1],w[2],w[3]];

print ( "bb.(aa°cc) = ",triple(bb,aa,cc))$

-------------------------------------------------------------------------------------------------------------------------------------------------------------