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

Euler problem 23.1.2

(defmacro abundant-numbers (limit)
  `(filter (macro-to-function is-abundant)
           (gen-list 1 ,limit)))

(defmacro none (predicate lst)
  `(not (some ,predicate ,lst)))

(defmacro take-while (predicate lst)
  `(labels ((take-while-iter (a-lst acc)
              (if (null a-lst)
                  (nreverse acc)
                  (let ((head (car a-lst))
                        (tail (cdr a-lst)))
                    (if (funcall ,predicate head)
                        (take-while-iter tail (cons head acc))
                        (nreverse acc))))))
     (take-while-iter ,lst '())))

(defmacro drop-while (predicate lst)
  `(labels ((drop-while-iter (a-lst)
              (if (null a-lst)
                  a-lst
                  (let ((head (car a-lst))
                        (tail (cdr a-lst)))
                    (if (funcall ,predicate head)
                        (drop-while-iter tail)
                        a-lst)))))
     (drop-while-iter ,lst)))

(defun create-hash-from-list (lst)
  (let ((hash (make-hash-table :test 'equal)))
    (dolist (item lst)
      (setf (gethash item hash) t))
    hash))

(defun is-not-abundant-sum (n abundant-list)
  (let* ((half-n-floor (floor (/ n 2)))
         (first-half (take-while #'(lambda (x) (<= x half-n-floor)) abundant-list))
         (second-half (drop-while #'(lambda (x) (< x half-n-floor)) abundant-list))
         (second-half-to-n (take-while #'(lambda (x) (< x n)) second-half))
         (second-half-hash (create-hash-from-list second-half-to-n)))
    (none (lambda (a)
            (let ((b (- n a)))
              (gethash b second-half-hash)))
          first-half)))

(defun not-abundant-sums-list (limit)
  (let ((abundant-list (abundant-numbers limit)))
    (filter #'(lambda (n)
                (is-not-abundant-sum n abundant-list))
            (gen-list 1 limit))))

CL-USER> (time (sum (not-abundant-sums-list 28123)))
 Evaluation took:
  2.481 seconds of real time
  2.477531 seconds of total run time (2.389778 user, 0.087753 system)
  [ Run times consist of 0.152 seconds GC time, and 2.326 seconds non-GC time. ]
  99.88% CPU
  6,194,100,940 processor cycles
  7,411,226,352 bytes consed
  
4179871

— Me@2024-10-04 03:38:12 PM

.

.

2024.10.05 Saturday (c) All rights reserved by ACHK

Quick Calculation 13.3

A First Course in String Theory

.

Justify UHU^{-1} = H directly from the oscillator expansion of H = L_0^\perp + \bar L_0^\perp -2 .

~~~

Eq. (13.37):

\displaystyle{  \begin{aligned}  \bar L_n^\perp &= \frac{1}{2} \sum_{p \in \mathbf{Z}} \bar \alpha_p^I \bar \alpha_{n-p}^I\text{,}   ~~~L_n^\perp = \frac{1}{2} \sum_{p \in \mathbf{Z}} \alpha_p^I \alpha_{n-p}^I\text{.} \\  \end{aligned}  }

So

\displaystyle{  \begin{aligned}  \bar L_0^\perp &= \frac{1}{2} \sum_{p \in \mathbf{Z}} \bar \alpha_p^I \bar \alpha_{-p}^I\text{,}   ~~~L_0^\perp = \frac{1}{2} \sum_{p \in \mathbf{Z}} \alpha_p^I \alpha_{-p}^I\text{.} \\  \end{aligned}  }

.

Eq. (13.93):

\displaystyle{  \begin{aligned}  U x_0 U^{-1} &= -x_0 \text{,}~~~  U p U^{-1} = -p \text{,} \\  U \alpha_n U^{-1} &= -\alpha_n \text{,}~~~  U \bar \alpha_n U^{-1} = - \bar \alpha_n \text{,}   \end{aligned}  }

where n \ne 0.

.

Eq. (13.22):

\displaystyle{  \begin{aligned}  \alpha_0^\mu &= \sqrt{\frac{\alpha'}{2}} p^\mu \\  \end{aligned}  }

So

\displaystyle{  \begin{aligned}  U \alpha_0^\mu U^{-1} &= - \alpha_0^\mu \\  \end{aligned}  }

.

Eq. (13.17)

\displaystyle{  \begin{aligned}  \bar \alpha_0^\mu &= \alpha_0^\mu \\  \end{aligned}  }

So

\displaystyle{  \begin{aligned}  U \bar \alpha_0^\mu U^{-1} &= - \bar \alpha_0^\mu \\  \end{aligned}  }

— Me@2024-10-03 06:42:21 PM

.

.

2024.10.03 Thursday (c) All rights reserved by ACHK