Euler problem 18.2

tri = [[75],
       [95,64],
       [17,47,82],
       [18,35,87,10],
       [20,04,82,47,65],
       [19,01,23,75,03,34],
       [88,02,77,73,07,63,67],
       [99,65,04,28,06,16,70,92],
       [41,41,26,56,83,40,80,70,33],
       [41,48,72,33,47,32,37,16,94,29],
       [53,71,44,65,25,43,91,52,97,51,14],
       [70,11,33,28,77,73,17,78,39,68,17,57],
       [91,71,52,38,17,14,91,43,58,50,27,29,48],
       [63,66,04,68,89,53,67,30,73,16,69,87,40,31],
       [04,62,98,27,23,09,70,98,73,93,38,53,60,04,23]]
  
pathAddItem x (y:ys) (z:zs)
  = (x+m):x:ms
  where 
    (m:ms) | y > z = y:ys
           | otherwise = z:zs
           
listApplyPathAddItem xs ys
  = zipWith3 f xs ys $ tail ys 
  where
    f = pathAddItem
   
e18 = foldr g acc (init tri) 
  where
    toPair x = [x,x]
    g = listApplyPathAddItem
    acc = map toPair $ last tri

— Me@2023-12-28 11:25:22 AM

.

.

2023.12.28 Thursday (c) All rights reserved by ACHK

3 Vector Fields and One-Form Fields, 1.2

p. 21

5.

\displaystyle{(Df(x)) b(x) \ne (Df(x)) \Delta x}

Instead, \displaystyle{(Df(x)) b(x)} is a generalization of \displaystyle{(Df(x)) \Delta x}.

6.

However, how to calculate \displaystyle{(Df(x)) b(x)}?

By this:

\displaystyle{f(x + \Delta x) \approx f(x) +  (Df(x)) \Delta x}

Then:

\displaystyle{(Df(x)) = \lim_{\Delta x \to 0} \frac{f(x + \Delta x) - f(x)}{\Delta x}}

So:

\displaystyle{(Df(x)) b(x) = \left( \lim_{\Delta x \to 0} \frac{f(x + \Delta x) - f(x)}{\Delta x} \right) b(x)}

7.

b is written as subscript to capture the meaning of “with respect to b“. The original directional derivative uses the same convention:

So the spatial rate of change of \displaystyle{f} along the direction of the vector \displaystyle{\mathbf{v}} is

\displaystyle{\begin{aligned}  D_{\mathbf{v}}(f)    &= \frac{\left(\delta f\right)_{\mathbf{v}}}{|\mathbf{v}|} \\    &= \frac{1}{|\mathbf{v}|} \left( \frac{\partial f}{\partial x} \delta x + \frac{\partial f}{\partial x} \delta y \right) \\    &= \frac{\partial f}{\partial x} \frac{\delta x}{\sqrt{(\delta x)^2 + (\delta y)^2}}  + \frac{\partial f}{\partial x} \frac{\delta y}{\sqrt{(\delta x)^2 + (\delta y)^2}} \\    &= \left(\nabla f\right) \cdot \frac{\mathbf{v}}{|\mathbf{v}|} \\  &= \left(\nabla f\right) \cdot \hat{\mathbf{v}} \\  \end{aligned}}

\displaystyle{D_{\mathbf{v}}(f)} is called directional derivative.

— Me@2016-02-06 09:49:22 PM

— Me@2023-12-27 01:37:32 PM

— Functional Differential Geometry

.

.

2023.12.27 Wednesday (c) All rights reserved by ACHK

@dialectphilosophy, 1.3.3

That is what “acceleration is absolute” means. The observer can notice different phenomena, compared with the no-acceleration case, even without seeing outside the car window.

The additional meaning of “acceleration is absolute” is that we can deduce the acceleration value by measuring v_{2c}(0), v_{2c}(t), and t. And, unlike velocity values, this acceleration value is identical for any two observers related by a Galilean transformation. (They are called inertial observers.)

.

To see a more direct consequence of accelerating the car, we can consider an even simpler case where v_{2c}=0. Then we split the case into two, one with acceleration and one without.

In the no acceleration case, the particle 2 keeps co-moving with the car at the same velocity. In this case, the distance between particle 2 and a point of the car is always the same, no matter what the car’s velocity is. So it is impossible to deduce that velocity by observing only the distance between any two points within the car.

The car velocity value observed is different for different observers, depending on each observer’s velocity. That is what “velocity is relative” means.

However, if the car accelerates, although for an observer co-moving with the car, what he sees is not the car accelerating, but the particle 2 accelerates in the opposite direction; he can measure the acceleration based on the separations (between points within the car), the separation changes, and rate of separation changes; and he will get an acceleration value of the same magnitude.

.

The key point is that the observer within the car can see the separation changes among some objects, including the car itself, within the car.

— Me@2023-12-06 11:06:23 AM

— Me@2023-12-24 05:58:54 PM

.

.

2023.12.26 Tuesday (c) All rights reserved by ACHK

NDE


22 07 2003

“Do not concentrate too much on being useful to others, but concentrate more on being useful to yourself.”
 

.

.

2023.12.24 Sunday ACHK

宇宙的琴弦

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

.

中學時代讀男校,少與女性相處,所以印象中,男仕是怪獸,女仕是仙子。多年後發現,那不一定。

比較內心而言,有一部分男仕,其實優雅過一部分女仕。

(你又怎會知道,他人的內心優不優美呢?)

觀察她的言行舉止就可以。例如,如果她有網誌的話,你可以閱讀之,看看她通常寫什麼題材。

— Me@2023-12-22 04:42:28 PM

.

.

2023.12.23 Saturday (c) All rights reserved by ACHK

Euler problem 18.1

(ql:quickload "str")

;; (defun file-get-contents (filename)
;;   (with-open-file (stream filename)
;;     (let ((contents (make-string
;;                      (file-length stream))))
;;       (read-sequence contents stream)
;;       contents)))

(defun file-get-lines (filename)
  (with-open-file (stream filename)
    (loop :for line = (read-line stream nil)
          :while line
          :collect line)))

;; (defun string-to-list (the-string)
;;   (loop :for char :across the-string
;;         :collect char))

;; (defun char-to-integer-list (char-list)
;;   (mapcar #'digit-char-p char-list))

(defun path-add-item (x yys zzs)
  (let* ((y (car yys))
         (ys (cdr yys))
         (z (car zzs))
         (zs (cdr zzs))
         (m (if (> y z) y z))
         (ms (if (> y z) ys zs)))
    (cons (+ x m) (cons x ms))))

(defmacro zipWith3 (f xs ys zs)
  `(mapcar ,f ,xs ,ys ,zs))

(defun path-add-item-zip (acc xs)
  (zipWith3 #'path-add-item xs acc (cdr acc)))

(defun foldl (f acc xs)
  (if (not xs)
      acc
      (foldl f (funcall f acc (car xs)) (cdr xs))))

(defun string-split (x)
  (str:split #\space x))

(defun map-parse-integer (xs)
  (mapcar #'parse-integer xs))

(defmacro map-string-split (xs)
  `(mapcar #'string-split ,xs))

(defmacro head (xs)
  `(car ,xs))

(defmacro tail (xs)
  `(cdr ,xs))

(defun pair-double (x)
  (list x x))

(defun e18 ()
  (let* ((string-lines (file-get-lines #P"n.txt"))
         (string-lists (map-string-split string-lines))
         (number-tower (mapcar #'map-parse-integer
                               string-lists))
         (r-tower (reverse number-tower))
         (acc (mapcar #'pair-double (head r-tower))))
    
    (foldl #'path-add-item-zip acc (tail r-tower))))

CL-USER> (e18)
((1074 75 64 82 87 82 75 73 28 83 32 91 78 58 73 93))
CL-USER> 

— Me@2023-12-20 07:32:00 PM

.

.

2023.12.21 Thursday (c) All rights reserved by ACHK

Taylor expansion of f around x

Series can also be formed by processes such as exponentiation of an
operator or a square matrix. For example, if f is any function of one
argument, and if x and dx are numerical expressions, then this
expression denotes the Taylor expansion of f around x.

(((exp (* dx D)) f) x)
= (+ (f x) (* dx ((D f) x)) (* 1/2 (expt dx 2) (((expt D 2) f) x)) ...)

— refman

.

(((exp (* 'dx D)) (literal-function 'f)) 'x)
#| (*series* (0 . 0) (*number* (expression (f x)) (literal-function #[apply-hook 40]) (type-expression Real)) . #[promise 41 (unevaluated)]) |#

(show-expression
 (series:print (((exp (* 'dx D))
                 (literal-function 'f)) 'x)))
(f x)
(* dx ((D f) x))
(* 1/2 (expt dx 2) (((expt D 2) f) x))
(* 1/6 (expt dx 3) (((expt D 3) f) x))
(* 1/24 (expt dx 4) (((expt D 4) f) x))
(* 1/120 (expt dx 5) (((expt D 5) f) x))
(* 1/720 (expt dx 6) (((expt D 6) f) x))
(* 1/5040 (expt dx 7) (((expt D 7) f) x))
(* 1/40320 (expt dx 8) (((expt D 8) f) x))
(* 1/362880 (expt dx 9) (((expt D 9) f) x))
(* 1/3628800 (expt dx 10) (((expt D 10) f) x))
(* 1/39916800 (expt dx 11) (((expt D 11) f) x))
(* 1/479001600 (expt dx 12) (((expt D 12) f) x))
(* 1/6227020800 (expt dx 13) (((expt D 13) f) x))
(* 1/87178291200 (expt dx 14) (((expt D 14) f) x))
;Aborting!: maximum recursion depth exceeded

— Me@2023-12-20 11:30:50 AM

.

.

2023.12.20 Wednesday (c) All rights reserved by ACHK

@dialectphilosophy, 1.3.2

He can deduce the relative velocity v_2 - v_1 by the separations x_2(t) - x_1(t) and x_2(0) - x_1(0). However, he still cannot deduce v_2 nor v_1 unless he is able to look outside the car window. Thus, he cannot deduce the car speed v just by observing the positions and velocities of the objects inside the car.

.

For simplicity, assume object 1 is actually a point of the car itself. So v_1 is actually the speed of the car, v. Then the calculation

\displaystyle{  \begin{aligned}  &x_2(t) - x_1(t) \\  &= \Bigl( x_2(0) + v_2 t \Bigr) - \Bigl(x_1(0) + v_1 t \Bigr) \\  &= \Bigl( x_2(0) - x_1(0) \Bigr) + \Bigl( v_2 - v_1 \Bigr) t \\  \end{aligned}}

becomes

\displaystyle{  \begin{aligned}  &x_2(t) - x(t) \\  &= \Bigl( x_2(0) - x(0) \Bigr) + \Bigl( v_2 - v \Bigr) t \\  \end{aligned}}

where x is a point of the car.

In this case, x_{2c} = x_2(t) - x(t) becomes the position of object 2 relative to car; and v_{2c} = v_2 - v becomes the velocity of object 2 relative to the car. The equation can be simplified to

\displaystyle{  \begin{aligned}  x_{2c}(t) &= x_{2c}(0) + v_{2c} t \\  \end{aligned}}

.

If the car has acceleration, the story is totally different. In short, for the observer inside the car, the path of each particle is not a straight line anymore. In long, the previous calculation becomes

\displaystyle{  \begin{aligned}  &x_2(t) - x(t) \\   &= \Bigl( x_2(0) + v_2 t - 1/2 a t^2 \Bigr) - \Bigl(x(0) + v t - 1/2 a t^2 \Bigr) \\  &= \Bigl( x_2(0) - x(0) \Bigr) + \Bigl( v_2 - v \Bigr) t \\  \end{aligned}}

where a is the acceleration of the car. Here, we assume that v_1, v_2, and a are all pointing in the same direction.

Although the result is the same as before:

\displaystyle{  \begin{aligned}  x_{2c}(t) &= x_{2c}(0) + v_{2c} t, \\  \end{aligned}}

the velocity v_{2c} is no longer a constant; it would keep decreasing.

In the no acceleration case, even if the particle velocity and the car velocity are not in parallel, the observer will see a straight path. However, in the accelerated case where the acceleration and velocity directions are not in parallel, the path of the particle will no longer be a straight line.

That is what “acceleration is absolute” means. The observer can notice different phenomena, compared with the no-acceleration case, even without seeing outside the car window.

The additional meaning of “acceleration is absolute” is that we deduce the acceleration value by measuring v_{2c}(0), v_{2c}(t), and t. And, unlike velocity values, this acceleration value is identical for any two observers related by a Galilean transformation. (They are called inertial observers.)

— Me@2023-12-06 11:06:23 AM

.

.

2023.12.16 Saturday (c) All rights reserved by ACHK

神必成魔

Some of the biggest cases of mistaken identity are among intellectuals who have trouble remembering that they are not God.

— Thomas Sowell

.

1. 魔來自神;

2. 神必成魔,

因為神自以為,高人一等。

.

間中做好事,永不做好人。

— Me@2023-12-02 12:37:01 AM

.

贓官可恨,人人知之,清官尤可恨人多不知,蓋贓官自知有病,不敢公然為非;清官則自以為不要錢,何所不可,剛愎自用,小則殺人,大則誤國,吾人親目所見,不知凡幾矣。

唉!天下大事壞於奸臣手上的十之三四,壞於不通世故的君子手上的倒有十分之六七!

— 老殘遊記

.

壞人是壞

好人也壞

因為時刻干涉他人的人生

沒有邊界感,非禮也

.

好人比壞人更恐怖

壞人害怕報復

好人無所顧忌

.

壞人企圖,謀財而害命

好人無知,殺人於無形

.

壞人你會有所提防

好人你會不知不覺

.

壞人可以武力對付

好人只能積極逃避

.

邪惡可以激烈抵抗

愚蠢只能無可奈何

— Me@2023-12-02 12:37:01 AM

.

魔鬼,也是由天使變成的。

不企圖做天使,就不會變成魔鬼。

— Me@2016-08-06 03:02:36 PM

.

You either “die” a hero, or live long enough to see yourself become the villain.

— Harvey Dent

.

Don’t try to be a god.

Remember, reaching the maximum also means going to fall.

— Me@2023-12-02 11:40:09 PM

.

.

2023.12.13 Wednesday (c) All rights reserved by ACHK

Eval the buffer

(defun common-lisp-eval (str)
  (unless (slime-current-connection)
    (let ((wnd (current-window-configuration)))
      (slime)
      (while (not (and (slime-current-connection)
                       (get-buffer-window
                        (slime-output-buffer))))
        (sit-for 0.2))
      (set-window-configuration wnd)))
  (let (deactivate-mark)
    (slime-eval `(swank:eval-and-grab-output ,str))))

(defun file-eval ()
  (interactive)
  (message
   (car (common-lisp-eval
         (concat "(format t \"~{~a~%~}\" (list "
                 (string-make-unibyte
                  (buffer-string)) "))")))))

(defun region-eval (from to)
  (interactive "r")
  (message
   (car (common-lisp-eval
         (concat "(format t \"~{~a~%~}\" (list "
                 (string-make-unibyte
                  (buffer-substring
                   from to)) "))")))))

(global-set-key (kbd "C-F") 'file-eval)
(global-set-key (kbd "C-R") 'region-eval)

— Me@2023-12-10 09:59:57 AM

.

.

2023.12.11 Monday (c) All rights reserved by ACHK

3.6 Analytic continuation for gamma function, 3

A First Course in String Theory

.

Explain why the above right-hand side is well defined for \displaystyle{  \Re (z) > - N - 1  }.

~~

\displaystyle{  \begin{aligned}    \Gamma (z) &= \int_{0}^{1}t^{z-1}e^{-t}dt + \int_{1}^{\infty}t^{z-1}e^{-t}dt \\\\    \end{aligned} \\ }

.

Prove that \displaystyle{\int_{1}^{\infty}t^{z-1}e^{-t}dt} converges.

Prove that \displaystyle{\int_{0}^{1}t^{z-1}e^{-t}dt} converges.

\displaystyle{  \begin{aligned}    \Re (z) &> 0 \\    \Gamma (z) &= \int_{0}^{\infty}t^{z-1}e^{-t}dt \\    &= \int_{0}^{1}t^{z-1}e^{-t}dt + \int_{1}^{\infty}t^{z-1}e^{-t}dt \\\\    \end{aligned} \\ }

\displaystyle{  \begin{aligned}    &\int_{0}^{1}t^{z-1}e^{-t}dt \\    &= \int_{0}^{1} t^{z-1} \sum_{n=0}^\infty \frac{(-t)^n}{n!} dt \\    &= \int_{0}^{1} t^{z-1} \left(  \sum_{n=0}^N \frac{(-t)^n}{n!}  +\sum_{n=N+1}^\infty \frac{(-t)^n}{n!}  \right) dt \\    \end{aligned} \\ }

\displaystyle{  \begin{aligned}    &= \int_{0}^{1} t^{z-1} \left(  \sum_{n=0}^N \frac{(-t)^n}{n!}  + e^{-t} - \sum_{n=0}^N \frac{(-t)^n}{n!}  \right) dt \\    \end{aligned} \\ }

.

\displaystyle{  \begin{aligned}    &\int_{0}^{1} t^{z-1} \frac{(-t)^n}{n!} dt \\    &= \frac{(-1)^n}{n!} \int_{0}^{1} t^{z+n-1} dt \\    &= \frac{(-1)^n}{n!} \frac{1}{z+n} \left[ 1 - 0^{z+n} \right] \\    \end{aligned} \\ }

Therefore, for the integral to converge, \displaystyle{  \Re (z) + n > 0  } is required. So for the overall integral \displaystyle{  \int_{0}^{1} t^{z-1} \sum_{n=0}^\infty \frac{(-t)^n}{n!} dt} to converge, a necessary condition is

\displaystyle{  \Re (z) + n_{\text{min}} > 0  }

Therefore,

\displaystyle{  \Re (z) > 0  }

.

Under this condition,

\displaystyle{ \begin{aligned} &\int_{0}^{1}t^{z-1}e^{-t}dt \end{aligned}  }
\displaystyle{   = \int_{0}^{1} t^{z-1} \left( \sum_{n=0}^N \frac{(-t)^n}{n!} +\sum_{n=N+1}^\infty \frac{(-t)^n}{n!} \right) dt, }

\displaystyle{   = \sum_{n=0}^N  \frac{(-1)^n}{n!} \frac{1}{z+n} + \int_{0}^{1} t^{z-1} \sum_{n=N+1}^\infty \frac{(-t)^n}{n!} dt}

So for \displaystyle{\Re (z) > 0},

— Me@2023-09-07 07:38:17 PM

.

.

2023.12.08 Friday (c) All rights reserved by ACHK

@dialectphilosophy, 1.3.1

As long as object 1 and object 2 have the same velocity-relative-to-the-ground as that of the car, \displaystyle{v}, i.e.

\displaystyle{v_1=v_2=v},

no matter what the value of \displaystyle{v} is, the distance between object 1 and object 2 is always the same. In other words, you cannot deduce the value of the \displaystyle{v} by observing the separation changes between any two objects/points within the car.

.

Even in another case where \displaystyle{v_2 \ne v_1},

the separation between the 2 objects is

\displaystyle{  \begin{aligned}  &x_2(t) - x_1(t) \\  &= \Bigl( x_2(0) + v_2 t \Bigr) - \Bigl(x_1(0) + v_1 t \Bigr) \\  &= \Bigl( x_2(0) - x_1(0) \Bigr) + \Bigl( v_2 - v_1 \Bigr) t \\  \end{aligned}}

In other words, the separation \displaystyle{(x_2(t) - x_1(t))} depends only on the initial separation \displaystyle{(x_2(0) - x_1(0))} and the velocity of object 2 relative to the object 1, \displaystyle{(v_2 - v_1)}.

Let this relative velocity be \displaystyle{v_{21}}:

\displaystyle{  \begin{aligned}  v_{21} &= v_2 - v_1 \\   \end{aligned}}

Although the value of either v_1 or v_2 depends on the observer’s own velocity, v_{21} does not. In other words, although either v_1 or v_2 would have a different value under Galilean transformation, v_{21} would stay the same.

\displaystyle{  \begin{aligned}  v_{21}'   &= v_2' - v_1' \\   &= (v_2 + V) - (v_1 + V) \\   &= v_2 - v_1 \\   &= v_{21} \\   \end{aligned}}

The observer can directly see are positions x_1(0), x_2(0), x_1(t), and x_2(t). With them and the time measured t, he can deduce the value of v_{21}.

He can deduce the relative velocity v_2 - v_1 by the separations x_2(t) - x_1(t) and x_2(0) - x_1(0). However, he still cannot deduce v_2 nor v_1 unless he is able to look outside the car window. Thus, he cannot deduce the car speed v just by observing the positions and velocities of the objects inside the car.

.

For simplicity, assume object 1 is actually a point of the car itself. So v_1 is actually the speed of the car, v. Then the calculation

\displaystyle{  \begin{aligned}  &x_2(t) - x_1(t) \\  &= \Bigl( x_2(0) + v_2 t \Bigr) - \Bigl(x_1(0) + v_1 t \Bigr) \\  &= \Bigl( x_2(0) - x_1(0) \Bigr) + \Bigl( v_2 - v_1 \Bigr) t \\  \end{aligned}}

becomes

— Me@2023-12-06 11:06:23 AM

.

.

2023.12.06 Wednesday (c) All rights reserved by ACHK

正義使者

當你覺得自己是「正義使者」時,就是入魔的時候,

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

因為你開始自我中心,

不再詳細考慮,做一件事效果的真正好壞,

而只著眼於自我形象 (我要做好人)。

.

.

.

.

.

.

記住:

做好事,不要做好人。

— Me@2015-10-06 12:13:05 PM

.

.

2023.12.03 Sunday (c) All rights reserved by ACHK