Exercise 1.16: Central force motion
(require [sicmutils.env :refer :all])
This exercise gives you practice in writing Lagrangians as compositions.
Find Lagrangians for central force motion in three dimensions in rectangular coordinates and in spherical coordinates. First, find the Lagrangians analytically, then check the results with the computer by generalizing the programs that we have presented.
Analytic Approach
Analytically in 3d coordinates, we have a straightforward extension:
formula not implementedHow would you find the spherical Lagrangian analytically?
The potential part is easy. We know that inline_formula not implemented, so the final Lagrangian will have a inline_formula not implemented term.
To transform the kinetic energies:
write down the coordinate transformation from spherical to rectangular:
get the velocity components by taking derivatives, chain rule
substitute these in to the rectangular Lagrangian
This is equivalent to generating inline_formula not implemented, where inline_formula not implemented is a function that substitutes each position inline_formula not implemented or velocity inline_formula not implemented for its spherical representation. inline_formula not implemented is the spherical Lagrangian, inline_formula not implemented is the rectangular.
How do you get the velocities?
Remember, from equation 1.77 in the book:
formula not implementedinline_formula not implemented is the conversion from spherical to rectangular coordinates. inline_formula not implemented is a 3-tuple of inline_formula not implemented, and inline_formula not implemented is a 3-tuple inline_formula not implemented, where:
formula not implementedIt's important to remember that the partials in equation 1.77 are taken as if the arguments were static. The chain rule has already been applied. It's more san
formula not implementedThis has three components; one for each of the components in the return value.
inline_formula not implemented is a tuple with three components, each of which also has three components, one for each of the spherical coordinates.
The inner tuples collapse upon multiplication by inline_formula not implemented, leaving:
formula not implementedSubstituting these in results, eventually, in a waterfall of cancellations and leaves:
formula not implementedClojure Approach
To show the rectangular Lagrangian, get the procedure from page 41:
(defn L-central-rectangular [m U]
(fn [[_ q v]]
(- (* (/ 1 2) m (square v))
(U (sqrt (square q))))))
This is already written in a form that can handle an arbitrary number of coordinates. Confirm the rectangular Lagrangian by passing in a local tuple with 3 dimensional coordinates and velocities:
((L-central-rectangular m (literal-function U))
(up t
(up x y z)
(up v_x v_y v_z)))
Next, the spherical. Write down the coordinate transformation from spherical to rectangular coordinates as a Scheme procedure:
(defn spherical->rect [[_ [r theta phi]]]
(up (* r (sin theta) (cos phi))
(* r (sin theta) (sin phi))
(* r (cos theta))))
Here are the velocities calculated above by hand:
(velocity
((F->C spherical->rect)
(up t
(up r theta phi)
(up rdot thetadot phidot))))
Now that we have inline_formula not implemented and inline_formula not implemented, we can compose them to get inline_formula not implemented, our spherical Lagrangian:
(defn L-central-spherical [m U]
(compose (L-central-rectangular m U)
(F->C spherical->rect)))
Confirm that this is equivalent to the analytic solution:
((L-central-spherical m (literal-function U))
(up t
(up r theta phi)
(up rdot thetadot phidot)))
Discussion
Lagrangian coordinate transformation from spherical -> rectangular on paper, which of course is a total nightmare, writing inline_formula not implemented and simplifying. BUT then, of course, you write down the spherical => rectangular position change…
the explicit link to function composition, and how the new lagrangian is (Lagrangian A + A<-B + B<-C)
… really drives home how coordinate transforms can stack associatively through function composition. the lesson is, prove that the code works, then trust the program to go to crazy coordinate systems.
Later, the authors add in a very simple-to-write coordinate transform that has one of the angles depend on t. and then compose that in, and boom, basically for free you're in rotating spherical coords.