# 排列組合 1.3

nCr, 0.3

.

— Me@2022.09.29 10:11:00 AM

.

.

# SimCity 2013

Euler problem 3.4

.

.

primes = 2 : filter (null . tail . primeFactors) [3, 5 ..]

primeFactors n = factor n primes
where
factor n (p : ps)
| p * p > n = [n]
| n mod p == 0 = p : factor (n div p) (p : ps)
| otherwise = factor n ps

f = last (primeFactors 600851475143)


.

— Me@2022.09.28 11:44:20 AM

.

.

# Ex 1.28 Prequel 1

Structure and Interpretation of Classical Mechanics

.

An analogous result holds when the $f_\alpha$‘s depend explicitly on time.

a. Show that in this case the kinetic energy contains terms that are linear in the generalized velocities.

~~~

Eq. (1.141):

$\displaystyle{ \textbf{v}_\alpha = \partial_0 f_\alpha (t,q) + \partial_1 f_\alpha (t, q) v }$

Eq. (1.142):

$\displaystyle{T(t, q, v) = \frac{1}{2} \sum_{\alpha} m_\alpha v^2_\alpha}$

Eq. (1.133):

\displaystyle{ \begin{aligned} \mathcal{P}_i &= (\partial_2 L)_i \\ \end{aligned}}

where $\displaystyle{\mathcal{P}}$ is called the generalized momentum.

.

\displaystyle{ \begin{aligned} \mathcal{P} \dot Q &= (\partial_2 L) \dot Q \\ &= (\partial_2 (T-V)) \dot Q \\ &= (\partial_2 T) \dot Q \\ \end{aligned}}

where $\displaystyle{\dot Q}$ is the velocity selector. And $V$ has no velocity component?

.

“… $T$ is a homogeneous function of the generalized velocities of degree 2.”

\displaystyle{ \begin{aligned} n &= 2 \\ (\partial_2 T) \dot Q &= ? \\ \end{aligned}}

\displaystyle{ \begin{aligned} x Df(x) &= nf(x) \\ \end{aligned}}

.

What does the $D$ actually mean?

\displaystyle{ \begin{aligned} x Df(x) &= nf(x) \\ x \frac{d}{dx} f(x) &= nf(x) \\ \end{aligned}}

\displaystyle{ \begin{aligned} \mathbf{v} D T (\mathbf{v}) &= 2 T (\mathbf{v}) ? \\ \end{aligned}}

.

\displaystyle{ \begin{aligned} \partial_{\vec 2} = \frac{\partial}{\partial \vec{\dot q}} &= \begin{bmatrix} \frac{\partial}{\partial \dot q_1} & \frac{\partial}{\partial \dot q_2} & ... \end{bmatrix} \\ \\ \mathcal{P} \dot Q &= (\partial_2 T) \dot Q \\ \\ \begin{bmatrix} \mathcal{P}_1 & \mathcal{P}_2 & ... \end{bmatrix} \begin{bmatrix} \dot Q_1 \\ \dot Q_2 \\ \vdots \end{bmatrix} &= \begin{bmatrix} (\partial_2 T)_1 & (\partial_2 T)_2 & ... \end{bmatrix} \begin{bmatrix} \dot Q_1 \\ \dot Q_2 \\ \vdots \end{bmatrix} \\ \\ &= \begin{bmatrix} \frac{\partial T}{\partial \dot q_1} & \frac{\partial T}{\partial \dot q_2} & ... \end{bmatrix} \begin{bmatrix} \dot Q_1 \\ \dot Q_2 \\ \vdots \end{bmatrix} \\ \\ &= \frac{\partial T}{\partial \dot q_1} \dot Q_1 + \frac{\partial T}{\partial \dot q_2} \dot Q_2 + ... \\ \end{aligned}}

.

Euler’s Homogeneous Function Theorem:

If

\displaystyle{ \begin{aligned} f(t x_1, t x_2, ...) &= t^n f( x_1, x_2 , ...), \\ \end{aligned}}

then

\displaystyle{ \begin{aligned} \sum_{i} x_i \frac{\partial f}{\partial x_i} &= n f(\mathbf{x}) \\ \end{aligned}}

.

$\displaystyle{T(t, q, v) = \frac{1}{2} \sum_{\alpha} m_\alpha v^2_\alpha}$

So

\displaystyle{\begin{aligned} T(t, q, uv) &= \frac{1}{2} \sum_{\alpha} m_\alpha (uv)^2_\alpha \\ &= u^2 T(t, q, v) \\ \end{aligned} }

Therefore,

\displaystyle{ \begin{aligned} \frac{\partial T}{\partial \dot q_1} \dot Q_1 + \frac{\partial T}{\partial \dot q_2} \dot Q_2 + ... &= 2 T \\ \end{aligned}}

— Me@2022.09.27 12:26:09 PM

.

.

# Encyclopædia Britannica

The preceding illustrates, simply but clearly, one of the proclivities that are often associated with mathematical thought: relatively simple concepts (such as integers), initially based on very concrete operations (for example, counting), are found to be capable of assuming novel meanings and potential uses, extending far beyond the limits of the concept as originally defined.

— Encyclopædia Britannica

— 31.12.2002

.

.

2022.09.27 Tuesday ACHK

# 眾害取其輕 10.1

The least of all evils, 10 | 地獄之路 3.2 | Good intentions 3.2

.

1. 有問題一定要解決。

2. 「難受」一定要避免。

3. 任何情況下，都要避免自己或他人的難受。

.

.

.

「眾害之最輕」有時可以零，有時不可以零。你只能客觀面對，不能主觀判斷。換句話說，「眾害之最輕」不一定「可以零」，亦不一定「不可以零」。

.

1. 理解後背誦

2. 有用的東西就背

3. 無用的東西就不背

.

— Me@2022.09.24 10:56:23 AM

.

.

Euler problem 3.3

.

The goal of this blog post is to install an advanced Haskell mode, called LSP mode, for Emacs.

.

1. Open the bash terminal, use the following commands to install the three packages:

sudo apt-get install elpa-haskell-mode

sudo apt-get install elpa-yasnippet

sudo apt-get install elpa-which-key


.

2. Read and follow the exact steps of my post titled “Haskell mode“.

.

.

— Me@2022.09.20 12:49:29 PM

.

.

# Functional Differential Geometry

Chapter 1: Introduction

.

(define ((Gamma w) t)
(up t (w t) ((D w) t)))

(define q-rect
(up (literal-function 'x_0)
(literal-function 'y_0)
(literal-function 'x_1)
(literal-function 'y_1)
(literal-function 'F)))

(show-expression (q-rect 't))

(show-expression ((Gamma q-rect) 't))

(define ((Lfree mass) state)
(* 1/2 mass (square (velocity state))))

(define ((sphere->R3 R) state)
(let ((q (coordinate state)))
(let ((theta (ref q 0)) (phi (ref q 1)))
(up (* R (sin theta) (cos phi))
(* R (sin theta) (sin phi))
(* R (cos theta))))))

(define ((F->C F) local)
(up (time local)
(F local)
(+ (((partial 0) F) local)
(* (((partial 1) F) local)
(velocity local)))))

(define (Lsphere m R)
(compose (Lfree m) (F->C (sphere->R3 R))))

((Lsphere 'm 'R)
(up 't
(up 'theta 'phi)

(show-expression
((Lsphere 'm 'R)
(up 't
(up 'theta 'phi)

(define ((L2 mass metric) place velocity)
(* 1/2
mass
((metric velocity velocity) place)))

(define ((Lc mass metric coordsys) state)
(let ((x (coordinates state))
(v (velocities state))
(e (coordinate-system->vector-basis
coordsys)))
((L2 mass metric)
((point coordsys) x) (* e v))))

(define the-metric
(literal-metric 'g R2-rect))

(define L
(Lc 'm the-metric R2-rect))

(L (up 't (up 'x 'y) (up 'vx 'vy)))

(show-expression
(L (up 't (up 'x 'y) (up 'v_x 'v_y))))

(define gamma
(literal-manifold-map 'q R1-rect R2-rect))

((chart R2-rect)
(gamma ((point R1-rect) 't)))

(show-expression
((chart R2-rect)
(gamma ((point R1-rect) 't))))

(define coordinate-path
(compose
(chart R2-rect) gamma (point R1-rect)))

(coordinate-path 't)

(define Lagrange-residuals
(((Lagrange-equations L)
coordinate-path) 't))

(show-expression
Lagrange-residuals)

(define-coordinates t R1-rect)

(define Cartan
(Christoffel->Cartan
(metric->Christoffel-2
the-metric
(coordinate-system->basis R2-rect))))

(define geodesic-equation-residuals
(((((covariant-derivative Cartan gamma) d/dt)
((differential gamma) d/dt))
(chart R2-rect))
((point R1-rect) 't)))

(define metric-components
(metric->components
the-metric
(coordinate-system->basis R2-rect)))

(- Lagrange-residuals
(* (* 'm (metric-components
(gamma ((point R1-rect) 't))))
geodesic-equation-residuals))

(show-expression
(- Lagrange-residuals
(* (* 'm (metric-components
(gamma ((point R1-rect) 't))))
geodesic-equation-residuals)))


— Me@2022.09.18 04:25:12 PM

.

.

2022.09.18 Sunday ACHK

Posted in FDG

# The Ship of Theseus

_jgvg on July 23, 2018 | next [–]

This reminds me of someone who once told me that the vast majority of philosophical problems are self-inflicted and caused by the intentional use of vague and ambiguous definitions, and therefore could be solved trivially simply by agreeing on a definition for something.

One example given was the Theseu’s Paradox (or The Ship of Theseus).

The entire problem only exists because you’re intentionally using a vague term in the problem, therefore causing the problem itself.

At least that was the commentary, I’m not an expert in the subject, and I’m sure many will disagree. But then, even the disagreeing is just pointlessly creating a problem for the sake of the discussion.

zukzuk on July 23, 2018 | parent | next [–]

I think you’re missing something really profound here. I wrote my masters thesis on identity problems in version control systems (Git, Mercurial, Subversion, and the like). These systems are forced to take a stance on the Ship of Theseus problem — they’re tracking the identity of files/documents whose entire contents, name, and format may change over time.

Different systems have chosen to take very different stances on this. As it turns out, taking a stance on what makes a file a file (or a ship a ship) — being explicit rather than vague — does not solve the problem. Not even close. In fact, one of the many little things that make Git a brilliant piece of software is that it refuses to take a stance on identity. Git is intentionally vague about what makes a file a file. It doesn’t actually track it at all — file identity is determined retroactively. It’s a question for which Git intentionally doesn’t have a straight answer.

What I think is really fascinating about all of this is that computers are forcing us to deal with age-old philosophical problems head on. These are not just interesting riddles anymore. They’re real problems that need concrete solutions. Event more interestingly, there is something in this that establishes computing as categorically different from just pure mathematics. Computing forces us to bridge abstraction with the real world — to answer questions like what is the relationship between an abstract model and the thing that is being modelled. This to me is really exciting, and what follows from it can’t be easily dismissed with a comment like “most philosophical problems only exist because language is vague”.

— Was Wittgenstein Right? (2013)

— Hacker News

.

.

2022.09.15 Thursday ACHK

# 地獄之路 3

Good intentions 3

.

— 老殘遊記

.

（JC: 不記得何時，看過一個紀錄片，主持人到非洲做義工。

.

— Me@2022.09.13 12:01:08 PM

.

.

# 相聚一刻, 2

— 潘偉源

.

.

2022.09.12 Monday ACHK

# 3.2 Maxwell equations in four dimensions

A First Course in String Theory

.

(a) Show explicitly that the source-free Maxwell equations emerge from $\displaystyle{T_{\mu \lambda \nu} = 0}$.

~~~

\displaystyle{ \begin{aligned} T_{\mu \lambda \nu} &= 0 \\ \partial_\lambda F_{\mu \nu} + \partial_\mu F_{\nu \lambda} + \partial_\nu F_{\lambda \mu} &= 0 \\ \end{aligned}}

\displaystyle{ \begin{aligned} \partial_0 F_{1 3} + \partial_1 F_{3 0} + \partial_3 F_{0 1} &= 0 \\ - \partial_0 B_y + \partial_1 E_z - \partial_3 E_x &= 0 \\ \\ \frac{\partial E_x}{\partial z} - \frac{\partial E_z}{\partial x} &= - \frac{1}{c} \frac{\partial B_y}{\partial t} \\ \end{aligned}}

— Me@2022.09.11 01:40:50 PM

.

.

# Photons in expanding space

If a photon (wave package) redshifts (stretches) travelling in our expanding universe, is its energy reduced?

.

Since you say you’re talking about what happens locally (in a small volume), I’ll answer from that point of view. The usual formulation of energy conservation in such a volume is that energy is conserved in an inertial reference frame. In general relativity, there are no truly inertial frames, but in a sufficiently small volume, there are reference frames that are approximately inertial to any desired level of precision. If you restrict your attention to such a frame, there is no cosmological redshift. The photon’s energy when it enters one side of the frame is the same as the energy when it exits the other side. So there’s no problem with energy conservation.

The (apparent) failure of energy conservation arises only when you consider volumes that are too large to be encompassed by a single inertial reference frame.

To be slightly more precise, in some small volume $V=L^3$ of a generic expanding Universe, imagine constructing the best possible approximation to an inertial reference frame. In that frame, observers near one edge will be moving with respect to observers near the other edge, at a speed given by Hubble’s Law (to leading order in $L$). That is, in such a frame, the observed redshift is an ordinary Doppler shift, which causes no problems with energy conservation.

If you want more detail, David Hogg and I wrote about this at considerable (perhaps even excessive!) length in an AJP paper.

— Photons in expanding space: how is energy conserved?

— answered Aug 16, 2011 at 15:31

— Ted Bunn

— Physics Stack Exchange

.

.

2022.09.11 Sunday ACHK

# Combination Lock 3

jancsika on July 26, 2018 | next [–]

I think the article makes “epiphany” sound rather extraordinary. But in the normal course of learning music there are plenty of them which we tend to ignore for some reason.

For example: if you learned to ride a bike as a kid, you’ll remember a moment where your balance just “locked in” and there you were riding for an arbitrary amount of time.

— Some suddenly become accomplished artists or musicians with no previous training

— Hacker News

.

.

2022.09.10 Saturday ACHK

# 排列組合 1.2

nCr, 0.2

.

1.4.2 另外一種設計定義的想法是，由 $\displaystyle{n!}$算式取靈感。

$\displaystyle{0! = a^0}$

.

「零項相乘」即是「乘了等如沒有乘」，所以是一，因為任何數乘了一，效果都等於沒有乘；所以，

$\displaystyle{a^0 = 1}$

$\displaystyle{0! = 1}$

.

「零項相乘」的正式學名是，「空積」或「零項積」。

.

1.4.3 如果要詳細一點，去理解「空積」的話，可以先嘗試了解「次方」的意思。

$\displaystyle{a^5 = aaaaa}$

.

$\displaystyle{a^5 a^3 = (aaaaa)(aaa)}$

.

$\displaystyle{a^5 a^3 = a^{5+3}}$

.

.

$\displaystyle{a^5 a^{-3} = \frac{aaaaa}{aaa}}$

.

$\displaystyle{a^{-3} = \frac{1}{a^3}}$

.

$\displaystyle{a}$次方，又會是什麼呢？

.

.

$\displaystyle{a^5 a^{1/2} a^{1/2}}=?$

.

$\displaystyle{a^5 a^{1/2} a^{1/2}}=a^5 a^1$

.

$\displaystyle{a^5 a^{1/2} a^{1/2}}=a^6$

.

$\displaystyle{a^{1/2} a^{1/2}}=a^1$

.

$\displaystyle{\sqrt{a} \sqrt{a}}=a^1$

.

$\displaystyle{a^{\frac{1}{2}} = \sqrt{a}}$

.

$\displaystyle{a}$ 五次方乘以 $\displaystyle{a}$ 的正三次，就是乘多三個 $\displaystyle{a}$；所以，結果就是 $\displaystyle{a}$ 的八次方。

$\displaystyle{a^5 a^3 = (aaaaa)(aaa) = a^8}$

$\displaystyle{a^5 a^{-3} = a^2}$

.

$\displaystyle{a^5 a^{0} = aaaaa = a^5}$

.

— Me@2022.09.07 08:09:14 PM

.

.

# Way

There is always a WAY.

.

(defun sum-of-squares(x y &key (a 1) (b 1))
(+ (* a x x) (* b y y)))

(deftype candidate()
'(simple-array boolean (*)))

(defmacro get-sieve-function(a b mod-results)
(lambda(x y)
(let* ((n (sum-of-squares x y :a ,a :b ,b))
(r (mod n 12)))
(when (and (<= n limit)
(not (null
(member r ,mod-results))))
(setf (aref candidates n)
(not (aref candidates n)))))))

(defun get-atkin-prime-candidates-map(limit)
(let* ((lmt (isqrt limit))
(candidates (make-array
(1+ limit)
:initial-element nil))
(stage1 (get-sieve-function 4 1 '(1 5)))
(stage2 (get-sieve-function 3 1 '(7)))
(stage3 (get-sieve-function 3 -1 '(11))))
(declare (type candidate candidates))
(declare (optimize (speed 3)))
(loop for x from 1 to lmt do
(loop for y from 1 to lmt do
(progn
(funcall stage1 x y)
(funcall stage2 x y)
(when (> x y)
(funcall stage3 x y)))))
candidates))

(defun atkin-sieve-map(candidates)
(let ((len (length candidates)))
(loop for i from 1 to (1- len)
when (aref candidates i)
do (loop for j from 1
for n = (* j i i)
while (< n len)
do (setf (aref candidates n) nil))))
(setf (aref candidates 2) T)
(setf (aref candidates 3) T)
candidates)

(defun eratosthene-sieve-map(limit)
(let ((candidates
(make-array
(1+ limit) :initial-element T)))
(declare (type candidate candidates))
(declare (optimize (speed 3)))
(progn
(setf (aref candidates 0) nil)
(setf (aref candidates 1) nil))
(loop for i from 2 to limit
when (aref candidates i)
do (loop for j from (+ i i) to limit by i
when (aref candidates j)
do (setf (aref candidates j) nil)))
candidates))

;; This is free software released
;; into the public domain.
;;
;; ykm

(defun get-primes(limit
&key
(generator :eratosthene))
(let ((candidates
(case generator
(:atkin (atkin-sieve-map
(get-atkin-prime-candidates-map
limit)))
(:eratosthene (eratosthene-sieve-map
limit))
(otherwise
(error "not valid type
(:atkin :eratosthene)")))))
(declare (type candidate candidates))
(loop for i from 0 to (1- (length candidates))
when (aref candidates i)
collect i)))

(format t "soe: ~d
" (time (length (get-primes 12345678))))

(format t "soa: ~d
" (time (length (get-primes 12345678
:generator :atkin))))

(defmacro log10 (x)
(/ (log ,x) (log 10)))


.

— Me@2022.09.06 03:24:36 PM

.

.

# Homogenous function

A function $f$ is homogenous of degree $n$ if and only if $f(ax) = a^n f(x)$.

— 1.8 Conserved Quantities

— Structure and Interpretation of Classical Mechanics

.

\displaystyle{\begin{aligned} D_a f(ax) &= \frac{d}{da} f(ax) \\ &= \frac{d}{da} a^n f(x) \\ &= f(x) \frac{d}{da} a^n \\ &= n a^{n-1} f(x) \\ \end{aligned}}

.

\displaystyle{\begin{aligned} D_a f(ax) &= \frac{d}{da} f(ax) \\ &= \frac{d(ax)}{da} \frac{d}{d(ax)} f(ax) \\ &= x \frac{d}{d(ax)} f(ax) \\ &= x D_{ax} f(ax) \\ \end{aligned}}

.

\displaystyle{\begin{aligned} x D_{ax} f(ax) &= n a^{n-1} f(x) \\ x D_{x} f(x) &= n f(x) \\ \end{aligned}}

— Me@2022.09.05 06:28:00 PM

.

.

# Ideal clock 5

Clock time is the extreme case of event time, by considering the weighted average of all events.

— Me@2011.05.19

.

.

# 11X

~~~

... 中化口試

~~~

10k trimmer pot: 7.31k

~~~

3150, 4260: Samuel

3170: Danny, 達
3260: Dennis

~~~


.

.