kill(all)$
load(lrats)$
load(vect)$

rotating coordinate system , 'version 1.0'
peter.vlasschaert@gmail.com, 03/09/2018

 rotating coordinate system (x,y,z  , [i,j,k])

rem : i  perpendicular j , j perpendicular k,   i perpendicular k
rem : I  perpendicular J , J perpendicular K, I perpendicular K

vector A : xyz ,'system'
===================

components :  x,y,z
---------------------

p1:A=[A1,A2,A3] ;
p1a : rhs(p1)[1];
p1b : rhs(p1)[2];
p1c : rhs(p1)[3];

unit vectors : i,j,k
--------------------

p2:[i,j,k];

vector : A
---------------

p3:lhs(A) = sum(rhs(p1)[kk]*p2[kk],kk,1,3);

depends([A1,A2,A3,i,j,k],t);

differentation : A ( = vector)
========================

p4:'diff(lhs(p3),t) = diff(rhs(p3),t);

We need  definition scalar product : 
------------------------------------------------------------------------------------------------
 a=b ,  a*b = 1 , ( cos(0)     =1 )
 a≠ b    a.b = 0 , ( cos(π/2) =0 )
======================================================
collection variables : a:{i,j,k},b:{i,j,k}
======================================================

definition : scalar product
======================

let(i*i,1);
let(j*j,1);
let(k*k,1);
let(i*j,0);
let(j*k,0);
let(k*i,0);

p5:(i+j+k)*(i+j+k);
p5a:expand(p5);
p5b:letsimp(p5a);

what about : differentation , i*i or j*j or k*k with  respect  't'
see : above depends 

p6: i*i ;
p6a : p6 = letsimp(p6);
p6b:diff(p6a,t);

1e) from definition : scalar product , angle between (i,('diff(i,t,1))) = π/2
= >  i : vector perpendicular to di/dt : vector   ,di/dt  stays in the plane (yz)
=============================================================
analog :  show above i => j => k.
=============================================================
2e) from definition : scalar product , angle between (j,('diff(j,t,1))) = π/2
= > j : vector perpendicular to dj/dt : vector   ,dj/dt  stays in theplane (xz)
=============================================================
3e) from definition : scalar product , angle between (k,('diff(k,t,1))) = π/2
= > k : vector perpendicular to dk/dt : vector   ,dk/dt  stays in theplane (xy)
=============================================================

p6b1:i*diff(i,t,1) = 0;
p6b2:j*diff(j,t,1) = 0;
p6b3:k*diff(k,t,1) =0;

p6c:[p6b1,p6b2,p6b3];

what about : differentation , i*j or j*k or i*k with  respect  't'
see : above depends 
================================================
 scalar definition          : i*j = j*k = i*k=0
                                            also
                                           j*i = k*j = k*i=0 
================================================

p6d1:i*j;
p6d2:p6d1=letsimp(p6d1);
p6d3:diff(p6d2,t);

p6e1:j*k;
p6e2:p6e1=letsimp(p6e1);
p6e3:diff(p6e2,t);

p6f1:i*k;
p6f2:p6f1=letsimp(p6f1);
p6f3:diff(p6f2,t);

1e )   di/dt  => (yz plane)
====================

p7:diff(i,t) = β[1]*j+β[2]*k;

2e )   dj/dt  => (xz plane)
====================

p7a:diff(j,t) = β[4]*i+β[3]*k;

3e )   dk/dt  => (xy plane)
====================

p7b:diff(k,t) = β[5]*i+β[6]*j;

find : β[kk] , kk = 1,2,3,4,5,6
========================
========================

1e) three equations , we want eliminate from three quations the, β[kk],kk=4,5,6
==================================================================
=> i,j,k from β[kk],kk=1,2,3

part 1: β[4] eliminate
==============================
=>  i*('diff(j,t,1))+('diff(i,t,1))*j=0 , 'p6d3'

see :   i*('diff(j,t,1))
---------------------------

p8:i*p7a;

p8a:expand(p8);

p8b:letsimp(p8a);

see : ('diff(i,t,1))*i
-------------------------

p9:j*p7;
p9a:expand(p9);
p9b:letsimp(p9a);

use : 'p6d3' ,find : β
=================

p10:subst([p8b,p9b],p6d3);
p10a :solve(p10,β[4]);

result :  into p7a  => p10b
=====

p10b:subst([p10a],p7a);

part 2: β[5] 
=============================
=>  k*('diff(i,t,1))+('diff(k,t,1))*i =0 , 'p6f3'

see :   k*('diff(i,t,1))
---------------------------

p11:k*p7;
p11a:expand(p11);
p11b:letsimp(p11a);

see : ('diff(k,t,1))*i
--------------------------

p12:i*p7b;
p12a:expand(p12);
p12b:letsimp(p12a);

use : 'p6f3' ,find : β
=================

p13:subst([p11b,p12b],p6f3);
p13a :solve(p13,β[5]);

result :  into p7b => p13b    ,( result, intermediary  )
=====

p13b:subst([p13a],p7b);

part 3: β[6] 
=============================
=>  j*('diff(k,t,1))+('diff(j,t,1))*k =0 , 'p6e3'

see :   j*('diff(k,t,1))
---------------------------

p14:j*p13b;
p14a:expand(p14);
p14b:letsimp(p14a);

see : ('diff(j,t,1))*k
--------------------------

p15:k*p10b;
p15a:expand(p15);
p15b:letsimp(p15a);

use : 'p6e3' ,find : β
=================

p16:subst([p14b,p15b],p6e3);
p16a :solve(p16,β[6]);

result :  into p7b => p13b    ,( result, final  )
=====

p16b:subst([p16a],p13b);

formula 17: final result : d()/dt ?
==========================

p17a:p7;
p17b:p10b;
p17c:p16b;

p17d :[p17a,p17b,p17c];

rotation : term with 'ω'
==================

coef : i,j,k  from  'p18a'
---------------------------------
i: p18b1
j:p18b2
k:p18b3

p18:A1*lhs(p17a)+A2*lhs(p17b)+A3*lhs(p17c);

p18a: p18 = subst(p17d,p18);
p18b1:ratcoeff(rhs(p18a),i);
p18b2:ratcoeff(rhs(p18a),j);
p18b3:ratcoeff(rhs(p18a),k);

How to find :  ω 'cross product ' A , ' Matrix Form'
=========================================

1e) construction : b1,b2,b3 , unknown
----------------------------------------------------------
construct matrix : see menu : Algebra : Enter matrix

you don't need :
=============
=>   first : expand , before  letsimp command. ( Name : Q)

Q: matrix(
 [i,j,k], 
 [b1,b2,b3], 
 [A1,A2,A3]
);

p19:determinant(Q);

i,j,k ,coef:
========

p19a1:ratcoeff(p19,i);
p19a2:ratcoeff(p19,j);
p19a3:ratcoeff(p19,k);

how to solve :{b1,b2,b3} from p18bi and p19ai , i=1,2,3
=============================================

p20a:p18b1 = p19a1;
p20b:p18b2 = p19a2;
p20c:p18b3 = p19a3;

p21:solve([p20a,p20b,p20c],[b1,b2,b3])[1];

select : % r1  => try β[1]
====================

p21a:subst([%r1= β[1]],p21);

update :  Q  with : 'p21a'
=====================

p21b:Q_up = subst(p21a,Q);

How to find element from  : Q_up

p21c :rhs(p21b)[1,1];

relation with : second row  of Q_up , components of ω  vector
---------------------------------------------------------------------------------------------
b1 =ω1,b2=ω2,b3=ω3, result final Q
----------------------------------------------------------------------------------------------

p22:[b1=ω1,b2=ω2,b3=ω3];
p22a:subst(p22,Q);

p23:p18=p22a;

p23a:lhs(p23) = determinant(rhs(p23));

final result : 'diff(A,t,1)
---------------------------------
==================

use : subst , 'p23' into 'p4'

p24:lratsubst([p23a],p4);

p24a:subst([p23],p4);

matchdeclare([a,b],nonscalar);

let(a*b,0);
let(a.a,1);
letsimp(x*y);
letsimp(x.x);

p55:(i+j+k)*(i+j+k);
p55a:expand(p55);
p55b:letsimp(p55a);

p66:'diff(x,t,1)+'diff(y,t,1)+'diff(z,t,1);
p66a:p6*p6;
p66b:expand(p66a);
p66c:letsimp(p66b);

p77:[a1,b1,c1]*[a1,b1,c1];
p77a:expand(p77);
p77b:letsimp(p77a);

rem : declare  doesn't wor k , use 'matchdeclare' to apply  to 'let'
          =>  works option : scalar  or nonscalar, only when , scalar definition
                 not implemented