Section 1.4: Computing Actions
(require [sicmutils.env :refer :all])
I don't plan on doing this for every section in the book, but section 1.4 is the first place where we're introduced to Scheme, so I followed along and made a few notes.
This is the first demo of how any of this stuff works, starting on page 15. Here's our first Lagrangian, super simple.
(defn L-free-particle [mass]
(fn [local]
(let [v (velocity local)]
(* (/ 1 2) mass (square v)))))
L-free-particle
is a function that takes some mass
and returns a new function. The new function takes an instance of a "local tuple" and returns the value of the "Lagrangian". This is the function that you query at every point along some evolving path in configuration space. For realizable physical paths, the integral of this function should by minimized, or stationary.
Why? That's what we're trying to develop here.
Suppose we let inline_formula not implemented denote a coordinate path function that maps time to position components:
(def q
(up (literal-function x)
(literal-function y)
(literal-function z)))
inline_formula not implemented is a function that takes a coordinate path and returns a function of time that gives the local tuple.
The value inline_formula not implemented returns is called the "local tuple":
((Gamma q) t)
This is just inline_formula not implemented Where inline_formula not implemented is the derivative. (Preview: can a component of the coordinate path depend on the others? YES, and that would impose constraints beyond the degrees of freedom you'd guess by just counting the coordinates.)
Composing the Lagrangian with inline_formula not implemented gives you a function that computes the Lagrangian at some instant:
((compose (L-free-particle m) (Gamma q)) t)
This particular formula is written in terms of inline_formula not implemented coordinates, but that only came from the definition of inline_formula not implemented. As we'll see later, you could write a coordinate transformation from some other totally different style of coordinates (called "generalized coordinates") and the Lagrangian would look different, but return the same value.
This function calculates the action inline_formula not implemented:
(defn Lagrangian-action [L q t1 t2]
(definite-integral (compose L (Gamma q)) t1 t2))
Here's an example path that a particle might take, moving along a straight line as a function of inline_formula not implemented.
(defn test-path [t]
(up (+ (* 4 t) 7)
(+ (* 3 t) 5)
(+ (* 2 t) 1)))
Calculate the action for a particle of mass 3, between inline_formula not implemented and inline_formula not implemented:
(Lagrangian-action (L-free-particle 3) test-path 0.0 10.0)
This happens to be the minimal action, since the path we provided was a uniform path and the Lagrangian was for a free particle. If we'd provided a different path, we would still get an action. Just not a stationary action. Infinitesimal wiggles would change the action.