腦殘遊記

以直報怨 4 | Punishment 4

這段改編自 2023 年 6 月 23 日的對話。

.

以前試過有精神病人斬人,造成多人死傷。那樣,該精神病人,有沒有罪呢?

重點不是標籤他,有沒有「罪」;重點是,應如何處理?他應否受刑罰?

懲罰的主要目的,並不在報復,而在立刻停止傷害,以及預防再次發生。或者說,報復的真正目的,正正就是制止及阻嚇。

無論標不標籤他為「有罪」,法官都可以判他,永久居住精神病院。而標不標籤他為「有罪」,則視乎你的「罪」字用法,包不包括「動機」。有犯罪動機的話,就應該判處終身監禁;沒有犯罪動機的話,則精神病院。

留意,受不受到懲罰,和有沒有犯罪意圖,並沒有必然關係。對於殺人犯,法官無論是判他死刑、終身監禁,還是無限期居住精神病院,目的也相同——最終也是要令他,沒有機會再傷害人。

極少情況下,服刑多年後,犯人可以假釋。但是,前提必須是,他再傷害人的機會極低。所以,那是極少情況下。

不是「不知者不罪」,而是「不知者最大罪」,因為,遇到壞人,你可以透過法津武力,去制止他;但是,遇到好人、蠢人,或者好蠢之人,你只可以無可奈何。

— Me@2024-10-22 10:56:09 AM

.

.

2024.11.08 Friday (c) All rights reserved by ACHK

Transform recursion into tail recursion

Remove a white dot from the photo | Euler problem 24.1.2

.

(defmacro detailn (fn (n)
                   (if endc
                       b-val
                       (op n (fn (ch n)))))
  (let ((acc (gensym)))
    `(defun ,fn (,n)
       (labels ((fn-iter (,n ,acc)
                  (if ,endc
                      ,acc
                      (fn-iter (,ch ,n)
                               (,op ,n ,acc)))))
         (fn-iter ,n ,b-val)))))

(detailn facn (m)
         (if (<= m 1)
             1
             (* m (facn (1- m)))))

(macroexpand '(detailn fac (m)
               (if (<= m 1)
                   1
                   (* m (fac (1- m))))))

— Fixed by GIMP’s Clone Tool

— Me@2024-10-30 12:42:22 PM

.

.

2024.11.06 Wednesday (c) All rights reserved by ACHK

Ex 1.32 Path functions and state functions, 2.1

Structure and Interpretation of Classical Mechanics

.

1. The local-tuple function f is the same as the local-tuple function \bar \Gamma (\bar f) where \bar f[q] = f \circ \Gamma [q].

2. …

~~~

1. Equation

\displaystyle{\begin{aligned} \bar f &= f \circ \Gamma \\ \end{aligned}}

is the definition of \bar f. And equation

\displaystyle{\begin{aligned} f &= \bar \Gamma (\bar f) \\ \end{aligned}}

is the definition of \bar \Gamma. So, in theory,

\displaystyle{\begin{aligned} f &= \bar \Gamma (\bar f) \\ \end{aligned}}

is just true by definition.

In practice, their initial inputs are both the same local tuple

\displaystyle{\begin{aligned} &(t, q(t), v(t), \cdots, q^{(n)}(t)) \\ \end{aligned}},

which has only a finite number of components. The path q in the process is generated by that initial input:

\displaystyle{\mathcal{O} (t,q,v, \cdots, q^{(n)})}

So the function \Gamma would get you back the exact local tuple from the osculating path:

\displaystyle{(t,q,v,\cdots, q^{(n)}) = \Gamma[\mathcal{O} (t,q,v, \cdots, q^{(n)}](t)}

.

In other words, since for the functions \displaystyle{f} and \displaystyle{\bar \Gamma (\bar f)}, neither input is the path itself, the identity is exact.

Conceptually,

(define (f local)
  (g local)) 
 
(define ((Gamma-bar f-bar) local)
  ((f-bar (osculating-path local)) (time local))) 

(define ((f-bar q) t)
  (f ((Gamma q) t))
 
;; (((f-bar q) 't)
;; == f((Gamma q) 't)
;; == f('t, (v 't), (a 't),...) 

— Me@2024-10-16 10:34:35 AM

.

.

2024.11.04 Monday (c) All rights reserved by ACHK

Mass in general relativity

The concept of mass in general relativity (GR) is more subtle to define than the concept of mass in special relativity. In fact, general relativity does not offer a single definition of the term mass, but offers several different definitions that are applicable under different circumstances. Under some circumstances, the mass of a system in general relativity may not even be defined.

The reason for this subtlety is that the energy and momentum in the gravitational field cannot be unambiguously localized. So, rigorous definitions of the mass in general relativity are not local, as in classical mechanics or special relativity, but make reference to the asymptotic nature of the spacetime. A well defined notion of the mass exists for asymptotically flat spacetimes and for asymptotically Anti-de Sitter space. However, these definitions must be used with care in other settings.

— Wikipedia on Mass in general relativity

.

.

2024.11.03 Sunday ACHK

公關即災難

烹飪事實 2

這段改編自 2021 年 12 月 16 日的對話。

.

鐵甲奇俠有些方面,遠比蝙蝠俠高明。當記者問他時,他直接回應:「我是鋼鐵俠。」

(JC:那一幕十分有型。)

不只有型。那還避免了像蝙蝠俠般,因為隱瞞身份,而導致往後的無數麻煩。那其實就是,現實版鐵甲奇俠,馬斯克的處事風格——有嗰句,講嗰句——在沒有必要時,就不要隱瞞或化妝。即使是最壞情況出現:講錯了被人批評,他也只需認錯和改正。

但是,如果不是坦誠相待,而是故弄玄虛的話,後果則不可預測。

(JC:有很多時,那些公關災難是,怎樣來的呢?其實就是……)

公關形成災難、公關引發災難。

.

留意,蝙蝠俠的錯,不在隱瞞身分本身;因為,有很多高危的任務,必須隱身才能完成。鐵甲奇俠在開始時,也必須隱藏身份。

蝙蝠俠的錯在於,永久隱瞞身分,而又不斷執行,新的任務。他應該在適當時機,公開身分,或者退休。

— Me@2024-10-31 03:11:18 PM

.

.

2024.11.02 Saturday (c) All rights reserved by ACHK

Euler problem 24.1.1

To formalize, if a_0 < \ldots < a_n , then in the k-th permutation of \{a_0, \ldots, a_n\} in lexicographic order, the leading entry is a_q if k = q(n!) + r for some q \geq 0 and 0 < r \leq n! . (Note that the definition of r here is a bit different from the usual remainder, for which 0 \leq r < n! . Also, a_q is the (q+1)-th entry but not the q-th entry in the sequence, because the index starts from 0.)

— edited Aug 30, 2011 at 18:23
— answered Aug 30, 2011 at 17:59
— user1551
— math stackexchange

Why r Cannot Be Zero: If r were allowed to be zero, it would imply that the leading entry of the permutation could be determined without any remaining elements to choose from, which contradicts the requirement of having a valid permutation. In other words, a remainder of zero would mean that we have perfectly divided k by n! , leading us to a situation where we would not be able to select the next element in the permutation sequence.

— AI Assistant

.

.

2024.10.30 Wednesday (c) All rights reserved by ACHK

DSE 數學補邊個好?(神器六)

這篇文章繼續討論,選擇數學補習老師的一些準則。而這裡的數學,是指香港中學文憑試的數學科,包括核心,M1 及 M2。

如果你問我物理補習推介,特別是物理補習天王的話,我會答:「補 physics,補 Ken Chan!」但是,如果你問我數學補習天王的話,恕沒有推介,因為本人沒有遇過。

那樣,數學科補習界如果有 Ken Chan,他又必須具備,什麼條件呢?

上文提到:

……

3. 星期時間篇

他會告訴你,如何從平衡到駕馭,各科溫習時間之爭。

……

4.0 分秒時間篇

除了日常生活中的,溫習時間管理外,他亦會教你,考試答題時的時間策略。

……

4.\infty 數學考試

= 兩成數學 + 八成人格(速度+準確度+表達)

……

5. 超時空準備

他會持續教導你,比考試要求,還深一倍的題目。目的就是令你,有奪取滿分的機會。

作為「附加數學」的 M1 或 M2,主要作用是令你覺得,作為「普通數學」的核心數,簡單而容易。

水平提高了,原地就會在你之下。再困難的迷宮,如果有直升機的協助,就不用再怕。一來,你可以直升離開;二來,即使必須降回原地,單單是在直升機的那幾分鐘,足以讓你鳥瞰原地全境。

同理,如果要令自己「附加數」本身,有機會滿分的話,則要熟習「附加附加數」,即是大學一年級程度的數學。

迷宮必勝法,用直升機也;簡稱「降維打擊」。其先決條件是,你要花大量時間,預先「升維」。

— Me@2024-10-26 11:23:52 PM

.

.

2024.10.27 Sunday (c) All rights reserved by ACHK

Where are you? 2.4

Utopia | 何有之鄉, 2.4

.

選擇戀愛對象的原則,並不是找「理想伴侶」,而是找厭惡得來,仍然可以遷就到的人。反過來說,必須排除那些,「不可能遷就到」的可能對象。可以遷就到的,就是缺點;想遷就也遷就不到的,就為之人格問題。

不可能遷就到,而為了保命,必須立刻超光速逃離,或者𣊬間轉移的例子有:

一、 永不守時:

有一次約會心儀對象,她沒有拒絕。但是,就單單那一次相約,她竟然連續失約改期五次。心儀對象,再不心儀。

二、 以為愛情主要為享福:

拍拖不以結婚為目的;或結婚不以生兒育女為目標。

三、 現實疏忽:

包括但不限於,家居安全或人身安全等意識不足。與她生活提心吊膽,不知何時會火災或爆炸。

四、 文書疏忽:

在公文中,會有不少文法錯誤;或在表格中,會有重要資料偏差。

二十年前,工作伙伴有這個問題,我無留意,然後中招,中得好緊要。連公文也不細心,不肯反覆詳細檢查,反映三觀不正,例如,不會為他人(包括未來的自己)設想。

五、 不可信:

誠信有問題,有兩個版本:

第一種是,會在沒有必要時,說假話,或透過隱瞞等方法,去誤導他人。

第二種是,會在沒有必要時,公開你的私隱,或者他人的秘密。

記住,誠信只可能破壞,不可能修補。

……

— Me@2024-09-05 03:33:08 PM

.

.

2024.10.26 Saturday (c) All rights reserved by ACHK

Euler problem 23.3

Watermelon 3

.

isAbundant[n_] :=
    Module[{sumDivisors},
        sumDivisors = Total[Divisors[n]] - n;
        sumDivisors > n]

abundantNumbers[a_, b_] :=
    Select[
        Range[a, b],
        isAbundant]

L := 28123

abundantList := abundantNumbers[1, L]

firstHalfAbundantList :=
    abundantNumbers[1, Quotient[L,2]]

abundantSums[aList_, bList_] :=
    DeleteDuplicates[
        Flatten[
            Table[
                aList[[i]] + bList[[j]],
                {i, Length[aList]},
                {j, Length[bList]}]]]

nonAbundantSums[limit_] :=
    Total[
        Complement[
            Range[1, limit],
            abundantSums[
                firstHalfAbundantList,
                abundantList]]]

result = Timing[nonAbundantSums[L]]

{1.73236, 4179871}

— Me@2024-10-20 01:49:38 PM

.

.

2024.10.25 Friday (c) All rights reserved by ACHK

Ex 3.2 Verification, 2.1

Functional Differential Geometry

.

Verify that the coefficients of a one-form field transform as described in equation (3.56). You should use equation (3.44) in your derivation.

~~~

Eq. (3.56):

a(\chi(\mathbf{m})) = a'(\chi'(\mathbf{m})) \left[D(\chi \circ (\chi')^{-1})(\chi'(\mathbf{m}))\right]^{-1}

.

The general one-form \boldsymbol{\omega} is a linear combination of coordinate-basis one-form fields:

Eq. (3.15):

\begin{aligned}   \text{X}_i(\text{f})(\mathbf{m})   &= D(\text{f} \circ \chi^{-1})(\chi(\mathbf{m})) u_i(\chi(\mathbf{m})) \\  &= \partial_i(\text{f} \circ \chi^{-1})(\chi(\mathbf{m}))   \end{aligned}

.

Given a vector field \mathbf{v}, we define the coordinate-basis one-form fields as

Eq. (3.40):

\tilde{\text{X}} (\mathbf{v}) (\mathbf{m}) = \mathbf{v}(\chi)(\mathbf{m})

So

\begin{aligned}   \tilde{\text{X}}^i (\text{X}_j) (\mathbf{m})   &= \text{X}_j (\chi^i)(\mathbf{m}) \\  &= \text{X}_j (\chi^i \circ \chi^{-1})(\chi (\mathbf{m})) \\  &= \partial_j (\chi^i \circ \chi^{-1})(\chi (\mathbf{m}))   \end{aligned}

Consider also that

\displaystyle{ \begin{aligned}      x^i &= \chi^i (\mathbf{m}) \\        &= \chi^i (\chi^{-1} (\chi (\mathbf{m}))) \\        &= (\chi^i \circ \chi^{-1}) (x) \\    \end{aligned}}

Then, we have Eq. (3.41):

\begin{aligned}   \tilde{\text{X}}^i (\text{X}_j) (\mathbf{m})   &= \delta^i_{~j} \   \end{aligned}

.

Eq. (3.42):

\begin{aligned}  \boldsymbol{\omega}(\mathbf{v})(\mathbf{m})   &= a(\chi(\mathbf{m})) \tilde{\text{X}}(\mathbf{v})(\mathbf{m}) \\  &= \sum_{i} a_i(\chi(\mathbf{m})) \tilde{\text{X}}^i(\mathbf{v})(\mathbf{m}) \\  \boldsymbol{\omega}(\mathbf{v})  &= (a \circ \chi) \tilde{\text{X}} (\mathbf{v}) \\  \end{aligned}

Therefore,

\begin{aligned}  \boldsymbol{\omega}(\text{X}_i)(\mathbf{m})   &= \sum_{j} a_j(\chi(\mathbf{m})) \tilde{\text{X}}^j(\text{X}_i)(\mathbf{m}) \\    &= a_i(\chi(\mathbf{m})) \\  \boldsymbol{\omega}(\text{X}_i)(\chi^{-1}(x))   &= a_i(x) \\  \end{aligned}

Eq. (3.44):

\begin{aligned}  a_i(x) &= \boldsymbol{\omega}(\text{X}_i)(\chi^{-1}(x)) \\  &= (a' \circ \chi') \tilde{\text{X}'}(\text{X}_i) (\chi^{-1}(x)) \\  \end{aligned}

— Me@2024-09-18 06:38:02 AM

.

.

2024.10.25 Friday (c) All rights reserved by ACHK

Posted in FDG

Table border

所有第一次, 2

.

<table border="1" style="border-collapse: collapse;width: 70%;margin: 20px auto">
  <thead>
    <tr>
      <th style="border: 1px solid #ddd;padding: 12px;text-align: left;background-color: #f2f2f2;color: #333">Duration</th>
      <th style="border: 1px solid #ddd;padding: 12px;text-align: left;background-color: #f2f2f2;color: #333">Subject</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="border: 1px solid #ddd;padding: 12px">3 hours</td>
      <td style="border: 1px solid #ddd;padding: 12px">理科</td>
    </tr>
    <tr>
      <td style="border: 1px solid #ddd;padding: 12px">1 hour</td>
      <td style="border: 1px solid #ddd;padding: 12px">語文</td>
    </tr>
    <tr>
      <td style="border: 1px solid #ddd;padding: 12px">1 hour</td>
      <td style="border: 1px solid #ddd;padding: 12px"></td>
    </tr>
    <tr>
      <td style="border: 1px solid #ddd;padding: 12px">3 hours</td>
      <td style="border: 1px solid #ddd;padding: 12px">文科</td>
    </tr>
  </tbody>
</table>
Duration Subject
3 hours 理科
1 hour 語文
1 hour
3 hours 文科

這個心結的本質就在於,和維珍在一起的時候,她所有的經歷,都是[只]跟你有關。那從青澀到成熟,都是只有你的參與。這種經歷,是可以支撐後面,漫漫的人生路。

維珍是把她自己,所有的一切,[都]給了你。而面對英航的時候,腦海當中,想起那段感情和經歷,不是跟自己的,就會覺得憋屈難受。

— 軒語說媒

.

.

2024.10.23 Wednesday ACHK

魔法師是怎樣煉成的, 2.2

這段改編自 2023 年 6 月 23 日的對話。

.

剛才講到:「有同情,就沒有愛情,因為,愛情的先決條件是:她傾慕你,而你又欣賞她。」

「同情會衍生愛情」是,嬰兒邏輯。有些人長不大,以為利用他嬰兒時期的手段——扭計哭鬧,就可以追求到愛情。

那亦可稱為,韓劇邏輯。

— Me@2024-10-22 11:25:10 AM

.

.

2024.10.22 Tuesday (c) All rights reserved by ACHK

Euler problem 23.2

import Data.Array as Array ( Array )
import Data.Array.Base ( (!), listArray )
import Data.List (group)

primes :: [Int]
primes = 2 : filter (null . tail . (pfa !)) [3, 5 ..]

ub :: Int
ub = 28123

pfa :: Array Int [Int]
pfa = listArray (2, ub) $ map pf [2..ub]

pf :: Int -> [Int]
pf n = factor n primes
  where
    factor n (p : ps)
      | p * p > n = [n]
      | n `mod` p == 0 = p : pfa ! (n `div` p)
      | otherwise = factor n ps

groupFactors :: [Int] -> [[Int]]
groupFactors xs = [[head x, length x] | x <- group xs]

genDiv :: [[Int]] -> [Int]
genDiv = foldr combine [1]
  where
    combine [p, n] acc
      = [x * p^e | x <- acc, e <- [0..n]]

sumProperDivisors :: Int -> Int
sumProperDivisors n
  = -n + sum (genDiv $ groupFactors $ pfa ! n)

isAbundant :: Int -> Bool
isAbundant n = sumProperDivisors n > n

abdSieve :: Array Int Bool
abdSieve = listArray (2, ub) $ map isAbundant [2..ub]

abundantNumbers :: Int -> [Int]
abundantNumbers m
  | m > ub = filter isAbundant [2..m]
  | otherwise = filter (abdSieve !) [2..m]

abundantList :: [Int]
abundantList = abundantNumbers ub

isAbundantSum :: Int -> Bool
isAbundantSum n 
  = any (\a -> abdSieve ! (n-a))
    $ takeWhile (<= n `div` 2) abundantList

notAbundantSumsList :: Int -> [Int]
notAbundantSumsList m
  = filter (not . isAbundantSum) [1..m]

λ> :set +s
λ> sum (notAbundantSumsList ub)
4179871
(1.14 secs, 1,772,425,584 bytes)
λ> 

— Me@2024-10-19 09:53:30 PM

.

.

2024.10.21 Monday (c) All rights reserved by ACHK

Ex 1.32 Path functions and state functions, 1

Structure and Interpretation of Classical Mechanics

.

In classical mechanics, there are scenarios where the path function cannot be reconstructed from a finite number of local tuples, such as time t, position q, velocity v, and acceleration a. One notable example involves non-conservative forces and chaotic systems.

Example: Chaotic Motion

Consider a system exhibiting chaotic behavior, such as the double pendulum. In this system, the motion is highly sensitive to initial conditions, meaning that even small changes in the initial state can lead to vastly different trajectories over time.

Local Information Limitations

  1. Finite Local Tuples: If you only have a finite number of measurements (e.g., position and velocity at discrete time intervals), you may not capture the full complexity of the system’s dynamics. For instance, knowing the position and velocity at a few points does not provide enough information to reconstruct the entire path due to the chaotic nature of the motion.

  2. Path Reconstruction Failure: In chaotic systems, the trajectory can diverge significantly from nearby trajectories. Thus, even if you have the position q(t) and velocity v(t) at several time points, the underlying dynamics can lead to a completely different path that cannot be predicted or reconstructed from those finite local tuples.

Conclusion

In summary, chaotic systems like the double pendulum illustrate how the path function cannot be reconstructed from a finite number of local tuples due to their sensitive dependence on initial conditions and the complexity of their dynamics. This highlights the limitations of local information in capturing the full behavior of certain mechanical systems.

— AI

.

.

2024.10.18 Friday (c) All rights reserved by ACHK

DSE 數學補邊個好?(神器五)

這篇文章繼續討論,選擇數學補習老師的一些準則。而這裡的數學,是指香港中學文憑試的數學科,包括核心,M1 及 M2。

如果你問我物理補習推介,特別是物理補習天王的話,我會答:「補 physics,補 Ken Chan!」但是,如果你問我數學補習天王的話,恕沒有推介,因為本人沒有遇過。

那樣,數學科補習界如果有 Ken Chan,他又必須具備,什麼條件呢?

上文提到:

1. 背誦篇

理科是文科,但不是一般的文科,而是極超巨大級的文科。

1.1 他會提醒你,數學其實是,極超大量的背誦。

……

1.2 極超大量的背誦,來自極端深刻的理解。

……

2. 年月時間篇:歷屆試題

2.1 他會提議你,考試前要操練 10 年、20 年 或 30 年的歷屆試題。

……

2.1.2 他會告訴你「八二法則」——頭八十分,只需兩成的付出;而尾二十分,則需佔八成的努力。亦即是話,付出和收穫,不成比例。

……

2.2 最近五年的題目,則從來不要看,因為你要保留它們,在公開試前的休假月時,來作模擬考試用。

2.3 最近五年以前的題目,則可以在課程的那三年間,隨時隨地做。

留意,做試題有兩大主要方法:「分課題」或「分年份」。

……

2.4 而歷屆試題的來源是:……

3. 星期時間篇

他會告訴你,如何從平衡到駕馭,各科溫習時間之爭。

……

4.0 分秒時間篇

除了日常生活中的,溫習時間管理外,他亦會教你,考試答題時的時間策略。那都是要在事先,學習和訓練的。

有關詳情,請點擊本綱誌之文章分類

exam time | 戰鬥意志

然後於網址結尾,加以下字串:

?order=asc

例如,剛才提到的「八二原則」指出了:同樣的分數,在不同的部分,難易不同。所以,考試時應先做最易的題目。

留意,題目的預設次序,未必是由易至深。其中一個原因是,各人對即使是同一道題目,深淺的感覺,未必相同。所以,必須在考試前鐵定,「唔識就飛」的好習慣:遇到不懂的題目時,不要思考,改為立刻跳過,去先做懂做的題目;最後還有時間剩餘時,才回到不懂的題目。

4.1 他會教你如何高速作答。

留意,高速不是急促。高速的原因在於,你掌握的數學知識,深於常人所及;繼而,你駕馭的運算技巧,高過他人所能。

每個課題的深知識,和對應的速算技巧,也可以不同,也可以是該課獨家。亦即是話,每種題目的速算技巧,都要遠在考試前就,事先學習和訓練好。

4.2 同理,每課題目的驗算技巧,亦都是那樣。

4.3 他亦會教你,考試作答時的表達技巧。自以為「數學和理科,毋須語文能力」的,是狂妄。

4.\infty 為了方便記憶,背了這公式:

數學考試

= 兩成數學 + 八成人格(速度+準確度+表達)

公式中的「準確度」,是指「數字準確度」或「運算準確度」。而「表達」,則指「文字準確度」或「語文準確度」。數學考試成績反映的,大概而言,只有兩成是數學中的,所謂「純知識」;其餘八成,都是人格的考驗。

有些數學知識,只在考試有益;而人格才能,則一生受用。

5.

……

— Me@2024-10-10 08:01:07 PM

.

.

2024.10.12 Saturday (c) All rights reserved by ACHK