History 5

bambax on June 17, 2018

Not just music history, but history in general.

History told forwards is superstition: trying to show that what came after was inevitable, when in fact it was one future among an infinite number of different possible futures.

History told backwards makes sense: look for the seeds of post events, in the past.

However the human mind loves nothing more than causation; we see cause and effect everywhere even where it’s not, we like “stories”, we don’t understand, don’t believe in, and outright reject chance.

— We Should Teach Music History Backwards

— Hacker News

.

.

2023.04.01 Saturday ACHK

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
                                         (cadar acc)))
                                (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

.

.

2023.03.27 Monday (c) All rights reserved by ACHK

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

.

.

2023.03.17 Friday (c) All rights reserved by ACHK

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

.

.

2023.03.15 Wednesday (c) All rights reserved by ACHK

Corsair Vengeance RGB Pro

你有「婚前性」的話,一定不會從一而終。

如果你宣稱,你的「婚前性」對象,由始至現在至未來,只有一位,亦只會有一位的話,那樣,你在一開始時,為何不先與其結婚?

.

第二,數字不是零或一的話,就不知是多少。

.

第三,可以前的話,就可以外。

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

.

.

2023.03.13 Monday (c) All rights reserved by ACHK

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

.

.

2023.03.07 Tuesday (c) All rights reserved by ACHK

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

.

.

2023.03.05 Sunday (c) All rights reserved by ACHK

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

人生 Presentation, 2.3

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

.

那是 Paul Buchheit 講過的,我現在轉述成:

在第一個版本中,最重要賣點以外的優點,都只是雜音。

這個原理翻譯成教學版本的話,就是:

在教授課題時,應只聚焦核心思想,用不同的字眼言辭去覆術它,而斬釘截鐵地,省略其他一切細節,暫時。

主題以外的有趣內容,一律視為敵人,暫時。

.

這和之前那一點「每課只講一點」的分別是:

你不單止要「只講一點」,還要有「主動放棄其他」的心態。

.

為什麼兩人開始情投意合時,不立刻結婚呢?

因為相愛容易,相處很難。

相愛時,你可以選擇只接受,對方優點中,最好的一點。

相處時,你不可以選擇不接受,對方缺點中,最差的一點。

所以,即使開始情投意合,兩人也應先作朋友,不作情侶。

.

可以作朋友的,不一定適合,作情侶。

同理,可以作情侶的,不一定適合作夫妻。

所以,當發覺必定,終不成夫妻時,應立刻終止情侶關係。

.

這和之前那一點「一生只愛一人」的分別是:

你不單止要「只愛一人」,還要有「主動放棄其他」的心態。

.

未來妻子以外的女子,(!)現在(!)就要疏遠,無論她有多好,你有多喜歡。

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

.

.

2023.02.28 Tuesday (c) All rights reserved by ACHK

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

.

.

2023.02.26 Sunday (c) All rights reserved by ACHK

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.


3. Return to my blog post “Zsh” to follow the remaining steps.


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

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

.

.

2023.02.24 Friday (c) All rights reserved by ACHK

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

.

.

2023.02.23 Thursday (c) All rights reserved by ACHK

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

.

.

2023.02.21 Tuesday (c) All rights reserved by ACHK

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

.

.

2023.02.15 Wednesday (c) All rights reserved by ACHK