Exercise 1.17: Bead on a helical wire

(require '[sicmutils.env :refer :all])

This, and the next three exercises, are here to give you practice in the real art, of difficulty, of any dynamics problem. It's easy to change coordinates. So what coordinates do you use?

A bead of mass inline_formula not implemented is constrained to move on a frictionless helical wire. The helix is oriented so that its axis is horizontal. The diameter of the helix is inline_formula not implemented and its pitch (turns per unit length) is inline_formula not implemented. The system is in a uniform gravitational field with vertical acceleration inline_formula not implemented. Formulate a Lagrangian that describes the system and find the Lagrange equations of motion.

I'll replace this with a better picture later, but this is the setup:

(defn turns->rect [d h]
  (fn [local]
    (let [turns (coordinate local)
          theta (* turns 2 'pi)]
      (up (/ turns h)
          (* (/ d 2) (cos theta))
          (* (/ d 2) (sin theta))))))

Or you could do this. Remember, these transformations need to be functions of a local tuple, so if you're going to compose them, remember to put coordinate at the beginning of the composition.

(defn turns->x-theta [h]
  (fn [q]
    (up (/ q h)
        (* q 2 'pi))))
(defn x-theta->rect [d]
  (fn [[x theta]]
    (up x
        (* (/ d 2) (cos theta))
        (* (/ d 2) (sin theta)))))
(defn turns->rect* [d h]
  (compose (x-theta->rect d)
           (turns->x-theta h)
           coordinate))

The transformations are identical:

((- (turns->rect 'd 'h)
    (turns->rect* 'd 'h))
 (up 't 'n 'ndot))

Define the Lagrangian:

(defn L-rectangular [m U]
  (fn [[_ q v]]
    (- (* (/ 1 2) m (square v))
       (U q))))
(defn L-turns [m d h U]
  (compose (L-rectangular m U)
           (F->C (turns->rect d h))))

The potential is a uniform gravitational acceleration:

(defn U-grav [m g]
  (fn [q]
    (* m g (ref q 2))))

Final Lagrangian:

((L-turns 'm 'd 'h (U-grav 'm 'g))
 (up 't 'n 'ndot))

Lagrange equations of motion:

(let [L (L-turns 'm 'd 'h (U-grav 'm 'g))
      n (literal-function 'n)]
  (((Lagrange-equations L) n) 't))
Runtimes (1)