Newton, Lagrange, Hamilton and Hamilton- Jacobi Mechanics of Classical Particles
with Mathematica
Dr. Luigi E. Masciovecchio email: [email protected] First published and available as notebook and PDF on
http://sites.google.com/site/luigimasciovecchio/
2017.06.06
In[1]:= Print@"Document revision: ", IntegerPart@Date@DDD Document revision: 82017, 10, 17, 6, 57, 57<
Foreword
D
ear Colleagues,Certainly only very few words have to be spent to describe the usefulness, the efficiency, the efficacy, the value and the beauty of Mathematica for the didactics of physics in general and, as shown in this notebook, for classical mechanics in particular. They are: "Get it! Now!"
But it maybe happens that in the havoc of the semester lectures You don't find the time to write (and to debug...) the code You would need to illustrate various aspects of the theory You are teaching. So I put together some examples from Newton, Lagrange, Hamilton and Hamilton-Jacobi mechanics of classical particles that You can use immediately, with perhaps only minor adjustments to meet Your special needs. I put special emphasis on examples with friction, on chaos, on visualization and on constants of motion (Noether's theorem); an attention to future applications in quantum mechan- ics is always on the background. Some comments are added to the code to explain what's going on, but this notebook is by no means an exhaustive exposition of the theories involved; see the bibliography section for a list of many interesting textbooks.
(You are maybe interested in my notebooks on special and general relativity too. You can find them on my web site.) Drop my a line if I have to fix some errors.
Enjoy!
Dr. Luigi E. Masciovecchio
Table of Content
ì Foreword
ì Table of Content ì Utilization Notes ì Bibliography
ì Initialization code (Run it first!)
ì I) Newton mechanics for classical particles
è Gravitative three-body-problem è actio = reactio? Not always...
ì II) Lagrange mechanics for classical particles
è Variational calculus: Formal Euler equations
è Variational calculus: Shortest path between (a, A, z) and (b, B, z) on the plane z = 0 analytical (geodetic) è Variational calculus: Shortest path between (a, A, z) and (b, B, z) on a surface z = x2+y analytical (geodetic) è Variational calculus: Shortest path between (a, A, z) and (b, B, z) on a surface z = Sin[4 x] + y/3 analytical (geodetic) è Variational calculus: Shortest path between (a, A, z) and (b, B, z) on a surface z =x2+y2 numerical (geodetic) è Variational calculus: Minimal area of a surface of revolution generated by rotating the graph of a function in the x-y
plane about the y axis (catenary) (see Goldstein&Poole&Safko p.40)
è Variational calculus: Brachystochrone problem from point (a, A) to point (b, B) (cycloid) (see Goldstein&Poole-
&Safko p.42)
è 1D harmonic oscillator in Cartesian coordinates è 2D nonlinear pendulum
è 2D spring pendulum (see Zimmerman&Olness p.327) è 3D bead sliding on a conical spiral (see Wells p.52) è 3D Spring pendulum with viscous drag (see Wells p.338)
è A mobile (in the sense of Alexander Calder) with drag and time-dependent driving force (3D, animation) è Noether's theorem for Lagrangian mechanics: the ten constants of motion from the Galilei transformation group
ì III) Hamilton mechanics for classical particles
è A simple 1D Hamiltonian
è A 2D central force V(r) = - Α/r Hamiltonian è A simple 3D Hamiltonian
è Sliding bead on a wire of the form y = f(x) in a homogenous gravitational field (2D) (see Baumann p.365)
è Mass point moving on the surface of a cylinder subject to a linear central force (coil spring) and gravity (3D) (see Baumann p.367)
è 1D harmonic oscillator in phase space and space of states è 1D harmonic oscillator with viscous drag
è Lots of cute orbits from the problem of the gravitational attraction from two fixed masses (2D)
è A pendulum bob suspended from a coil spring and allowed to swing in a vertical plane, assuming viscous drag on the bob, in polar coordinates (2D) (see Wells p.321)
è 2D double simple pendulum exhibits chaotic behavior (see Baumann p.393)
è 1D chaos: particle moving in a nonlinear potential with external driving force and drag è Poisson bracket: definition and properties
è Poisson bracket: Total energy, angular momentum and Runge-Lenz vector in the Α/r potential (see Tong p.95 and Goldstein&Poole&Safko p.102)
è A canonical transformation for the 1D damped harmonic oscillator with an ad hoc Hamiltonian and {Q, P} = 1 (see Greiner p.373)
è A canonical transformation for the 1D harmonic oscillator with {Q, P} = 1 è A canonical transformation for the 1D q-22 potential with {Q, P} = 1
è An (at least) canonoidal transformation for the 1D harmonic oscillator with Hamiltonian K(Q, P) = P and {Q, P} ¹ 1 (see Torres del Castillo p.160)
è An (at least) canonoidal transformation for the 1D harmonic oscillator with Hamiltonian K(Q, P) = 0 and {Q, P} ¹ 1 (see Torres del Castillo p.160)
è Noether's theorem for the Hamiltonian
è Liouville's theorem for a system of free falling bodies
ì IV) Hamilton-Jacobi mechanics for classical particles
è PDE (Partial Differential Equation): A few analytically solved basic examples adapted from the Mathematica 5.2 documentation
è PDE: Numerical solution of the 1D time-dependent Schrödinger equation (Cauchy problem with a second order PDE in two variables)
è Solving the HJE (Hamilton-Jacobi equation) for the free particle in 1D (see Jelitto p.342 or Schmutzer p.430) è Solving the HJE for the harmonic oscillator in 1D (see Goldstein&Poole&Safko p.434-437)
è Solving the HJE for the slant throw in 2D (see Jelitto p.342 or Greiner p.395-397)
è Separability of the HJE for a particle attracted to two fixed gravitational centers in 2D (see José&Saletan, Worked Example 6.3, p.298-301)
è Separation of variables in ("normalized") elliptic coordinates of the HJE in physically interesting planar cases (see Landau&Lifshitz, § 48, (3) Elliptic co-ordinates)
è HJE and Hamilton's principal function for the planar problem of the attraction from two equal and fixed masses (see Arnold, chapter IX, § 47, C. Examples)
è An opto-mechanical analogy and the dawn of Quantum Mechanics in the Hamilton-Jacobi theory
Utilization Notes
Û
Note: Mathematica by Wolfram Research is a (fabulous) computer algebra system. A notebook is an interactive Mathematica document (extension .nb), which can be printed out as a PDF file, but loosing any interactivity, of course.Û
Note: Once the (protected) initialization code has run, every of the following Mathematica subsections can be evaluated by its own! The Remove["Global`*"] statement at the beginning of every subsections gets ruthlessly rid of any interference from previously run code.The code was originally written in Mathematica version 5.2 and runs with only a few minor flaws in Mathematica version 7. For higher Mathematica versions there will be more and more issues, which had to be fixed to reproduce any results.
Û
Note: The $Assumptions statement at the beginning of a few subsections contains relations often crucial for a proper simplification of the following expressions.Û
Note: E means ã in input, so the very similar looking capital epsilon character E is used when the usual E character is needed, for example to designate an Energy in the code. Likewise, the capital kappa character K substitutes sometimes the usual K character.Ü
Warning: Mathematica supposes partial differentiation to be commutative!In[2]:= 9¶x,yf@x,yD,¶y,xf@x, yD=
HoldFormA¶x,yf@x,yD== ¶y,xf@x, yDE
%ReleaseHold
Out[2]= 9fH1,1L@x, yD, fH1,1L@x, yD=
Out[3]= ¶x,yf@x, yD ¶y,xf@x, yD Out[4]= True
Ü
Warning: The evaluation of an expression x2 must be done very carefully to avoid errors! See some examples:In[5]:= ::SimplifyB x2 F, H-xL2 , PowerExpandB x2 F, PowerExpandB H-xL2 F>, :SimplifyB x2 ,xÎRealsF, SimplifyB x2,x£0F, SimplifyB x2 ,x³0F>, :Ix2M12, x
1 2
2
,x
2
2, SolveB x2 y,xF>>
Out[5]= 99 x2 , x2 , x, x=,8Abs@xD,-x, x<,9 x2 , x, x,88x® -y<,8x®y<<==
Ü
Warning: Avoid Italian universities like hell: they are highly neurotoxic! I know what I'm talking about. Prof. Urs Bestmann (my excellent mathematics, geometry and informatics teacher) was right about that! Absolutely right.Bibliography
Bibliography
N. Straumann. Skript Klassische Mechanik, Sommersemester 1984.
V.I. Arnold. Mathematical Methods of Classical Mechanics, 1974.
A. Romano. Classical Mechanics with Mathematica, 2012.
D.A. Wells. Schaum's Outline of Theory and Problems of Lagrangian Dynamics, 1967.
D. Tong. vol. 2 Classical Dynamics, 2015.
H. Goldstein, C.Poole, J.Safko. Classical Mechanics, 3.ed. 2000.
R.M. Dreizler, C.S. Lüdde. Theoretical Physics 1. Theoretical Mechanics, 2011.
R.L. Zimmerman, F.I. Olness. Mathematica for Physics, 2.ed. 2002.
G. Baumann. Mathematica for Theoretical Physics I, 2.ed. 2005.
W. Greiner. Classical Mechanics, 2.ed. 2010.
L.D. Landau, E.M. Lifshitz. Course of Theoretical Physics 1. Mechanics, 3.ed. 1976.
G.F. Torres del Castillo. "The generating function of a canonical transformation", Revista Mexicana de Física E 57 158–163, december 2011.
E. Schmutzer. Grundlagen der Theoretischen Physik - Band 1 und 2, 3.ed, 2005.
R.J. Jelitto. Theoretische Physik 2: Mechanik II, 2.ed, 1987.
J.V. José, E.J. Saletan. Classical Dynamics: A Contemporary Approach, 1998.
Initialization code (Run it first!)
In[6]:= Print@"This system is: ",
8"ProductIDName", "ProductVersion"< . $ProductInformationD Print@"Operating system: ", ReadList@"!ver", StringDD
Print@"$MachineType,$ProcessorType,$ByteOrdering,$SystemCharacterEncoding: ", 8$MachineType, $ProcessorType, $ByteOrdering, $SystemCharacterEncoding<D This system is: 8Mathematica, 7.0 for Microsoft Windows H32-bitL HNovember 10, 2008L<
Operating system: 8Microsoft Windows XP @Versione 5.1.2600D<
$MachineType,$ProcessorType,$ByteOrdering,$SystemCharacterEncoding:
8PC, x86,-1, WindowsANSI<
In[9]:= H* graphic output parameters *L Unprotect@"*Sizepic"D;
minSizepic=150;
medSizepic=300;
maxSizepic=500;
Protect@"*Sizepic"D; In[14]:= Unprotect@HamiltonD;
Hamilton@L_,xList_List,pList_List,t_:tD:=
Module@8xx,vv,pp,sol,ham,eqp,eqx,eqs<, xx=Through@xList@tDD;
vv=D@xx,tD;
pp=Through@pList@tDD;
sol=Solve@HD@L,ðD&vvLpp,vvD Flatten;
ham=pp.vv-L.solSimplifyExpand;
eqp=D@pp,tD -Map@D@ham,ðD&,xxD Thread;
eqx=D@xx,tD +Map@D@ham,ðD&,ppD Thread;
eqs=Join@eqx,eqpD; Return@8sol,ham,eqs<D D
H*
sol = relation between generalized velocity and canonical momentum ham = Hamiltonian expressed in terms of canonical variables eqs = equation of motion
from R.L.Zimmerman,F.I.Olness - Mathematica for Physics H2.ed,2002L
*L
Protect@HamiltonD;
In[17]:= Unprotect@PoissonBracketD;
PoissonBracket@f_,g_,q_List,p_ListD ; Length@qD==Length@pD:=
D@f,8q<D.D@g,8p<D-D@f,8p<D.D@g,8q<DH* by Suba Thomas *L Protect@PoissonBracketD;
In[20]:= <<Utilities`Notation`
In[21]:= NotationB8f_, g_<q_,p_ PoissonBracket@f_, g_, q_, p_DF In[22]:= <<Calculus`VariationalMethods`
"Ready, set, go!"
I) Newton mechanics for classical particles
Q
uantum mechanics isn't logically independent from classical mechanics and the most general formulation of classical mechanics is Newton mechanics. So let's solve (numerically) the gravitative three-body-problem in this framework; en passant we also check the conservation laws for an isolated system. Then we take also a look at New- ton's third law in a special case. Gravitative three-body-problem
In[23]:= Remove@"Global`*"D In[24]:= Bewegungsgleichungen =
8
m1 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 2+Hy2@tD-y1@tDL^ 2+Hz2@tD-z1@tDL^ 2L^H32L, m3 x3''@tD -G m3 m2
Hx3@tD-x2@tD L H Hx3@tD-x2@tDL^ 2+Hy3@tD-y2@tDL^ 2+Hz3@tD-z2@tDL^ 2L^ H32L -G m3 m1Hx3@tD-x1@tD L
H Hx3@tD-x1@tDL^ 2+Hy3@tD-y1@tDL^ 2+Hz3@tD-z1@tDL^ 2L^H32L,
m3 y3''@tD -G m3 m2Hy3@tD-y2@tD L H Hx3@tD-x2@tDL^ 2+Hy3@tD-y2@tDL^ 2+ Hz3@tD-z2@tDL^ 2L^H32L -G m3 m1Hy3@tD-y1@tD L
H Hx3@tD-x1@tDL^ 2+Hy3@tD-y1@tDL^ 2+Hz3@tD-z1@tDL^ 2L^H32L,
m3 z3''@tD -G m3 m2Hz3@tD-z2@tD L H Hx3@tD-x2@tDL^ 2+Hy3@tD-y2@tDL^ 2+ Hz3@tD-z2@tDL^ 2L^H32L -G m3 m1Hz3@tD-z1@tD L
H Hx3@tD-x1@tDL^ 2+Hy3@tD-y1@tDL^ 2+Hz3@tD-z1@tDL^ 2L^H32L
<; In[25]:=
In[25]:= G=1;
m1=1;m2=1;m3=1;
Anfangsbedingungen=
8x1@0D0,y1@0D0,z1@0D0,
x1'@0D0.1,y1'@0D0.3,z1'@0D0.1, x2@0D1,y2@0D1,z2@0D1,
x2'@0D0.2,y2'@0D0.3,z2'@0D0.1, x3@0D0,y3@0D1,z3@0D23,
x3'@0D0.3,y3'@0D0.1,z3'@0D0.2<; tmax=5;
NDSolve@8Bewegungsgleichungen, Anfangsbedingungen<,
8x1, y1, z1, x2, y2, z2, x3,y3,z3<, 8t, 0, tmax<D . Rule®SetShort Out[29]//Short=
88InterpolatingFunction@880., 5.<<,<>D,
7, InterpolatingFunction@880., 5.<<,<>D<<
In[30]:= ParametricPlot3D@
88x1@tD, y1@tD,z1@tD, Red<, 8x2@tD, y2@tD,z2@tD, Green<, 8x3@tD, y3@tD,z3@tD, Blue<<,
8t, 0, tmax<, PlotPoints®1000, AxesLabel®8"x", "y", "z"<, PlotLabel®
"A classical gravitative three-body-problem:\norbits of the particles.\n", ImageSize®medSizepicD
Out[30]=
A classical gravitative three-body-problem:
orbits of the particles.
0.0
0.5
1.0
1.5
2.0 x
0.0 0.5
1.0 1.5
2.0 y
0.0 0.5 1.0 1.5
z
Now we search for constants of motion:
a) Total impulse conservation
a) Total impulse conservation
In[31]:= TotalImpulse@t_D=8m1 x1'@tD+ m2 x2'@tD+m3 x3'@tD,
m1 y1'@tD+ m2 y2'@tD+m3 y3'@tD,m1 z1'@tD+ m2 z2'@tD+m3 z3'@tD<; TotalImpulse@0D
TotalImpulse@tmaxD
Plot@Evaluate@TotalImpulse@tDD,8t, 0,tmax<, PlotRange®80, 1<,
PlotLabel®"total impulse components HtimeL", ImageSize®medSizepicD Out[32]= 80.6, 0.7, 0.4<
Out[33]= 80.6, 0.7, 0.4<
Out[34]=
0 1 2 3 4 5
0.2 0.4 0.6 0.8 1.0
total impulse components HtimeL
b) Total angular momentum conservation
In[35]:= TotalAngularMomentum@t_D=m18x1@tD, y1@tD,z1@tD<8x1'@tD, y1'@tD,z1'@tD<+ m28x2@tD, y2@tD,z2@tD<8x2'@tD, y2'@tD,z2'@tD<+
m38x3@tD, y3@tD,z3@tD<8x3'@tD, y3'@tD,z3'@tD<; TotalAngularMomentum@0D
TotalAngularMomentum@tmaxD
Plot@Evaluate@TotalAngularMomentum@tDD,8t, 0,tmax<, PlotRange®8-1, 1<,
PlotLabel®"total angular momentum components HtimeL", ImageSize®medSizepicD Out[36]= 8-0.0666667, 0.3,-0.2<
Out[37]= 8-0.0666666, 0.3,-0.2<
Out[38]=
1 2 3 4 5
-1.0 -0.5 0.5 1.0
total angular momentum components HtimeL
c) Total energy conservation
In[39]:=
In[39]:= TotalEnergy@t_D= m1
2 Ix1'@tD2+ y1'@tD2+z1'@tD2M+ m2
2 Ix2'@tD2+ y2'@tD2+z2'@tD2M+m3
2 Ix3'@tD2+ y3'@tD2+z3'@tD2M- G m1 m2 Hx1@tD-x2@tDL2+Hy1@tD-y2@tDL2+Hz1@tD-z2@tDL2 - G m1 m3 Hx1@tD-x3@tDL2+Hy1@tD-y3@tDL2+Hz1@tD-z3@tDL2 - G m2 m3 Hx2@tD-x3@tDL2+Hy2@tD-y3@tDL2+Hz2@tD-z3@tDL2 ; TotalEnergy@0D
TotalEnergy@tmaxD
PlotATotalEnergy@tD,8t, 0,tmax<, PlotRange®TotalEnergy@0D 91-10-4, 1+10-4=, PlotLabel®"total energy HtimeL", ImageSize®medSizepicE
Out[40]= -2.16308 Out[41]= -2.16309
Out[42]=
0 1 2 3 4 5
-2.1632 -2.1631 -2.1630 -2.1629
total energy HtimeL
Note: Looking very closely we notice a slight decrease of the energy in time which should not appear in a conservative system; this is due to the numerical errors which act like some kind of friction!
d) Inertial motion of center of mass
In[43]:= CenterOfMassPosition@t_D=
Hm18x1@tD, y1@tD,z1@tD<+m28x2@tD, y2@tD,z2@tD<+m38x3@tD, y3@tD,z3@tD<L Hm1+m2+m3L;
CenterOfMassPosition@0D
CenterOfMassPosition@tmaxD-tmax CenterOfMassPosition'@0D
Plot@Evaluate@CenterOfMassPosition@tD-tCenterOfMassPosition'@0DD, 8t, 0,tmax<, PlotRange®80, 1<, PlotLabel®
"reduced center of mass\nposition components HtimeL", ImageSize®medSizepicD Out[44]= 80.333333, 0.666667, 0.555556<
Out[45]= 80.333333, 0.666667, 0.555556<