# Euler problem 12.1.1

(defmacro sq (x)
(* ,x ,x))

(defmacro last-item (lst)
(car (last ,lst)))

(defun good-reverse (lst)
(labels ((rev (lst acc)
(if (null lst)
acc
(rev
(cdr lst)
(cons (car lst) acc)))))
(rev lst nil)))

(defun prime-sieve-a-list (input-lst)
(labels ((sieve-iter (go-lst acc-list)
(if (not go-lst)
acc-list
(if (> (sq (car go-lst))
(last-item go-lst))

(append (good-reverse acc-list)
go-lst)

(sieve-iter
(remove-if #'(lambda (x)
(=
(mod x
(car go-lst))
0))
(cdr go-lst))
(cons (car go-lst)
acc-list))))))

(sieve-iter input-lst '())))

(defun range (max &key (min 0) (step 1))
(loop :for n :from min :below max :by step
collect n))

(defmacro prime-sieve (n)
(prime-sieve-a-list (cons 2
(range (1+ ,n)
:min 3
:step 2))))

(time (length (prime-sieve 20000000)))

;; Evaluation took:
;; 19.907 seconds of real time


What is the value of the first triangle number to have over five hundred divisors?

(defun factor-iter (n p-list acc-list)
(if (NULL p-list)
acc-list
(let* ((p (car p-list))
(ps (cdr p-list)))
(cond ((> (* p p) n)
(good-reverse (cons n
acc-list)))
((eql (mod n p) 0)
(factor-iter (floor n p)
p-list
(cons p acc-list)))
('t
(factor-iter n ps acc-list))))))

(defparameter *pm* 2000000)

(defparameter *psi* (prime-sieve *pm*))

(defun factor (n)
(if (> n (expt *pm* 2))

(let ((m (floor (sqrt n))))
(factor-iter n (prime-sieve m) '()))

(factor-iter n *psi* '())))

(defun group-factors (lst)
(labels ((gf (acc lst)
(if (NULL lst)
(good-reverse acc)
(let* ((p (car lst))
(ps (cdr lst))
(lp1 (list p 1)))
(if (NULL acc)
(gf (list lp1) ps)
(if (eql p (caar acc))
(gf (cons
(list p
(+ 1
(cdr acc))
ps)
(gf (cons lp1 acc) ps)))))))
(gf '() lst)))

(defmacro sum (lst)
(reduce #'+ ,lst))

(defmacro product (lst)
(reduce #'* ,lst))

(defun nDiv (n)
(product (mapcar #'(lambda (x) (1+ (cadr x)))
(group-factors (factor n)))))

(defun fm (m n)
(labels ((tri-div (n)
(if (evenp n)
(* (nDiv (/ n 2)) (nDiv (1+ n)))
(* (nDiv n) (nDiv (/ (1+ n) 2))))))

(if (> (tri-div n) m)
(/  (* n (1+ n)) 2)
(fm m (+ 1 n)))))

;

(time (fm 500 1))

;; Evaluation took:
;; 0.007 seconds of real time

;; 76576500


— Me@2023-03-25 07:51:18 PM

.

.

# 3.4 Electric fields and potentials of point charges

A First Course in String Theory

.

(a) Show that for time-independent fields, the Maxwell equation $\displaystyle{T_{0ij}=0}$ implies that $\displaystyle{\partial_i E_j - \partial_j E_i = 0}$. Explain why this condition is satisfied by the ansatz $\displaystyle{\vec E = - \nabla \Phi}$.

~~~

Eq. (3.23):

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

\displaystyle{ \begin{aligned} &\vec E \\ &= - \nabla \Phi \\ &= - \left( \partial_x, \partial_y, \partial_z \right) \Phi \\ \end{aligned}}

\displaystyle{ \begin{aligned} &\partial_i E_j - \partial_j E_i \\ &= \partial_i \partial_j \Phi - \partial_j \partial_i \Phi \\ \end{aligned}}

— Me@2023-03-18 11:08:24 AM

.

.

# Debugging quantum concepts

Reality is a superposition of eigenstates. Even if we use the pilot-wave formalism, in which a particle has definite position or momentum, the pilot wave itself is in a superposition.

— Me@2012-04-16 2:27:20 PM

.

Physics reality is NOT a superposition of eigenstates. If physics reality was a superposition of eigenstates, there would have never been any interference patterns.

For an experimental setup, what is in a superposition is the quantum state, which is a tool for deducing probabilities of different potential measurement results.

“A quantum state is a superposition of eigenstates” just means nothing more than that we need to use individual probabilities of the eigenstates to calculate the probabilities.

A quantum state, which is represented by a wave function, is logical, mathematical, conceptual, and linguistic in nature. A quantum state is NOT physical. A quantum state is NOT reality. A quantum state is NOT directly corresponding to a physical reality (aka observable events, measurement results, etc.)

A quantum state is NOT even corresponding to a probability directly. (If a quantum state was a probability, there would have never been the phenomenon of interference.) Instead, a quantum state is corresponding to a probability amplitude, which is used for calculating probabilities.

— Me@2023-03-16 09:57:07 AM

.

.

# Computing Note, 5

21[.]07[.]2002

From Personal Computer[s] to Personal Robots

27[.]07[.]2002

optical fibers

In the beginning of the optical fiber research,
there were a lot of difficulties. But I thought if
[I succeeded], the research payoff would be huge,
because it could create a whole new world.
"Mingpao Monthly"

By the Father of Optical Fibers

19[.]08[.]2002

Make Robot as inexpensive and as useful as
Personal Computer -- Personal Robot


.

.

# Corsair Vengeance RGB Pro

.

.

— Me@2023-03-12 10:28:29 AM

.

.

# MangoHud

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more.

.

.

vram
ram
swap
gpu_temp
cpu_temp
gpu_power
cpu_power


.

.

— Me@2023-03-07 09:14:51 AM

.

.

# Ex 2.1-2 Particle in a Box

Quantum Methods with Mathematica

.

Reproduce Figure 2.1-1 …

~~~

phi[n_, x_] := Sin[n Pi x]

p[n_] := Plot[phi[n,x],{x,0,1}]

GraphicsColumn[{p[1], p[2], p[3]}]


— Me@2023-03-03 01:30:46 PM

.

.

# Intermediate states

What happens in the interval between the initial and final states of the interaction process?

What happens in between is everything and nothing. There is no privileged clearcut answer what happened that would be physically meaningful. It’s really the very basic point of quantum mechanics that only results of measurements are physically meaningful facts or observables; all other data are fictitious or uncertain. By the very definition of your problem, no measurement took place in the intermediate states which means that no sharp answers to any questions were generated, no answers or values became real or privileged or facts.

But unlike classical physics, quantum mechanics says that not only the probabilities of each history matter. All the relative phases matter, too.

— answered Jan 9, 2021 at 16:10

— Luboš Motl

— Physics StackExchange

.

.

2023.03.02 Thursday ACHK

# Copyleft 7

What stands in the way becomes the way.

— Marcus Aurelius

.

capitalize on

~ 用之以謀利

~ 利用

.

copyleft

~ 敵為己用

~ 幽默利用

~ 反利用

~ 草船借箭

.

— Me@2023-03-01 01:22:15 PM

.

.

# 人生 Presentation, 2.3

.

.

.

.

.

.

— Me@2023-02-28 11:16:42 AM

.

.

# Euler problem 10.2

Find the sum of all the primes below two million.

removeIf :: (a -> Bool) -> [a] -> [a]
removeIf p = filter (not . p)

sieveIter :: Integral a => [a] -> [a] -> [a]
sieveIter [] (x:xs) = x:xs
sieveIter (x:xs) acc
| x^2 > last (x:xs) = reverse acc++(x:xs)
| otherwise = sieveIter xss (x:acc)
where
xss = removeIf (\n -> n mod x == 0) xs

primeList :: Integral a => [a] -> [a]
primeList xs = sieveIter xs []

pL :: [Integer]
pL = primeList [2..2000000]

f :: Integer
f = sum (takeWhile (< 2000000) pL)


— colorized by palette fm

— Me@2023-02-25 12:35:57 PM

.

.

# Zsh, 2

To install the Z shell (Zsh):

1. Read my blog post “Zsh” to follow the instructions point 1 and point 2.

2. In the Bash terminal, run

zsh


once, in order to get the config file generated.

— Me@2023-01-19 12:41:56 PM

— Me@2023-02-24 05:19:38 PM

.

.

# Looper, 6

Causal diamonds in time travel, 3

.

Time travel in the absolute sense is logically impossible.

If time travel was logically possible, it still could be logically consistent from the time traveller’s point of view, as long as he cannot see from the perspective of the meta time.

— Me@2016-06-01 07:10:51 AM

— Me@2023-02-23 12:13:20 PM

.

.

# When physics meets biology

oli5679 on May 15, 2018

There was a really good chapter on his time in a biology lab in his book, “Surely you’re joking Mr. Feynman”. I have always remembered this quote:

When it came time for me to give my talk on the subject, I started off by drawing an outline of the cat and began to name the various muscles.

The other students in the class interrupt me: “We know all that!”

“Oh,” I say, “you do? Then no wonder I can catch up with you so fast after you’ve had four years of biology.” They had wasted all their time memorizing stuff like that, when it could be looked up in fifteen minutes.

sykh on May 15, 2018

Feynman was wrong on his view. The same thing could have been said of him and physicists. Oh, you spent your time memorizing formulas when it could be looked up in 15 minutes.

This is a nonsensical point of view for two reasons. [1] People in areas of their expertise tend to know a lot in that area off the top of their head because they have encountered this stuff so much that it has become memorized. That memorized knowledge comes from experience not a memorization exercise. [2] It’s also nonsensical because if you didn’t have a core set of knowledge memorized in your area of expertise and instead relied on spending 15 minutes looking up each fact necessary to understand a given situation you’d end up wasting your whole day just trying to understand the meaning of the problem.

— Hacker News

.

.

2023.02.22 Wednesday ACHK

# Euler problem 10.1

Find the sum of all the primes below two million.

(defmacro sq (x)
(* ,x ,x))

(defmacro last-item (lst)
(car (last ,lst)))

(defun good-reverse (lst)
(labels ((rev (lst acc)
(if (null lst)
acc
(rev
(cdr lst)
(cons (car lst) acc)))))
(rev lst nil)))

(defun prime-sieve-a-list (input-lst)
(labels ((sieve-iter (go-lst acc-list)
(if (not go-lst)
acc-list
(if (> (sq (car go-lst))
(last-item go-lst))

(append (good-reverse acc-list)
go-lst)

(sieve-iter
(remove-if #'(lambda (x)
(=
(mod x (car go-lst))
0))
(cdr go-lst))
(cons (car go-lst)
acc-list))))))

(sieve-iter input-lst '())))

(defun range (max &key (min 0) (step 1))
(loop :for n :from min :below max :by step
collect n))

(defmacro prime-sieve (n)
(prime-sieve-a-list (cons 2 (range (1+ ,n)
:min 3
:step 2))))

(defun sum (lst)
(reduce #'+ lst))

(sum (prime-sieve 2000000))

(time (sum (prime-sieve 2000000)))


— Me@2023-02-16 11:34:49 PM

.

.

# G40-70

If you are using SSD, you should turn off the swap file:

1. In command line, run

swapoff --all


2. Backup the file

/etc/fstab


3. Then, in that file, comment out any lines that contain the word “swap”.

— Me@2023-02-14 05:00:26 PM

.

.

# Causal diamonds in time travel, 2

Time travel in the absolute sense is logically impossible.

If time travel was logically possible, no observer would see any paradox if there is no meta-observer, who can compare results seen by different observers.

— Me@2016-06-12 12:12:40 PM

— Me@2023-02-13 12:53:31 AM

.

.

# Computing Note, 4

08[.]07[.]2002

1. Use Computer Software to improve/[]upgrade

10[.]07[.]2002

2. Software Philosophy:

Use it, enjoy it, but keep your ability
to live without it.

<<Conversation with God>>

Enjoy everything, but need nothing!

(Even people?
Especially people!)


.

.

# 大恩養仇人 3

.

「幫助別人」就有如「責備別人」，雖然有時必須，但是越小越好，越少越好。

「幫助別人」就有如「服用藥物」，雖然有時必須，但是越小越好，越少越好。

.

.

「醫藥治療」雖然有時必須，但是越小越好，越少越好。

.

.

.

「福利主義」的意思，就是把偶然的「福份」，視為必然的「權利」。那是錯的！

.

— Me@2022-11-05 12:54:58 PM

— Me@2023-02-09 12:24:10 PM

.

.