4. Lagrangians and Hamiltonians

Legal Notice, Disclaimer, and Book Ordering Information:

Null

Setup

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

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

4.2 Problems

4.2.3  Hamiltonian Problems

Problem 3:  Spherical Pendulum  and Hamilton's Equations

Clear["Global`*"];

Part (a)   Find Hamilton's equations for the variables {θ,ϕ}.  Eliminate the ϕ variableand reduce Hamilton's equations to a non-linear equation for θ.  Restrict the pendulum motion to a plane and show that the solution resuces to a standard pendulum equation.

T=(1/2) m (Len^2) (((θ'[t])^2)+Sin[θ[t]]^2 ((ϕ'[t])^2))

V = m g Len (1 - Cos[θ[t]])

L = T - V

{prule, ham, eqMotion} = 
      Hamilton[L, {θ, ϕ}, {pθ, pϕ}, t]

eqMotion

eqMotion = eqMotion //. {pϕ -> (pϕ0&)}

eqMotion[[{1, 3}]]

pθRule = 
      ToRules[eqMotion[[1]]]

eq1 = 
      Simplify[ExpandAll[
          (((∂_t) #1&)/@#1&)[
              eqMotion[[3]]] //. 
            pθRule]]

Normal[
      ((Series[#1, {θ[t], 0, 1}]&)/@#1&)[eq1] //. {
          pϕ0 -> 0}]

Part (b)   Assume the pendulum equation can be expanded in a power series and solve for the first few terms.  Assume g=1, m=1, and Len=1, and intial conditions {θ[0]=π/4,`q`'[0]=0}.  Find numerical solutions for θ when pϕ[0]=0 (planar pendulum) and for pϕ[0]=0.2.

pert=Simplify[diffSeriesOne[eq1,θ,t,6,{θ[0] -> θ0,θ'[0]->0}]];

pert + O[t]^3

values = {g -> 1, m -> 1, Len -> 1};

initial={θ[0] == (π/4),θ'[0]==0};

\(ndsol1 = 
      \(NDSolve[
          \(Join[{eq1}, initial] //. values\) //. {pϕ0 -> 0}, {
            θ}, {t, 0, 8}]\)[[1
        ]]; 
θ1[t_] = θ[t] //. ndsol1; 

    θ1[3.4]\)

\(ndsol2 = 
      \(NDSolve[
          \(Join[{eq1}, initial] //. values\) //. {pϕ0 -> 0.2}, {
            θ}, {t, 0, 8}]\)[[1
        ]]; 
θ2[t_] = θ[t] //. ndsol2; 

    θ2[3.4]\)

Part (c)   On the same graph, plot the following solutions:
	1. The power series solution for the parameters in Part (b) with pϕ[0]=0.2
	2.  The numerical solution found in Part (b) with pϕ[0]=0
	3.  The numerical solution found in Part (b) with pϕ[0]=0.2
	4.  The linear pendulum solution iven by the function θ0 Cos[t]

θ3[t_] = 
      Normal[N[pert //. values //. {θ0 -> (π/4), 
              pϕ0 -> 0.2}]]

θ4[t_] = θ0 Cos[t] //. {θ0 -> (π/4)}

Plot[
      Evaluate[{θ1[t], θ2[t], θ3[t], θ4[t]}], {t, 
        0, 8}, PlotStyle 
        -> {{Dashing[{1.00, 0.00}], Thickness[0.010]}, {
            Dashing[{0.08, 0.010}], Thickness[0.008]}, {
            Dashing[{0.06, 0.02}], Thickness[0.006]}, {Dashing[{1, 0}], 
            Thickness[0.002]}}, Frame -> True, 
      GridLines -> Automatic, PlotRange -> {-1, 1}];