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

Note:  The problem solution below does not work!

Problem 4:  Harmonic Oscillator and Hamilton-Jacobi Equations

\(TextForm
    \`Consider\ \ a\ one - dimensional\ harmonic\ \(oscillator . \)\)

Part (a)   Express the Hamiltonianin canonical variables and derive and Hamilton-Jacobi equation for W using the user-defined function Hamilton.

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

V = k/2 x[t]^2

L = T - V

{xpRule, ham, eqMotion} = Hamilton[L, {x}, {p}]

pRule = {p[t] -> D[S[x, t], x]}

eqHJ = (ham + D[S[x, t], t]) == 0 //. pRule

sRule = {S -> (W[#1] - P #2 &)}

S[x, t] //. sRule

eqW = eqHJ //. sRule

Part (b)   Solve the Hamilton-Jacobi equation for W to obtain the oscillator solution for {x,p}.

wPrimeRule = Solve[eqW, W'[x]][[2]]

wp  =  W'[x] /. wPrimeRule

wRule = {
        W[x] -> (Integrate[(W'[x] /. wPrimeRule), x] // Hold)}

\(Unprotect[Hold]; 

    D[Hold[Integrate[a_, x_]], b_] ^:= Integrate[D[a, b], x]\)Protect[Hold];

S[x, t] //. sRule

S1[x, t] = S[x, t] //. sRule //. wRule

eq4 = Q == D[S1[x, t], P] /. x[t] -> x /. x -> x[t]

Note: Up to this point all results have been OK.  However, the above result differs from that given on P. 220 of the book, which involves an ArcTan function.  Doing it "by hand" below in either order leads to the same answer.

eq4a  =  
      Q == D[-P t  +  Integrate[(W'[x] /. wPrimeRule), x], 
              P] /. x[t] -> x /. x -> x[t]

eq4b  =  
      Q == D[-P t, P]  + 
              Integrate[ D[(W'[x] /. wPrimeRule), P], x] /. 
          x[t] -> x /. x -> x[t]

xSol = Solve[eq4, x[t]][[2]] // PowerExpand // Simplify

pRule2 = Solve[eqMotion[[2]], p[t]] // Flatten

pSol = 
      {p -> m D[(x[t] //. xSol), t]} // PowerExpand // Simplify