Exercise 1.15: Equivalence

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

This is one of the more important exercises in the chapter. The problem asks for a proof that it's possible to absorb a coordinate transformation directly into the Lagrangian. If you can do this, you can express your paths and your forces in whatever coordinates you like, so long as you can transition between them.

I also found that this exposed, and repaired, my weakness with the functional notation that Sussman and Wisdom have used in the book.

The problem states:

Show by direct calculation that the Lagrange equations for inline_formula not implemented are satisfied if the Lagrange equations for inline_formula not implemented are satisfied.

Definitions and Preliminaries

inline_formula not implemented and inline_formula not implemented refer to ideas from section 1.6.1. The major promise of Lagrangian mechanics is that both the potential and kinetic energies are coordinate-independent; looking at the system through different coordinates can't affect the energy in the system, or you've dropped some information in the conversation. If this is true, then the value of the Lagrangian, equal to inline_formula not implemented, must be coordinate independent too.

Imagine a coordinate transformation inline_formula not implemented, maybe time-dependent, that can convert "primed coordinates" like inline_formula not implemented into "unprimed coordinates", inline_formula not implemented:

formula not implemented

You might imagine that inline_formula not implemented is in polar coordinates and inline_formula not implemented is in rectangular coordinates. Time-dependence means that the coordinate system itself is moving around in time. Imagine looking at the world out of a spinning window.

Now imagine some Lagrangian inline_formula not implemented that acts on a local tuple built out of the unprimed coordinates. If the Lagrangian's value is coordinate-independent, there must be some other form, inline_formula not implemented, that can act on the primed coordinates. inline_formula not implemented has to satisfy:

formula not implemented

The function inline_formula not implemented only acts on specific coordinates. Imagine a function inline_formula not implemented that uses inline_formula not implemented to transform the entire local tuple from the primed coordinates to the unprimed coordinates:

formula not implemented

Function composition is associative, so two facts stare at us from \eqref{eq:1-15-relations}:

formula not implemented

This implies that if we want describe our path in some primed coordinate system (imagine polar coordinates), but we only have a Lagrangian defined in an unprimed coordinate system (like rectangular coordinates), if we can just write down inline_formula not implemented we can generate a new Lagrangian inline_formula not implemented by composing our old inline_formula not implemented with inline_formula not implemented. This brings us to the exercise.

The goal is to show that if the Lagrange equations hold in the unprimed coordinate system:

formula not implemented

Then they hold in the primed coordinate system:

formula not implemented

Approach

The approach we'll take will be to:

  • Write down the form of inline_formula not implemented, given some arbitrary inline_formula not implemented

  • start calculating the terms of the Lagrange equations in the primed coordinate system using inline_formula not implemented

  • Keep an eye out for some spot where we can use our assumption that the Lagrange equations hold in the unprimed coordinates.

I'll walk through a solution using "pen and paper", then show how we can run this derivation using Scheme to help us along.

First, some Scheme tools that will help us in both cases.

Clojure Tools

Equation (1.77) in the book describes how to implement inline_formula not implemented given some arbitrary inline_formula not implemented. Looking ahead slightly, this is implemented as F->C on page 46.

The following function is a slight redefinition that allows us to use an inline_formula not implemented that takes an explicit inline_formula not implemented, instead of the entire local tuple:

(defn F->C* [F]
  (fn [[t x v]]
    (up t
        (F t x)
        (+ (((partial 0) F) t x)
           (* (((partial 1) F) t x)
              v)))))

Next we define inline_formula not implemented, inline_formula not implemented and inline_formula not implemented as described above, as well as qprime, a function that can represent our unprimed coordinate path function.

The types here all imply that the path has one real coordinate. I did this to make the types easier to understand; the derivation applies equally well to paths with many dimensions.

(def F
  (literal-function 'F (-> (X Real Real) Real)))
(def C (F->C* F))
(def L
  (literal-function 'L (-> (UP Real Real Real) Real)))
(def qprime
  (literal-function 'qprime))

When we apply inline_formula not implemented to the primed local tuple, do we get the transformed tuple that we expect from 1.77 in the book?

((compose C (Gamma qprime)) 't)

This looks correct. We can also transform the path before passing it to inline_formula not implemented:

(defn to-q [F qp]
  (fn [t]
    (F t (qp t))))

Subtract the two forms to see that they're equivalent:

((- (compose C (Gamma qprime))
    (Gamma (to-q F qprime)))
 't)

Now that we know inline_formula not implemented is correct we can define inline_formula not implemented, the unprimed coordinate path function, and Lprime:

(def q (to-q F qprime))
(def Lprime (compose L C))

Derivation

Begin by calculating the components of the Lagrange equations in equation \eqref{eq:lagrange-prime}. Examine the inline_formula not implemented term first.

As we discussed above, function composition is associative, so:

formula not implemented

Substituting inline_formula not implemented from \eqref{eq:c-l} and using the chain rule:

formula not implemented

I found the next step troubling until I became more comfortable with the functional notation.

inline_formula not implemented is a function that transforms a local tuple. It takes 3 arguments (a tuple with 3 elements, technically) and returns 3 arguments. inline_formula not implemented is an up-tuple with 3 entries. Each entry describes the derivative each component of inline_formula not implemented's output with respect to the velocity component of the local tuple.

inline_formula not implemented is a function that transforms the 3-element local to a scalar output. inline_formula not implemented is a down-tuple with 3 entries. Each entry describes the derivative of the single output with respect to each entry of the local tuple.

The tuple algebra described in Chapter 9 defines multiplication between an up and down tuple as a dot product, or a "contraction" in the book's language. This means that we can expand out the product above:

formula not implemented

inline_formula not implemented, inline_formula not implemented and inline_formula not implemented are "selectors" that return that single element of the local tuple.

Example the value of inline_formula not implemented using our Scheme utilities:

(->tex-equation
 (((partial 2) C) (up 't 'xprime 'vprime))
 :label "eq:p2c")

The first two components are 0, leaving us with:

formula not implemented

Compose this quantity with inline_formula not implemented and distribute the composition into the product. Remember that inline_formula not implemented:

formula not implemented

Take the derivative (with respect to time, remember, from the types):

formula not implemented

Substitute the second term using \eqref{eq:p2c}:

formula not implemented

Expand using the product rule:

formula not implemented

A term from the unprimed Lagrange's equation is peeking. Notice this, but don't make the substitution just yet.

Next, expand the inline_formula not implemented term:

formula not implemented

Calculate inline_formula not implemented using our Scheme utilities:

(((partial 1) C) (up 't 'xprime 'vprime))

Expand the chain rule out and remove 0 terms, as before:

formula not implemented

Compose inline_formula not implemented and distribute:

formula not implemented

We now have both components of the primed Lagrange equations from \eqref{eq:lagrange-prime}.

Subtract the two terms, extract common factors and use our assumption \eqref{eq:1-15-lagrange} that the original Lagrange equations hold:

formula not implemented

And boom, we're done! The primed Lagranged equations \eqref{eq:lagrange-prime} hold if the unprimed equations \eqref{eq:1-15-lagrange} hold.

I'm not sure what to make of the new constant terms. The new Lagrange equations are scaled by inline_formula not implemented, the derivative of inline_formula not implemented with respect to the path; that seems interesting, and possibly there's some nice physical intuition waiting to be discovered.

Scheme Derivation

Can we use Scheme to pursue the same derivation? If we can write the relationships of the derivation in code, then we'll have a sort of computerized proof that the primed Lagrange equations are valid.

First, consider inline_formula not implemented:

((compose ((partial 1) Lprime) (Gamma qprime))
 't)

This is completely insane, and already unhelpful. The argument to inline_formula not implemented, we know, is actually inline_formula not implemented. Make a function that will replace the tuple with that reference:

(defn ->eq [expr]
  (clojure.string/replace
   (->tex-equation expr)
   (->TeX (simplify ((Gamma q) 't)))
   "\\Gamma[q]\\left(t\\right)"))

Try again:

(->eq
 ((compose ((partial 1) Lprime) (Gamma qprime))
  't))

The inline_formula not implemented term of the unprimed Lagrange equations is nestled inside the expansion above, multiplied by a factor inline_formula not implemented:

(let [factor (((partial 1) F) 't (qprime 't))]
  (->eq
   ((* factor (compose ((partial 1) L) (Gamma q)))
    't)))

Next, consider the inline_formula not implemented term:

(->eq
 ((D (compose ((partial 2) Lprime) (Gamma qprime)))
  't))

This, again, is total madness. We really want some way to control how Scheme expands terms.

But we know what we're looking for. Expand out the matching term of the unprimed Lagrange equations:

(->eq
 ((D (compose ((partial 2) L) (Gamma q)))
  't))

Staring at these two equations, it becomes clear that the first contains the second, multiplied by inline_formula not implemented, the same factor that appeared in the expansion of the inline_formula not implemented term.

Try writing out the primed Lagrange equations, and subtracting the unprimed Lagrange equations, scaled by this factor:

(let [primed-lagrange
      (- (D (compose ((partial 2) Lprime) (Gamma qprime)))
         (compose ((partial 1) Lprime) (Gamma qprime)))
      lagrange
      (- (D (compose ((partial 2) L) (Gamma q)))
         (compose ((partial 1) L) (Gamma q)))
      factor
      (compose coordinate ((partial 1) C) (Gamma qprime))]
  ((- primed-lagrange (* factor lagrange))
   't))

Done! It seems that the extra terms on each side exactly cancel. As with the pen and paper derivation, we've shown that the primed Lagranged equations \eqref{eq:lagrange-prime} hold if the unprimed equations \label{eq:1-15-lagrange} hold.

Final Comments

I'm troubled by my lack of intuition around two ideas:

  • what is the meaning of the inline_formula not implemented scaling factor?

  • Both sides acquire a constant inline_formula not implemented.

The right factor is a total time derivative. Is this meaningful? We know from later discussion that if we add a total time derivative to the Lagrangian we don't affect the shape of the realizable path.

I learned quite a bit about functional notation from this exercise, and I think that test that the result represents is critical for leaning hard on the coordinate transformations that we'll continue to explore. But I do feel like I'm leaving intuitive cake on the table.

Runtimes (1)