Section: Paths of Minimum Action

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

This section takes us through an example action calculation on a path with an adjustable "variation", or wiggle. We should see that, if we consider a "realizable path", then any wiggle we add will increase the calculated action.

The only restriction on a variation is that it can't affect the endpoints of the realizable path. the times and positions of the start and end of the path are pinned.

make-eta takes some path inline_formula not implemented and returns a function that wiggles in some similar way to inline_formula not implemented, but equals 0 at inline_formula not implemented and inline_formula not implemented:

(defn make-eta [nu t1 t2]
  (fn [t]
    (* (- t t1) (- t t2) (nu t))))

Next, define a function that calculates the Lagrangian for a free particle, like before, but adds in the path variation inline_formula not implemented multiplied by some small scaling factor inline_formula not implemented:

(defn L-free-particle [mass]
  (fn [local]
    (let [v (velocity local)]
      (* (/ 1 2) mass (square v)))))
(defn varied-free-particle-action [mass q nu t1 t2]
  (fn [epsilon]
    (let [eta (make-eta nu t1 t2)]
      (Lagrangian-action (L-free-particle mass)
                         (+ q (* epsilon eta))
                         t1
                         t2))))

And a test path:

(defn test-path [t]
  (up (+ (* 4 t) 7)
      (+ (* 3 t) 5)
      (+ (* 2 t) 1)))

Consider some variation like inline_formula not implemented. The action of the path with this small wiggle (processed through make-eta to pin its endpoints) is larger (top entry) than the action of the non-varied path (bottom entry), as expected:

(let [action-fn (varied-free-particle-action 3.0 test-path
                                             (up sin cos square)
                                             0.0 10.0)]
  (up (action-fn 0.001)
      (action-fn 0)))

What value of inline_formula not implemented minimizes the action for the test path?

We can search over values of inline_formula not implemented from inline_formula not implemented to inline_formula not implemented using the built-in minimize function:

(let [action-fn (varied-free-particle-action
                 3.0 test-path
                 (up sin cos square)
                 0.0 10.0)]
  (:result
   (minimize action-fn -2.0 1.0)))

The result shows that the minimum action occurs at inline_formula not implemented, up to numerical precision.

Finding trajectories that minimize the action

Is it possible to use this principle to actually find a path, instead of simply checking it?

First we need a function that builds a path. This version generates a path of individual points, bracketed by the supplied start and end points inline_formula not implemented and inline_formula not implemented. inline_formula not implemented is a list of intermediate points.

(defn make-path [t0 q0 t1 q1 qs]
  (let [n  (count qs)
        ts (linear-interpolants t0 t1 n)]
    (Lagrange-interpolation-function
     (concat [q0] qs [q1])
     (concat [t0] ts [t1]))))

The next function sort-of-composes make-path and Lagrangian-action into a function that takes inline_formula not implemented and the endpoints, and returns the total action along the path.

(defn parametric-path-action [L t0 q0 t1 q1]
  (fn [qs]
    (let [path (make-path t0 q0 t1 q1 qs)]
      (Lagrangian-action L path t0 t1))))

Finally, find-path takes the previous function's arguments, plus a parameter inline_formula not implemented. inline_formula not implemented controls how many intermediate points the optimizer will inject and modify in its attempt to find an action-minimizing path. The more points you specify, the longer minimization will take, but the more accurate the final path will be.

(defn find-path* [L t0 q0 t1 q1 n]
  (let [initial-qs    (linear-interpolants q0 q1 n)
        minimizing-qs (multidimensional-minimize
                       (parametric-path-action L t0 q0 t1 q1)
                       initial-qs)]
    (make-path t0 q0 t1 q1 minimizing-qs)))

Let's test it out with a Lagrangian for a one dimensional harmonic oscillator with spring constant inline_formula not implemented. Here is the Lagrangian, equal to the kinetic energy minus the potential from the spring:

(defn L-harmonic [m k]
  (fn [local]
    (let [q (coordinate local)
          v (velocity local)]
      (- (* (/ 1 2) m (square v))
         (* (/ 1 2) k (square q))))))

Now we invoke the procedures we've built, and plot the final, path-minimizing trajectory.

(def harmonic-path
  (find-path* (L-harmonic 1.0 1.0) 0.0 1.0 (/ pi 2) 0.0 3))
;; These are unported from Scheme! I'll need to revisit this and get this
;; producing a proper in-browser chart.
;; (define win2 (frame 0.0 :pi/2 0 1))
;; (plot-function win2 harmonic-path 0 :pi (/ :pi 100))

The path looks like a harmonic oscillator that starts high and bounces down, after inline_formula not implemented seconds, down to 0. This is the first quarter of a sine wave with period inline_formula not implemented.

Runtimes (2)