1.6 How to Find Lagrangians
It is possible to work back from Newton’s second law and obtain the Lagrangian $L = T - V$.
Constant Acceleration
Consider a particle of mass $m$ in a gravitational field with acceleration, $g$. The potential energy is $mgh$ and kinetic energy is $\frac{1}{2} m v^2$. Therefore, a Lagrangian for the system is:
The EOMs for this system can be obtained by applying the EL equations as follows:
(defn L-const-accel [m g]
(fn [[_ [x y] [v_x v_y]]]
(- (* 1/2 m (+ (square v_x) (square v_y))) (* m g y))))
(let [L (L-const-accel 'm 'g)
state (up (literal-function 'x) (literal-function 'y))]
(rendertex (((Lagrange-equations L) state) 't)))
The above equations describe constant velocity in the $x$ direction and constant acceleration in the $y$ direction.
Central Force Field
Consider the motion of a particle of mass $m$ through a potential field, $U(r)$ whose value depends only on the distance $r$ to the center of attraction (e.g. gravity). In rectangular coordinates, the Lagrangian is:
Applying EL equations, the equations of motion can be derived as:
(defn L-central-rectangular [m U]
(fn [[_ [x y] [v_x v_y]]]
(let [r (sqrt (+ (square x) (square y)))]
(- (* 1/2 m (+ (square v_x) (square v_y))) (U r)))))
(def eom-central-rectangular (let [L (L-central-rectangular 'm (literal-function 'U))]
(Lagrange-equations L)))
(let [state (up (literal-function 'x) (literal-function 'y))]
(rendertex ((eom-central-rectangular state) 't)))
These equations can be rewriten as:
This is the same form as two components of $F = ma$ where the particle is acted upon by a radial force of magnitude $-D U(r)$.
If we describe the system in polar coordinates instead, then $x = r \cos{\varphi} \text{ and } y = r \sin{\varphi}$.
Consider a configuration path that is represented in both rectangular and polar coordinates. Let $\widetilde{x}$ and $\widetilde{y}$ be components of the rectangular coordinate path, and let $\widetilde{r}$ and $\widetilde{\varphi}$ be components of the corresponding polar coordinate path. Applying the above conversion and differentiating, we get:
From the above expressions for generalized velocities, the expression for kinetic energy can be obtained as:
And the Lagrangian as:
Applying Lagrange’s Equations, we get:
(defn L-central-polar [m U]
(fn [[_ [r phi] [rdot phidot]]]
(- (* 1/2 m (+ (square rdot) (* (square r) (square phidot)))) (U r))))
(def eom-central-polar (let [L (L-central-polar 'm (literal-function 'U))]
(Lagrange-equations L)))
(let [state (up (literal-function 'r) (literal-function 'varphi))]
(rendertex ((eom-central-polar state) 't)))
;; F->C in book
(defn F2C [F]
(fn [q-prime]
((Gamma (F q-prime)) 't)
))
(defn p2r [[_ [r phi] [rdot phidot]]]
(let [x (* r (cos phi))
y (* r (sin phi))]
(up x y)))
;; Local tuple after coordinate conversion from polar -> rectilinear
(rendertex ((F2C p2r)
(up 't
(up (literal-function 'r) (literal-function 'phi))
(up (literal-function 'rdot) (literal-function 'phidot)))
))
The first equation says that mass times radial acceleration is equal to the sum of the force due to the potential field ($U(r)$) and the centrifugal force $mr\dot{\varphi}^2$. The second equation can be interpreted as $\frac{d}{dt}(mr^2 \dot{\varphi}) = 0$ or that the angular momentum is conserved.