kill(all)$

maxima  hamiltonian function ,version 1.0,part 3
peter.vlasschaert@gmail.com,29/03/2020

load - packages
============

load(lrats)$

how to construct ,'hamiltonian' : from physics
=================================
H = T + V = kinetc Energy +potential energy

p1:H=T+V;

a) problem :  spring coupled with mass ( = ideal)
-----------------------------------------------------------
F= force                  = m*a = mass acceleration
k= spring constance
x=  displacement
v=  velocity
-----------------------------------------------------------
sprng is fixed on the wall
------------------------------------------------------------
wall → spring → mass , x-direction  ( 1d :problem)

p1a:F= -k*x;
p1b:m*a = rhs(p1a);
p1c:m*'diff(v,t)   = rhs(p1a);
p1d:m*'diff(x,t,2) = rhs(p1a);

b)  find H(x,y) → (x →p) ,'momentum'  p=m*v'
                          (y →q) ,'space          q       '

1e) kinetic energy = T
-----------------------

p2a:T = 1/2*m*v^2;
p2b:T = 1/(2*m)*p^2;

2e) potential energy = V
------------------------

a)  gradient 'V' & force, 'conservative field'
---------------------------------------------------

p3a: F = - 'diff(V,x);

p3b:subst([p1a],p3a);

b) find V
-----------

p3c:ode2(p3b,V,x);

set %c

p3b:subst([%c=0],p3c);

c)  subst x = q
------------------

p3c:subst([x=q],p3b);

3e) final result  H(p,q)
---------------------------

p3d:H(p,q) = subst([p2b,p3c],rhs(p1));

m : mass

ref :https://en.wikipedia.org/wiki/Hamiltonian_mechanics
=========================================

 theoretical
========

1e ) dp/dt = -∂H/∂q
2e ) dq/dt =  ∂H/∂p

declare(m,constant);

depends([v],[t]);

1e ) dp/dt = -∂H/∂q
==============

p = m*v

p4:p=m*v;

wet Newton ( m*a = F)
----------------------------

p4a:diff(rhs(p4),t) = -diff(rhs(p3d),q);

see : part 1, above

2e ) dq/dt =  ∂H/∂p
==============

p4b:'diff(q,t) =diff(rhs(p3d),p);

velocity (v)

p4c:subst([p4],p4b);

p4d:rhs(p4c) = lhs(p4c);

result : from H =H(p,q) we can find  : result ' Newton's law for system F = m*a ' 