Exercise 1.22: Driven pendulum
(require [sicmutils.env :refer :all])
Show that the Lagrangian (1.93) can be used to describe the driven pendulum (section 1.6.2), where the position of the pivot is a specified function of time: Derive the equations of motion using the Newtonian constraint force prescription, and show that they are the same as the Lagrange equations. Be sure to examine the equations for the constraint forces as well as the position of the pendulum bob.
I might be slightly misunderstanding this question. The problem states that we should use equations 1.91 and 1.92 in the book to express the equations of motion of the driven pendulum, and then to rederive the equations of motion using the Lagrangian.
The final note about examining the constraint forces means that we'll need to follow the approach of equation 1.21 and include a coordinate transformation from some inline_formula not implemented, and then substitute inline_formula not implemented down the road.
Part A: Newton's Equations
Step one is to use 1.91 and 1.92 in the book to express inline_formula not implemented. The only potential is a uniform gravitational potential:
formula not implementedSo equation 1.91 becomes, for the single pendulum bob:
formula not implementedThe assumption here is that the pendulum support sits at inline_formula not implemented.
Part B: Lagrangian
Now write the Lagrangian for the driven pendulum in rectangular coordinates. The constraint force takes the same shape as in exercise 1.21:
(defn U-constraint [q0 q1 F l]
(* (/ F (* 2 l))
(- (square (- q1 q0))
(square l))))
The Lagrangian is similar, but only involves a single particle – the pendulum bob. We can generate the constraint force by directly building the support's coordinates, rather than extracting them from the local tuple.
(defn extract-particle [pieces]
(fn [[t q v] i]
(let [indices (take pieces
(iterate
inc (* i pieces)))
extract (fn [tuple]
(mapv (fn [i]
(ref tuple i))
indices))]
(up t (extract q) (extract v)))))
(defn KE-particle [m v]
(* (/ 1 2) m (square v)))
(defn L-driven-free [m l y U]
(fn [local]
(let [extract (extract-particle 2)
[_ q qdot] (extract local 0)
F (ref (coordinate local) 2)]
(- (KE-particle m qdot)
(U q)
(U-constraint (up 0 (y (state->t local)))
q
F
l)))))
Here is the now-familiar equation for a uniform gravitational potential, acting on the inline_formula not implemented coordinate:
(defn U-gravity [g m]
(fn [[_ y]]
(* m g y)))
Now use the new Lagrangian to generate equations of motion for the three coordinates inline_formula not implemented, inline_formula not implemented and inline_formula not implemented:
(let [q (up (literal-function x)
(literal-function y)
(literal-function F))
U (U-gravity g m)
y (literal-function y_s)
L (L-driven-free m l y U)
f ((Lagrange-equations L) q)]
(f t))
The first two equations of motion match the equations we derived in part A, using Newton's equations. The third states that
formula not implementedVerified, with some extra terms to force the simplification:
(let [q (up (literal-function x)
(literal-function y)
(literal-function F))
U (U-gravity g m)
y (literal-function y_s)
L (L-driven-free m l y U)
f ((Lagrange-equations L) q)
eq (ref (f t) 2)]
(- eq
(/ (* (/ 1 2)
(- (+ (square ((literal-function x) t))
(square ((- y (literal-function y)) t)))
(square l)))
l)))
Part C: Coordinate Change
Now we want to verify that we get the same Lagrangian and equations of motion as in 1.88 from the book. We also want to analyze the constraint forces. To do this we need to introduce a coordinate change.
To analyze the constraint forces, we have to do the same trick as in exercise 1.21 and use a coordinate inline_formula not implemented. The new coordinates are inline_formula not implemented:
(defn driven-polar->rect [y]
(fn [[t [theta c F]]]
(up (* c (sin theta))
(- (y t) (* c (cos theta)))
F)))
Compose the coordinate change with the rectangular Lagrangian:
(defn L-driven-pend [m l y U]
(compose (L-driven-free m l y U)
(F->C (driven-polar->rect y))))
Examine the Lagrangian itself, after the coordinate transformation. (Notice that we're using a constant function for inline_formula not implemented that always returns inline_formula not implemented.)
(let [q (up (literal-function theta)
(fn [_] l)
(literal-function F))
y (literal-function y_s)
L (L-driven-pend m l y (U-gravity g m))
f (compose L (Gamma q))]
(f t))
Looks just like equation 1.88.
Next, examine the Lagrange equations, using the same substitution of inline_formula not implemented:
(let [q (up (literal-function theta)
(fn [_] l)
(literal-function F))
y (literal-function y_s)
L (L-driven-pend m l y (U-gravity g m))
f ((Lagrange-equations L) q)]
(f t))
The third equation is 0 because of the substitution of constant inline_formula not implemented. The first equation of motion, for inline_formula not implemented, is identical to the equation on page 52.
The second equation describes the constraint force on the driven pendulum as a function of the other coordinates and the support position.