peter.vlasschaert@gmail.com,02/08/2017 'version 1.0'
1e) cylindrical coordinates (= find =>KE =kinetic energy=1/2*m*v^2)
2e) Lagrangian cylindrical coordinates = lag = KE - PE

ref:  schaum's outline series ,theory and problems
        of vector analysis and an introduction to tensor analysis
auth: Murray R.Spiegel 
rem: curvilinear coordinates.

zoomout : crtl and scroll from the mouse

load 'packages'

kill(all)$
load("vector3d")$

menu:view :greek letters (make active)

assume(ρ>=0);

x:ρ*cos(phi);
y:ρ*sin(phi);
z:z;

r:[x,y,z];

depends on

depends([phi,ρ,z],t);

velocity ,cylindrical coordinates = diff(r,t)

p1:diff(r,t);

components 'v'

p1a:part(p1,1);
p1b:part(p1,2);
p1c:part(p1,3);

velocity ^2  'dot product' =>v^2 = dot(v,v) 'p2'

p2:[p1a*p1a,p1b*p1b,p1c*p1c];
p3:p1*p1;

cylindrical coordinate system 'ortnogonal system'

dr = diff(r,ρ)*dρ+diff(r,phi)*dphi+diff(r,z)*dz

find : v(x,y,z)->v(ρ,phi,z)

p4:diff(r,ρ);
p5:diff(r,phi);
p6:diff(r,z);

find 2-norm : p4,p5,p6

p7:p4*p4$
p71:trigsimp(sqrt(part(p7,1)+part(p7,2)+part(p7,3)));
p8:p5*p5$
p81:trigsimp(sqrt(part(p8,1)+part(p8,2)+part(p8,3)));
p9:p6*p6$
p91:trigsimp(sqrt(part(p9,1)+part(p9,2)+part(p9,3)));

find unit vector :e_ρ    ,   e_phi   ,      e_z
e_ρ = cos(phi)*i+sin(phi)*j+0*k
e_phi = -sin(phi)*i+cos(phi)*j+0*k
e_z     = 0*i+0*j+z*k

p10:e_ρ=p4/p71;
p11:e_phi=p5/p81;
p12:e_z=p6/p91;

find :e_z  from e_ρ and e_phi
solution :cross product  = e_z = e_ρ  coss e_phi

p12a:cross(part(p10,2),part(p11,2));
p12b:trigsimp(p12a);

first component,second component,thrid component ,e_ρ

p13:part(p10,2,1);
p14:part(p10,2,2);
p15:part(p10,2,3);

find : diff(e_ρ,t),diff(e_phi,t)

p16:diff(part(p10,2),t);
p17:diff(part(p11,2),t);

relation between :cartesian unit vectors and cylindrical unit vectors
find i = f(e_ρ,e_phi),j= f(e_ρ,e_phi)  
sol : find 'p18,p19'

p18:e_ρ    = cos(phi)*i+sin(phi)*j+0*k;
p19:e_phi = -sin(phi)*i+cos(phi)*j+0*k;
p20:e_z     = 0*i+0*j+1*k;

menu :Solve 
first field       : p18,p19
second field : i,j

sol:solve([p18,p19], [i,j]);

sol1:(part(sol,1,1,2))$
sol2:(part(sol,1,2,2))$
sol_i:trigsimp(sol1);
sol_j:trigsimp(sol2);

p21:R=trigsimp(expand(x*sol_i+y*sol_j+z*e_z));

depends : e_ρ = e_ρ(t),e_phi=e_phi(t)

depends([e_ρ,e_phi],t);

p22:'diff(R,t)=diff(part(p21,2),t);

find :diff(e_ρ,t) 'p16' and 'p18'

p23:'diff(e_ρ,t)=ratsimp(factor(diff(part(p18,2),t)));

find :p19  'e_phi'

p24:ratsubst(part(p19,1),(j*cos(phi)-i*sin(phi)),part(p23,2));

p25:ev(p22,part(p23,1)=p24);

p26:v_ρ=ratcoef(part(p25,2),e_ρ);
p27:v_phi=ratcoef(part(p25,2),e_phi);
p28:v_z=ratcoef(part(p25,2),e_z);

Kinetic Energy : Cylindrical coordinates (ρ,phi,z)

p29:EK=1/2*m*(part(p26,2)^2+part(p27,2)^2+part(p28,2)^2);

Potential Energie :Cylindrical coordinates (ρ,phi,z)

depends(V,[ρ,phi,z]);

p30:EP= V;

p31:'diff(V,t)=diff(V,t);

Lagrangian : cylindrical coordinates   (= lag) = EK-EP

lag=part(p29,2)-part(p30,2);