# The Principle of Stationary Action

Varying the action

$\displaystyle{S[q](t_1, t_2) = \int_{t_1}^{t_2} L \circ \Gamma[q]}$

.

The Principle of Stationary Action

$\displaystyle{\delta_\eta S[q] (t_1, t_2) = 0}$

$\delta_\eta S[q] (t_1, t_2) = \int_{t_1}^{t_2} \delta_\eta L \circ \Gamma[q]$

— Structure and Interpretation of Classical Mechanics

.

.

2019.05.13 Monday ACHK

# Ex 1.8 Implementation of $\delta$

\displaystyle{ \begin{aligned} \delta_\eta f[q] &= \lim_{\epsilon \to 0} \left( \frac{f[q+\epsilon \eta]-f[q]}{\epsilon} \right) \\ \end{aligned}}

The variation may be represented in terms of a derivative.

— Structure and Interpretation of Classical Mechanics

\displaystyle{ \begin{aligned} g( \epsilon ) &= f[q + \epsilon \eta] \\ \delta_\eta f[q] &= \lim_{\epsilon \to 0} \left( \frac{g(\epsilon) - g(0)}{\epsilon} \right) \\ &= D g(0) \\ \end{aligned}}

.

A lambda expression evaluates to a procedure. The environment in effect when the lambda expression is evaluated is remembered as part of the procedure; it is called the closing environment.

— Structure and Interpretation of Classical Mechanics

(define (((delta eta) f) q)
(let ((g (lambda (epsilon) (f (+ q (* epsilon eta))))))
((D g) 0)))


— Me@2019-05-05 10:47:46 PM

.

.

# Varying a path

Suppose that we have a function $\displaystyle{f[q]}$ that depends on a path $\displaystyle{q}$. How does the function vary as the path is varied? Let $\displaystyle{q}$ be a coordinate path and $\displaystyle{q + \epsilon \eta}$ be a varied path, where the function $\displaystyle{\eta}$ is a path-like function that can be added to the path $\displaystyle{q}$, and the factor $\displaystyle{\epsilon}$ is a scale factor. We define the variation $\displaystyle{ \delta_\eta f[q]}$ of the function $\displaystyle{f}$ on the path $\displaystyle{q}$ by

$\displaystyle{\delta_\eta f [q] = \lim_{\epsilon \to 0} \left( \frac{f[q + \epsilon \eta] - f[q]}{\epsilon} \right)}$

The variation of $\displaystyle{f}$ is a linear approximation to the change in the function $\displaystyle{f}$ for small variations in the path. The variation of $\displaystyle{f}$ depends on $\displaystyle{\eta}$.

— 1.5.1 Varying a path

— Structure and Interpretation of Classical Mechanics

.

Exercise 1.7. Properties of $\displaystyle{\delta}$

The meaning of $\displaystyle{\delta_\eta (fg)[q]}$ is

$\displaystyle{\delta_\eta (f[q]g[q])}$

— Me@2019-04-27 07:02:38 PM

.

.

2019.04.27 Saturday ACHK

# scmutils

In order to run the SICM code, you need to install the scmutils library. Just go to the official page to download the library and follow the official instructions to install it in a Linux operating system.

When you try to run it, your system may give the following error message:

/usr/local/bin/mechanics: line 16: exec: xterm: not found


If so, you should install the program xterm first.

.

Also, in case you like to use Emacs as editor, you can:

Just include the following in your .emacs file:

(defun mechanics ()
(interactive)
(run-scheme
"ROOT/mit-scheme/bin/scheme --library ROOT/mit-scheme/lib"
))


Replace ROOT with the directory in which you installed the scmutils software. (Remember to replace it in both places. If it is installed differently on your system, just make sure the string has the form “/path/to/mit-scheme --library /path/to/scmutils-library“.) Restart emacs (or use C-x C-e to evaluate the mechanics defun), and launch the environment with the command M-x mechanics.

— Using GNU Emacs With SCMUtils

— Aaron Maxwell

.

In my Ubuntu 18.04, the paths are:

(defun mechanics()
(interactive)
(run-scheme
"/usr/local/scmutils/mit-scheme/bin/scheme --library
/usr/local/scmutils/mit-scheme/lib"
))


— Me@2019-04-07 02:52:50 PM

.

.

# Finding trajectories that minimize the action

We have used the variational principle to determine if a given trajectory is realizable. We can also use the variational principle to find trajectories. Given a set of trajectories that are specified by a finite number of parameters, we can search the parameter space looking for the trajectory in the set that best approximates the real trajectory by finding one that minimizes the action. By choosing a good set of approximating functions we can get arbitrarily close to the real trajectory.

— Structure and Interpretation of Classical Mechanics

.

We have used the variational principle to determine if a given trajectory is realizable.

How?

— Me@2019-03-29 04:23:36 PM

.

Check if the action of that given trajectory is stationary or not.

— Me@2019-03-29 04:25:45 PM

.

.

# Lagrangians in generalized coordinates

The function $\displaystyle{S_\chi}$ takes a coordinate path; the function $\displaystyle{\mathcal{S}}$ takes a configuration path.

\displaystyle{\begin{aligned} \mathcal{S} [\gamma] (t_1, t_2) &= \int_{t_1}^{t_2} \mathcal{L} \circ \mathcal{T} [\gamma] \\ S_\chi [q] (t_1, t_2) &= \int_{t_1}^{t_2} L_\chi \circ \Gamma [q] \\ \end{aligned}}

\displaystyle{\begin{aligned} \mathcal{S} [\gamma] (t_1, t_2) &= S_\chi [\chi \circ \gamma] (t_1, t_2) \\ \end{aligned}}

# Computing Actions

$\displaystyle{\texttt{literal-function}}$ makes a procedure that represents a function of one argument that has no known properties other than the given symbolic name.

The method of computing the action from the coordinate representation of a Lagrangian and a coordinate path does not depend on the coordinate system.

# Exercise 1.4. Lagrangian actions

For a free particle an appropriate Lagrangian is

\displaystyle{\begin{aligned} L(t,x,v) &= \frac{1}{2} m v^2 \\ \end{aligned}}

Suppose that $x$ is the constant-velocity straight-line path of a free particle, such that $x_a = x(t_a)$ and $x_b = x(t_b)$. Show that the action on the solution path is

\displaystyle{\begin{aligned} \frac{m}{2} \frac{(x_b - x_a)^2}{t_b - t_a} \\ \end{aligned}}

— Structure and Interpretation of Classical Mechanics

.

\displaystyle{\begin{aligned} L(t,x,v) &= \frac{1}{2} m v^2 \\ \end{aligned}}

\displaystyle{\begin{aligned} S_\chi [\gamma] (t_1, t_2) &= \int_{t_1}^{t_2} L_\chi (t, q(t), Dq(t)) dt \\ &= \int_{t_2}^{t_1} \frac{1}{2} m v^2 dt \\ &= \frac{1}{2} m v^2 \int_{t_2}^{t_1} dt \\ &= \frac{1}{2} m v^2 (t_2 - t_1) \\ &= \frac{1}{2} m (\frac{x_2 - x_1}{t_2 - t_1})^2 (t_2 - t_1) \\ &= \frac{1}{2} m \frac{(x_2 - x_1)^2}{t_2 - t_1} \\ \end{aligned}}

— Me@2006-2008

— Me@2019-03-10 11:08:29 PM

.

.

# Configuration Spaces

The set of all configurations of the system that can be assumed is called the configuration space of the system.

## Generalized Coordinates

1. In order to be able to talk about specific configurations we need to have a set of parameters that label the configurations. The parameters used to specify the configuration of the system are called the generalized coordinates.

2. The $\displaystyle{n}$-dimensional configuration space can be parameterized by choosing a coordinate function $\displaystyle{\chi}$ that maps elements of the configuration space to $n$-tuples of real numbers.

3. The motion of the system can be described by a configuration path $\displaystyle{\gamma}$ mapping time to configuration-space points.

4. Corresponding to the configuration path is a coordinate path $\displaystyle{q = \chi \circ \gamma}$ mapping time to tuples of generalized coordinates.

The function $\displaystyle{\Xi \chi}$ takes the coordinate-free local tuple $\displaystyle{( t, \gamma (t), \mathcal{D} \gamma (t), ... )}$ and gives a coordinate representation as a tuple of the time, the value of the coordinate path function at that time, and the values of as many derivatives of the coordinate path function as are needed.

\displaystyle{ \begin{aligned} \text{generalized coordinate representation} &= \Xi (\text{local tuple}) \\ (t, q(t), Dq(t), ...) &= \Xi_\chi (t, \gamma(t), \mathcal{D} \gamma(t), ...) \\ \end{aligned} }

\displaystyle{ \begin{aligned} \text{generalized coordinates} &= q \\ &= \chi \circ \gamma \\ \\ q(t) &= \chi(\gamma(t)) \\ \end{aligned} }

\displaystyle{ \begin{aligned} t &\to \gamma: \text{configuration path} \to \chi: \text{generalized coordinates} = q \\ \end{aligned} }

\displaystyle{ \begin{aligned} (t, q(t), Dq(t), ...) &= \Xi_\chi (t, \gamma(t), \mathcal{D} \gamma(t), ...) \\ \\ \Gamma[q](t) &= (t, q(t), Dq(t), ...) \\ \Gamma[q] &= \Xi_\chi \circ \mathcal{T}[\gamma] \\ \end{aligned} }

— 1.2 Configuration Spaces

— Structure and Interpretation of Classical Mechanics

— Me@2019-03-01 03:09:25 PM

.

.

2019.03.01 Friday ACHK

# Path-distinguishing function, 2

$\displaystyle{\gamma(t)}$ = configuration path function

$\displaystyle{\mathcal{F} [\gamma]}$ = a function of time that measures some local property of the path

……….It may depend upon the value of the function $\displaystyle{\gamma}$ at that time

……….and the value of any derivatives of $\displaystyle{\gamma}$ at that time.

.

We can decompose $\mathcal{F} [\gamma]$ into two parts:

1. a part that measures some property of a local description

and

2. a part that extracts a local description of the path from the path function.

.

— 1.3 The Principle of Stationary Action

— Structure and Interpretation of Classical Mechanics

.

1. The function that measures the local property of the system depends on the particular physical system;

2. the method of construction of a local description of a path from a path is the same for any system.

.

\displaystyle{ \begin{aligned} \mathcal{F} [\gamma] &= \mathcal{L} \circ \mathcal{T}[\gamma] \\ \mathcal{T} [\gamma] &= (t, \gamma (t), \mathcal{D} \gamma (t), ...) \end{aligned}}

.

— 1.3 The Principle of Stationary Action

— Structure and Interpretation of Classical Mechanics

— Me@2019-02-22 11:46:50 PM

.

.

2019.02.24 Sunday ACHK

# Path-distinguishing function

So we will try to arrange that the path-distinguishing function, constructed as an integral of a local property along the path, assumes a stationary value for any realizable path. Such a path-distinguishing function is traditionally called an action for the system. We use the word “action” to be consistent with common usage. Perhaps it would be clearer to continue to call it “path-distinguishing function,” but then it would be more difficult for others to know what we were talking about.

— 1.3 The Principle of Stationary Action

— Structure and Interpretation of Classical Mechanics

.

.

2019.02.17 Sunday ACHK

# SICM

Structure and Interpretation of Classical Mechanics (SICM) is a classical mechanics textbook written by Gerald Jay Sussman and Jack Wisdom with Meinhard E. Mayer. The first edition was published by MIT Press in 2001, and [the] second edition was released in 2015. The book is used at the Massachusetts Institute of Technology to teach a class in advanced classical mechanics, starting with Lagrange’s equations and proceeding through canonical perturbation theory.

— Wikipedia on Structure and Interpretation of Classical Mechanics

.

.

2019.02.02 Saturday ACHK

# DO

While DOLIST and DOTIMES are convenient and easy to use, they aren’t flexible enough to use for all loops. For instance, what if you want to step multiple variables in parallel?

(do (variable-definition*)
(end-test-form result-form*)
statement*)


— Practical Common Lisp

— Peter Seibel

.

(defun split-if (fn lst)
(let ((acc nil))
(do ((src lst (cdr src)))
((or (null src) (funcall fn (car src)))
(values (nreverse acc) src))
(push (car src) acc))))


 >(split-if #'(lambda (x) (> x 4)) '(1 2 3 4 5 6 7 8 9 10))

(1 2 3 4) (5 6 7 8 9 10)

— p.50

— On Lisp

— Paul Graham

.

Exercise 4.5

Implement the function split-if without using the macro do.

— Me@2019-01-30 09:58:30 PM

.

.

2019.01.30 Wednesday ACHK

# duplicate

If (member o l) finds o in the list l, it also returns the cdr of l beginning with o. This return value can be used, for example, to test for duplication. If o is duplicated in l, then it will also be found in the cdr of the list returned by member. This idiom is embodied in the next utility, duplicate:
 >(duplicate ’a ’(a b c a d)) (A D) 

(defun duplicate (obj lst &key (test #’eql))
(member obj (cdr (member obj lst :test test))
:test test))


— p.51

— On Lisp

— Paul Graham

.

Exercise 4.4

Without using the existing function member, define duplicate as in
 >(duplicate ’a ’(a b c a d)) (A D)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

— This answer is my guess. —


(defun my-member (obj lst)
(cond ((not lst) NIL)
((eq obj (car lst)) lst)
(t (my-member obj (cdr lst)))))



— This answer is my guess. —

— Me@2019-01-21 06:34:46 AM

.

.

# Equality Predicates

6.3. Equality Predicates

Common Lisp provides a spectrum of predicates for testing for equality of two objects: eq (the most specific), eql, equal, and equalp (the most general).

eq and equal have the meanings traditional in Lisp.

eql was added because it is frequently needed, and equalp was added primarily in order to have a version of equal that would ignore type differences when comparing numbers and case differences when comparing characters.

If two objects satisfy any one of these equality predicates, then they also satisfy all those that are more general.

.

[Function]
eq x y

(eq x y) is true if and only if x and y are the same identical object. (Implementationally, x and y are usually eq if and only if they address the same identical memory location.)

.

The predicate eql is the same as eq, except that if the arguments are characters or numbers of the same type then their values are compared. Thus eql tells whether two objects are conceptually the same, whereas eq tells whether two objects are implementationally identical. It is for this reason that eql, not eq, is the default comparison predicate for the sequence functions defined in chapter 14.

.

[Function]
eql x y

The eql predicate is true if its arguments are eq, or if they are numbers of the same type with the same value, or if they are character objects that represent the same character.

.

[Function]
equal x y

The equal predicate is true if its arguments are structurally similar (isomorphic) objects. A rough rule of thumb is that two objects are equal if and only if their printed representations are the same.

Numbers and characters are compared as for eql. Symbols are compared as for eq. This method of comparing symbols can violate the rule of thumb for equal and printed representations, but only in the infrequently occurring case of two distinct symbols with the same print name.

.

[Function]
equalp x y

Two objects are equalp if they are equal; if they are characters and satisfy char-equal, which ignores alphabetic case and certain other attributes of characters; if they are numbers and have the same numerical value, even if they are of different types; or if they have components that are all equalp.

— Common Lisp the Language, 2nd Edition

— Guy L. Steele Jr.

.

Conrad’s Rule of Thumb for Comparing Stuff:

1. Use eq to compare symbols

2. Use equal for everything else

— Land of Lisp, p.63

— Conrad Barski, M. D.

.

.

2019.01.16 Wednesday ACHK

# Clasp

Overview

Clasp is a new Common Lisp implementation that seamlessly interoperates with C++ libraries and programs using LLVM for compilation to native code. This allows Clasp to take advantage of a vast array of preexisting libraries and programs, such as out of the scientific computing ecosystem. Embedding them in a Common Lisp environment allows you to make use of rapid prototyping, incremental development, and other capabilities that make it a powerful language.

.

I followed the official instructions to build Clasp:

The building process had been going on for about an hour; and then I got this error:

— Me@2019-01-04 10:11:43 PM

.

.

# Build cross-compiled ECL for Android, 3

EQL5-Android | Common Lisp for Android App Development 2018

.

After successfully running the command ./1-make-ecl-host.sh, when I tried to run the command ./2-make-ecl-android.sh, I got the following errors:

— Me@2018-12-29 11:21:46 PM

.

.

# Build cross-compiled ECL for Android, 2

EQL5-Android | Common Lisp for Android App Development 2018

.

The step 2 is to “build cross-compiled ECL for Android”. It should have been straightforward to follow the instructions in the README page of the EQL5-Android project.

However, when trying to run the command ./1-make-ecl-host.sh, I got the following error messages:

The error was caused by the fact that my Ubuntu 18.04’s 64-bit gcc toolchain could not compile any source code to create 32-bit executables.

The solution is to run the following command to install the 32-bit gcc toolchain first:

sudo apt-get install g++-multilib libc6-dev-i386

— Me@2018-12-25 09:51:02 PM

.

.

# Build cross-compiled ECL for Android

EQL5-Android | Common Lisp for Android App Development 2018

.

The step 2 is to “build cross-compiled ECL for Android”. It should have been straightforward to follow the instructions in the README page of the EQL5-Android project.

However, when trying to run the command ./1-make-ecl-host.sh, I got the following error messages:

A more serious problem was that I could not even locate the error log file config.log.

.

Another abnormality was that while the process claimed that it was

Creating directory 'build',

the directory build was actually not created at all.

So I manually created that directory before running the command ./1-make-ecl-host.sh again. Only then, I could find the error log file config.log in the build directory, after the failure of the compilation.

— Me@2018-12-19 10:50:31 PM

.

.

# The Android NDK Tools

EQL5-Android | Common Lisp for Android App Development 2018

.

After installing the Android SDK Tools by installing Android Studio, originally, you would be able to install the Android NDK through Android Studio’s SDK Manager.

However, since EQL5-Android requires an old version of the NDK (version 10e), you have to download the NDK from the Android’s official NDK webpage.

In Ubuntu, move the file android-ndk-r10e-linux-x86_64.zip to the same location as the Android SDK and then unzip it.

— Me@2018-12-16 09:25:10 PM

.

.

# The Android SDK Tools

EQL5-Android | Common Lisp for Android App Development 2018

.

After installing Qt, check whether its version is 5.9 or later.

If so, install the Android SDK Tools by installing Android Studio.

If you use Ubuntu 18.04 or later, you can use the snap command to install Android Studio.

Besides installing Android Studio, it also automatically updates Android Studio regularly.

— Me@2018-12-12 02:21:45 PM

.

.

# EQL5-Android

Common Lisp for Android App Development 2018

.

The first step to set up EQL5-Android is to install Qt.

In Ubuntu, if you do not need the most updated Qt, you can just install the Qt-Creator using apt-get.

— Me@2018-12-08 09:18:19 PM

.

.