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

.

.

2019.05.05 Sunday (c) All rights reserved by ACHK

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

.

.

2019.04.07 Sunday (c) All rights reserved by ACHK

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

.

.

2019.03.29 Friday (c) All rights reserved by ACHK

Computing Actions

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

.

.

2019.03.10 Sunday (c) All rights reserved by ACHK

Generalized Coordinates

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

d_2019_02_02__12_27_49_PM_

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

長頸豹 3

尋找時間的定義 1.2

SICM, 3.2 | SICP, 2.2

這段改編自 2010 年 4 月 10 日的對話。

涉獵多門知識,即使對於「本行」的發展,也會有意想不到的幫助。

例如,我對「什麼是時間」這個物理問題,有極之大的興趣。我想像,如果我只閱讀和研究物理,可能窮一身的時間,也沒有寸進。

估不到,在大概 2006 年,我從一本電腦界的神作中,得到了靈感,開始對「時間定義」有一點理解。然後在今年(2010),再加上我在大學時代時,長期訓練得來的「語理分析」功力,我破解了,「時間」的大部分意思。

(安:你上星期也有提及過,那本電腦界的神作。)

又例如,如果一個人過身後,仍然以某種形式存在的話,究竟確實是以哪一種,或者怎麼樣的形式來存在呢?

從物理和電腦知識中,我得到了一些關鍵靈感。

「靈感」中的「靈」,其實就是解「靈活」、「靈通」,即是有大量和多類型的資料或消息來源。

— Me@2014.06.03

2014.06.03 Tuesday (c) All rights reserved by ACHK

SICP, 3

Just as every day thoughts are expressed in natural language, and formal deductions are expressed in mathematical language, methodological thoughts are expressed in programming languages. A programming language is a method for communicating methods, not just a means for getting a computer to perform operations – programs are written for people to read as much as they are written for machines to execute.

— Lisp: A language for stratified design

— Harold Abelson, Gerald Jay Sussman

— SICP distilled

— jao 

2013.05.31 Friday ACHK

Hacker 3

.

The Jargon File has had a special role in acculturating hackers since its origins in the early 1970s. Many textbooks and some literary works shaped the academic hacker subculture; among the most influential are:

* Hackers: Heroes of the Computer Revolution, by Steven Levy
* Godel, Escher, Bach, by Douglas Hofstadter
* The Art of Computer Programming (TAOCP), by Donald Knuth
* The Mythical Man-Month, by Brooks
* Compilers: Principles, Techniques, and Tools (“the Dragon Book”), by Aho, Sethi, and Ullman
* Structure and Interpretation of Computer Programs (SICP), by Abelson and Sussman
* The C Programming Language (K&R), by Kernighan and Ritchie
* The Hitchhiker’s Guide to the Galaxy, by Douglas Adams
* The Tao of Programming, by Geoffrey James
* The Illuminatus! Trilogy, by Robert Shea and Robert Anton Wilson
* Principia Discordia, by Greg Hill and Kerry Thornley
* The Soul of a New Machine, by Tracy Kidder
* The Cuckoo’s Egg, by Cliff Stoll
* The Unix System, by Stephen R. Bourne
* Hackers & Painters, by Paul Graham
* The Cathedral and the Bazaar, by Eric S. Raymond
* The essays of Richard M. Stallman (many published in Free Software, Free Society: Select Essays of Richard M. Stallman)

– Wikipedia on Hacker (programmer subculture)

.

.

[10] “Hacker” here means a highly skilled programmer, not a computer criminal. — Me

The basic difference is this: hackers build things, crackers break them. — Eric S. Raymond

In academia, a “hacker” is a person who follows a spirit of playful cleverness and enjoys programming.

– Wikipedia on Hacker (academia)

.

.

.

2010.03.04 Thursday ACHK

SICM, 3.2

這段改編自 2010 年 4 月 3 日的對話。

《SICM》(Structure and Interpretation of Classical Mechanics)中的編程語言,除了 Scheme 的本體外,還會用到作者特製的力學程式庫 Scmutils。而這個程式庫(library)卻只有 Linux 的版本,不能安裝在 Windows 之中。那導致我要特意在我的 Windows 中,先裝一個 virtual machine(虛擬機器),從而在那個虛擬機器之上,再安裝一個 Linux 作業系統。

閱讀《SICM》,除了間接令我,發現「時間」的定義外,還令我第一次接觸「virtual machine」這個概念。兩者各自都是,我個人智力發展的一個里程碑。

— Me@2012.12.25

2012.12.25 Tuesday (c) All rights reserved by ACHK

尋找時間的定義

SICM, 3 | SICP, 2

這段改編自 2010 年 4 月 3 日的對話。

當年,我初看《SICM》(Structure and Interpretation of Classical Mechanics)時,我不太懂做那些練習題目,因為那時,我是只是初學,而尚未能掌握,內裡的編程語言 Scheme programming language。

為了熟習 Scheme,我先行閱讀了《SICM》的姊妹作,《SICP》(Structure and Interpretation of Computer Programs)的頭幾課。

《SICP》跟《SICM》,同樣是超級名著。但是它不易理解。幸好,它官方網站提供了,一些 1986 年的講課錄影。當年(2006),尚未流行使用 YouTube,所以我要花很多時間,下載那些錄影。我還記得,每節課的錄影檔案,有 600MB 那麼大。

雖然那麼費神,但卻換來意外的收穫。《SICP》令我瞭解「時間」的定義。

This image is taken from 《SICP》 and 《SICP》 itself is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License.

最令我意想不到的是,那竟然是來自一本電腦書,而不是物理書。

— Me@2012.12.23

2012.12.23 Sunday (c) All rights reserved by ACHK

SICM, 2

這段改編自 2010 年 4 月 3 日的對話。

《SICM》(Structure and Interpretation of Classical Mechanics)總共花了我兩年的時間。我大概由 2006 年,閱讀至 2008 年。除了閱讀課文外,我還把內裡的幾乎所有練習,無論是數學題,還是程式題,都一一擊破。要花那麼長的時間才能完成,主要是因為上班的工務繁忙。每日可以花在自修的時間,通常也不會超過半小時。

雖然時間成本奇高,但是,我仍然覺得是值得的。一來,它是一本名著,質素非常高。二來,它竟然把我人生的兩大興趣,重疊在一起。

— Me@2012.12.21

2012.12.21 Friday (c) All rights reserved by ACHK

程式員頭腦 14.3

SICM, 1.3

這段改編自 2010 年 4 月 3 日的對話。

即使有時會剛巧得到正確的結果,但是由於胡亂推導,大家也不知道,那個正確結果的真正由來。所以,每一代的學生,都不可能明白那一個部分。

要戒除「暗地裡轉換意思」的陋習,並不困難。如果透過編寫程式,來解決力學問題,你就要先把那個力學問題,翻譯制訂成電腦程式的版本。那樣,在過程中,你自然會百分百釐清了,所有符號的意義,因為,在同一個程式中,同一個符號,電腦只會容許,有唯一的一個意思。電腦不會讓你(,在沒有事先特別聲明的情況下),任意放大、縮小 或 更改,那一個符號的意思。電腦不會錯失,你任何的「概念扭曲」或者「概念滑轉」,所以不會有絲毫的容忍。

由於要你「寫程式學力學」,《SICM》(Structure and Interpretation of Classical Mechanics)會教你一種編程語言 Scheme programming language。這種語言的好處是,你學了一句後,就可以立刻應用那一句,而不像一般的程式語言,應用前,要先行學習一大堆語法。

(安:那本書真的用 programming(電腦編程),來講解 mechanics(力學)?)

無錯。正如一般的教科書,課文以外,《SICM》還有例題和練習題。而例子和練習之中,有超過一半是程式題目。其餘的則是文字題目和數學題目。

但是,《SICM》的正題始終是力學,而不是寫程式。正如,力學需要用數學。但是數學在這本書內,只是工具,不是主菜。

— Me@2012.12.18

2012.12.19 Wednesday (c) All rights reserved by ACHK

概念滑轉

SICM, 1.2 | 程式員頭腦 14

這段改編自 2010 年 4 月 3 日的對話。

“In almost all textbooks, even the best, this principle is presented so that it is impossible to understand.” (K. Jacobi, Lectures on Dynamics, 1842-1843). I have not chosen to break with tradition.

— V. I. Arnold, Mathematical Methods of Classical Mechanics, footnote, p. 246

Structure and Interpretation of Classical Mechanics

這本書的主要好處是,它會要求你,透過編寫簡短的電腦程式,來解決力學問題。反過來說,你亦可以透過解決力學問題,來練習 programming(電腦編程)。

這本書的主旨是,在經典力學,人們做公式推導的過程中,有時會把一些數字符號的意思,不自覺地改了一點,導致推導失效。例如,運算步驟的第二行和第五行,都會出現的函數 f 這個符號。但是,第二行的 f ,是代表 f(x,y)。而第五行的 f ,卻是指 f(x(t),y(t))。

即使有時會剛巧得到正確的結果,但是由於胡亂推導,大家也不知道,那個正確結果的真正由來。所以,每一代的學生,都不可能明白那一個部分。

如果透過編寫程式,來解決力學問題,你就可以避免了「暗地裡轉換意思」的陋習,因為在同一個程式中,同一個符號,電腦只會容許,有唯一的一個意思。電腦不會錯失,你任何的「概念扭曲」或者「概念滑轉」,所以不會有絲毫的容忍。

— Me@2012.12.17

2012.12.17 Monday (c) All rights reserved by ACHK

SICM

這段改編自 2010 年 4 月 3 日的對話。

(安:我怎樣把 mechanics(力學)學得好一點?)

哪一門力學?經典力學,還是量子力學?

(安:經典力學。)

你想應用在哪些地方?

(安:暫時純粹為了求知和娛樂。)

那我介紹一本名著給你。它叫做《SICM》(Structure and Interpretation of Classical Mechanics)。它免費發布於 MIT(麻省理工學院)的網站。

這本書的主要好處是,它會要求你,透過編寫簡短的電腦程式,來解決力學問題。反過來說,你亦可以透過解決力學問題,來練習 programming(電腦編程)。

— Me@2012.12.15

2012.12.15 Saturday (c) All rights reserved by ACHK