4. Lagrangians and Hamiltonians

Setup

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

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

4.2 Problems

4.2.1  Lagrangian Problems

Problem 1:  Atwood's Machine

Clear["Global`*`"];

Part (a)   Express the Lagrangian in terms only of x[1].  Find the equations of motion and solve.

lenRule = x[2] -> ((Len - x[1][#])&)

T = 1/2 Sum[m[i] D[x[i][t], t]^2, {i, 1, 2}]

V = -g Sum[m[i] x[i][t], {i, 1, 2}]

L = T - V /. lenRule // Simplify

eq1 = Lag[x[1], L]

initial = {x[1][0] == x0,  x[1]'[0] == v0}

sol = 
      DSolve[Join[{eq1}, initial], x[1][t], t] // Flatten // Simplify

Part (b)   Express the Lagrangian in terms of x[1] and x[2]. Find the Larangian multipliers from the constraint that the cord does not stretch.   Find the equations of motion for x[1] and x[2] using Lagrange multipliers.  Solve for the motion.

L = T - V

f[1] =  x[1][t]  +  x[2][t]  -  Len

Q[i_] := Sum[D[f[j], x[i][t]] λ[j], {j, 1, 1}]

Array[Q, 2]

eq2 = Table[Lag[x[i], L, Q[i]], {i, 1, 2}]

f[1] == 0

eq3 = D[f[1] == 0, {t, 2}]

\(eq4 = 
      \((Solve[Join[eq2, {eq3}], 

              		{λ[1], \(\(x[2]'\)'\)[t], \(\(x[1]'\)'\)[t]}, t] // 
            Flatten)\)
 /. {Rule -> Equal}\)

initial = {x[1][0] == x0,  x[1]'[0] == v0};

\(sol1 = 
      \(DSolve[eq4[\([{3}]\)]~Join~initial
				, {\(x[1]\)[t]}, t] // 
          Flatten\) // FullSimplify\)

sol2 = {x[2][t] -> Len - x[1][t] /. sol1}

Problem 2:  Bead Sliding on a Rotating Wire

Clear["Global`*`"];

Needs["Calculus`VectorAnalysis`"]

Part (a)   Solve for the motion of the bead assuming r[0]=r0 amd r'[0]=v0.  Express the results in terms of hyperbolic functions.

\(x2rRule = {x, y, z} -> {\((r[#]\ Sin[θ] Cos[ω\ #])\)&, 

            			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \((r[#]\ Sin[θ] Sin[ω\ #])\)&, 

            			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
            \((\(-r[#]\)\ Cos[θ]\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ )
                \)&}
					 // Thread\)

T = 
      m/2 (x'[t]^2  +  y'[t]^2  + z'[t]^2) //. x2rRule // 
        Simplify

V = m g z[t] //. x2rRule

L = T - V // TrigReduce // Collect[#, {m}]&

eq1 = Lag[r, L]

\(rSol = 
      \((\(Solve[eq1, \(\(r'\)'\)[t]]
					 // Flatten\)
					 // 
            Simplify
		\ \ \ \ \ )\) /. {Rule -> Equal}\)

initial = {r[0] == r0, r'[0] == v0}

\(rRule = 
      \(\(DSolve[Join[rSol, initial], r[t], t]
				 // Flatten\) // 
          ExpToTrig\) // Simplify\)

Part (b)   Let r0 and v0 be 0 at t=0 and find the time it takes for the bead to move a distance Len.  Evaluate the time for the special case θ=0.

tRule = 
      Solve[Len == r[t] /. rRule /. {v0 -> 0, r0 -> 0}, t][
          [2]] // Simplify

Limit[t //. tRule, θ -> 0] // PowerExpand

Part (c)   Let r0 and v0 be 0 at t=0 and graph the motion of the bead as a function of time..

values = {θ -> π/13, g -> 1, ω -> 2, v0 -> 0, r0 -> 0}

position = 
      ({x[t], y[t], z[t]} //. x2rRule //. rRule //. values // N);

\(\(p1 = 
      ParametricPlot3D[position // Evaluate, {t, 0, 6}
	\ \ , 
        Boxed -> True
		, Axes -> False
	\ \ , BoxRatios -> {1, 1, 1}

        	]; \)\)

disPoints = Table[position, {t, 0, 6, 0.5}];

\(\(disGraphics\  = \ 
      Graphics3D[{PointSize[0.03]
			, Point/@disPoints}]; \)\)

\(\(Show[disGraphics, p1
	\ , BoxRatios -> {1, 1, 1}]; \)\)