4. Lagrangians and Hamiltonians

Legal Notice, Disclaimer, and Book Ordering Information:

Null

Setup

\(Clear["Global`*"]; 
Off[General::spell]; 
Off[General::spell1]; 
    \)

Needs["Calculus`VectorAnalysis`"]

<< "D:\Mma\Inits\ch4init.m"

Clear["Global`*"];

4.2 Problems

4.2.3  Hamilton and Hamilton-Jacobi Problems

Problem 1:  Harmonic Oscillator and Hamilton's Equation

\(TextForm
    \`Consider\ \ a\ particle\ of\ mass\ m\ moving\ in\ a\ harmonic\ 
        oscillator\ potential\ V\  = \ \((1/2)\) \(kx\^2 . \)\)

Part (a)   Find the Hamiltonian for the system and solve Hamilton's Equation

T = (m/2) x'[t]^2

V = (k/2) x[t]^2

L = T - V

eq1 = p[t] == D[L, x'[t]]

xpRule = Solve[eq1, x'[t]] // Flatten

H = (p[t] x'[t] - L) //. xpRule

\(eq2 = {\(p'\)[t] == \(-D[H, x[t]]\)
			\ \ \ \ , 
        \(x'\)[t] == \(+D[H, p[t]]\)}\)

initial = {p[0] == 0, x[0] == x0};

dsol = DSolve[eq2~Join~initial, {p[t], x[t]}, t] // Flatten

Part (b)   Use the user-defined Hamilton procedure to obtain the Hamiltonain and the equations of motion.

dsolH = Hamilton[L, {x}, {p}]

Part (c)   Consider the non-linear oscillator described by V  =  (1/2) (kx^2) + ϵ(x^5) . Write hamilton's equations.  Assume the solution can be written as a power series in t and use the used-defined firstDiffSeries procedure to find the power series solution.  Find the first-order perturbation solution in the parameter ϵ using the user-defined procedure firstOrderPert.

V1 = ϵ x[t]^5

L1 = T - (V + V1)

{xprule, hamiltonian, eqMotion} = Hamilton[L1, {x}, {p}]

sol1 = 
      firstDiffSeries[eqMotion, {x, p}, {x[0] -> x0, p[0] -> 0}, 3]

sol2 = {x[t], p[t]} -> sol1 // Thread

sol3 = sol2 // Map[(D[#, t]&), #, {2}]&

eqM2 = eqMotion //. Join[sol2, sol3] // Normal // ExpandAll

(eqM2 //. {t^3 -> 0})

eq3 = (eqMotion // First) /. {p'[t] -> m x''[t]}

pert3 = 
      ((firstOrderPert[eq3, x, {x0, 0}, ϵ])) // Simplify

sPert3 = Series[pert3, {t, 0, 3}] // Normal // ExpandAll

test1 = x[t] //. sol2 // Normal // ExpandAll

test1 == sPert3