kill(all)$

maxima : unit vector transformation (both direction),spherical coordinates,version 1
peter.vlasschaert@gmail.com,02/09/2021

coordinates spherical coordinates

                        [er,eθ,eφ] & [ii,jj,kk]

ordergreat(ii,jj,kk)$

p1: er=(r*cos(φ)*sin(θ)*ii+r*sin(φ)*sin(θ)*jj+r*cos(θ)*kk)/r,expand; 
p2: eθ=subst([θ=π/2+θ],rhs(p1)),expand;

bb: genmatrix(aa, 3, 3);

m:[bb[1,1]:ii,bb[1,2]:jj,bb[1,3]:kk];

m[1];

vector product: erxeθ =eφ

bb;

makelist(bb[2,i]:ratcoeff(rhs(p1),m[i]),i,1,3);
makelist(bb[3,i]:ratcoeff(rhs(p2),m[i]),i,1,3);

bb;

bbb:trigsimp(determinant(bb));

trigsimp((-sin(θ)^2*sin(φ)-cos(θ)^2*sin(φ))*ii-(-sin(θ)^2*cos(φ)-cos(θ)^2*cos(φ))*jj);

p3:eφ=%;

p4:[rhs(p1),rhs(p2),rhs(p3)];

p4a:transpose(matrix(p4));

p5:[lhs(p1),lhs(p2),lhs(p3)];
p5a:transpose(matrix(p5));

p6:p5a=p4a;

[er,eθ,eφ] →[ii,jj,kk]

p6a:table_form(p6)$

reverse : [ii,jj,kk]→[er,eθ,eφ]

z1:solve([p1,p2,p3], [ii,jj,kk])[1];

z2:trigsimp(z1),expand;

z3:matrix(z2);

z4:table_form(z3)$

qq1:trigsimp(z1[1]);
qq2:trigsimp(z1[2]);
qq3:trigsimp(z1[3]);

z5:[qq1,qq2,qq3];

z5a:map(rhs,z5);

z5b:transpose(matrix(z5a));

z5aa:map(lhs,z5);
z5bb:transpose(matrix(z5aa));

z6:z5bb=z5b;

z6a:table_form(z6)$

check:{p1,p2,p3}
===============

1e) step : use z5  into(p1,p2,p3)

z7:(subst(z5,[p1,p2,p3]));

2e) step :simplify(trigsimp)

z7a:trigsimp(z7);

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