FF7R

Crucial MX500 1TB 3D NAND SATA SSD

.

Final Fantasy 7 Remake Steam version testing result:

1. With GTX 1050 Ti as the GPU, the bottleneck is the GPU, not the CPU, even though my CPU itself was weak.

2. However, once the GPU got upgraded, the CPU became the bottleneck.

The following settings can make the game smoother:

3. Set the Texture to Low. However, I do not recommend that.

4. Set the Shadow to Low.

5. Set the number of background people to be zero.

6. Set the resolution to 720p.

.

The following are the less obvious steps to release some CPU pressure:

7. Turn Steam into offline mode.

8. Turn off as many as other programs as possible.

9. In the controller setting, change the controller from the default “XInput” to “XBox 360“. However, I do not recommend that because that would disable the game’s rumble function.

.

After these settings, the game should be able to load Cloud’s headache memory cinematic scenes.

— Me@2023-01-11 12:39:59 AM

.

10. If not, start to repeat pressing the pause button every one second when a scene starts to load.

— Me@2023.01.23 05:17:38 PM

.

.

2023.01.24 Tuesday (c) All rights reserved by ACHK

htmlize

is an Emacs app for exporting syntax-highlighted buffers to html files. This post is about how to install it.

1. In the Bash terminal, get htmlize by the following command:

sudo apt-get install elpa-htmlize

2.0 Change the value of the variable htmlize-output-type to inline-css by the following steps:

2.1 In Emacs, run the function describe-variable by the hotkey:

Ctrl-h v

2.2 When you are asked to describe variable, type

htmlize-output-type

2.3 Click “customize“.

2.4 Click “Value Menu“.

2.5 Select “inline-css“.

2.6 Click “Apply and Save“.

.

3.1 Then whenever you want to turn the Emacs buffer into html, run the command

M-x htmlize-buffer

The buffer will show the generated html code.

3.2 Save the buffer as an html file. The html code itself will get syntax-highlighted.

.

4.1 In the output html file, delete everything before

<body style="color: #333333; background-color: #FFFFFF;">

4.2 Then replace these 2 lines

<body style="color: #333333; background-color: #FFFFFF;">
    <pre>

with

<pre style="color: #333333;background-color: #FFFFFF">

4.3 Delete everything after

</pre>

— Me@2023-01-15 03:39:29 PM

.

.

2023.01.22 Sunday (c) All rights reserved by ACHK

KDE Chinese

This post is about how to enable Traditional Chinese keyboard in KDE Plasma desktop in Ubuntu 22.10.

1. In the Bash terminal, get the Cangjie input method (倉頡輸入法) by the following command:

sudo apt-get install ibus-cangjie

2. Then, get also the the following packages

sudo apt-get install \
ibus-data \
ibus-gtk \
ibus-gtk3 \
ibus-gtk4 \
ibus-table-cangjie3 \
ibus-table-cangjie5 \
ibus-table-cantonese \
ibus-table-quick-classic \
python3-ibus-1.0

3. Log out KDE and then log in again.

4. In KDE, open the application IBus Preferences. Add the language Chinese.

5. Select Cangjie3.

6. Change the language switch hotkey from Super-Space to Ctrl-Space.

7. Then in any text editor, press Ctrl-Space to switch input language.

— Me@2023-01-01 11:52:09 AM

.

.

2023.01.07 Saturday (c) All rights reserved by ACHK

Zsh

To install Z shell (Zsh):

1. In the Bash terminal, get zsh by the following command:

sudo apt-get install zsh

2. Then, apt-get also the following 3 packages:

sudo apt-get install zsh-syntax-highlighting

sudo apt-get install zsh-autosuggestions

sudo apt-get install zsh-theme-powerlevel9k

.

3. Read my blog post “Haskell mode“.

Follow the instructions point 0 and point 1 to install the Nix package manager.

.

4. Then, use the Nix package manager to install the Powerlevel10k theme.

nix-env -iA nixpkgs.zsh-powerlevel10k

5. Also, install the Meslo Nerd Font.

nix-env -iA nixpkgs.meslo-lgs-nf

The font would be located at

~/.nix-profile/share/fonts/truetype/

6. Use, for example, the KDE Plasma Font Management program to install the font.

.

7. Open the text file

~/.zshrc

Add the following 3 lines onto it:

source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh

source ~/.nix-profile/share/zsh-powerlevel10k/powerlevel10k.zsh-theme

8. Run the command

chsh --shell /usr/bin/zsh

9. Reboot the computer.

.

— Me@2022-12-21 01:29:17 PM

— Me@2023-01-05 10:43:10 PM

.

.

2023.01.06 Friday (c) All rights reserved by ACHK

cmu-infix

is

a library for writing infix mathematical notation in Common Lisp.

To install it:

1. In the Bash terminal, get Quicklisp by the following command:

sudo apt-get install cl-quicklisp

The file quicklisp.lisp will be created at

/usr/share/common-lisp/source/quicklisp/quicklisp.lisp

.

2. Run the command

sbcl --load /usr/share/common-lisp/source/quicklisp/quicklisp.lisp

3. Follow the install instructions:

(quicklisp-quickstart:install)

(ql:add-to-init-file)

.

4. To enable the library, in the Common Lisp REPL, run the code:

(ql:quickload :cmu-infix)

5. And then run:

(named-readtables:in-readtable cmu-infix:syntax)

.

6. To test the library, run:

(defmacro add (x y)
  `(let ((a ,x)
         (b ,y))
     #I(a+b)))

(add 2 3)

(macroexpand-1 '(add 2 3))

(macroexpand-1 '#I(1+2-3*5^^6))

(eval (macroexpand-1 '#I(1+2-3*5^^6)))

— Me@2022-12-25 10:13:04 AM

.

.

2022.12.25 Sunday (c) All rights reserved by ACHK

Euler problem 11.4


recursive function max_e11(a2d, i, j, acc) result(a)

  integer, dimension(20, 20) :: a2d
  integer :: i, j, acc, a, accm = 0
  integer :: dia_l = 0, dia_r = 0, hori = 0, vert = 0
  integer :: k = 0, x = 1, y = 1
  integer :: lenx = 20, leny = 20

  if (i <= (lenx - 3)) then 
     hori = 1
     do k = 0, 3 
        hori = hori*a2d(i+k, j)
     end do
  end if

  if (j <= (leny - 3)) then
     vert = 1
     do k = 0, 3 
        vert = vert*a2d(i, j+k)
     end do
  end if

  if ((i <= (lenx - 3)) .and. (j <= (leny - 3))) then
     dia_r = 1
     do k = 0, 3 
        dia_r = dia_r*a2d(i+k, j+k)
     end do
  end if

  if ((i >= 4) .and. (j <= (leny - 3))) then
     dia_l = 1
     do k = 0, 3
        dia_l = dia_l*a2d(i-k, j+k)
     end do
  end if

  if ((i == lenx) .and. (j == leny)) then 
     a = acc
  else 
     accm = max(acc, hori, vert, dia_l, dia_r)

     if (i == lenx) then
        x = 1
        y = j + 1
     else 
        x = i + 1
        y = j
     end if

     a = max_e11(a2d, x, y, accm)
  end if
end function max_e11

program main

  implicit none

  integer :: p_max, p_count, i, j
  integer(kind = 16) :: p_sum
  logical, ALLOCATABLE, DIMENSION(:) :: is_prime
  character(len=128) :: currentDir
  integer, dimension(20, 20) :: D, M
  integer :: max_e11

  call GET_ENVIRONMENT_VARIABLE('PWD', currentDir)

  print *, "dir == ", trim(currentDir)

  open(1, file = "t.txt", status = "old")
  read(1, *) D
  close(1)

  M = transpose(D)

  write(*, *) M(1, 1)
  write(*, *) max_e11(M, 1, 1, 0) 
  write(*, *) M(1, 1)

end program main

— Me@2022-12-24 11:50:15 AM

.

.

2022.12.24 Saturday (c) All rights reserved by ACHK

Ex 2.1-1 Particle in a Box

Remove["Global`*"]

hbar := \[HBar]

H[V_] @ psi_  := -hbar^2/(2m) D[psi,{x,2}] + V psi

SchD[V_] @  psi_ := H[V] @ psi - En psi

SchD[V[x]] @ psi[x] == 0 // TeXForm

\displaystyle{-\text{En} \psi (x)-\frac{\hbar ^2 \psi ''(x)}{2 m}+\psi (x) V(x)=0}

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

SchD[0] @ phi[n,x] == 0 // ExpandAll

SchD[0] @ phi[n,x] / phi[n,x] == 0 // Simplify // TeXForm

\displaystyle{2 \text{En} L=\frac{\pi ^2 n^2 \hbar ^2}{L m}}

Starting with a linear superposition A E^(Ikx) + B E^(-Ikx) of independent plane waves, where A and B are constants, verify the box eigen-functions and eigen-energies given above.

Thus, show that this superposition is a solution of the Schrodinger equation and, by invoking the boundary condition, that k -> n Pi/L.

— Quantum Methods with Mathematica

phi[k_, x_] := A E^(I k x) + B E^(- I k x)

eq1 := SchD[0] @ phi[k,x]/phi[k,x] == 0 // Simplify

Ek[k_] := En /. Solve[eq1, En] [[1]]

Ek[k] // TeXForm

\displaystyle{\frac{k^2 \hbar ^2}{2 m}}

.

The boundary conditions are \displaystyle{\phi_{x=0} = \phi_{x=L} = 0}.

\displaystyle{  \begin{aligned}  A+B&=0 \\   A e^{i k L}+B e^{-i k L}&=0 \\  \end{aligned}}

So

\displaystyle{  \begin{aligned}  e^{i k L} - e^{-i k L}&=0 \\  \end{aligned}}

Solve[E^(I k L) - E^(-I k L) == 0, k] // Simplify

\displaystyle{  \left\{k\to -\frac{2 \pi  c_1}{L}\text{ if }c_1\in \mathbb{Z}, ~~~k\to -\frac{2 \pi  c_1+\pi }{L}\text{ if }c_1\in \mathbb{Z} \right\}}

\displaystyle{  =\left\{k\to \frac{n \pi }{L}\text{ if }n \in \mathbb{Z}\right\}}

.

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

norm[n_] = Cn /.
    Solve[
        Integrate[ phi[n,x]^2, {x,0,L}] == 1 /.
            Sin[m_Integer n Pi] -> 0, 
        Cn
    ] [[1]] // TeXForm

\displaystyle{  -\frac{\sqrt{2}}{\sqrt{L}}  }

It’s interesting to note in passing that the 1D box eigenfunctions are also classically the eigenfunctions of a taut string. However, whereas the quantum mechanical energies scale as n^2, the classical eigenfrequencies of the string’s normal modes are linear in n. This is a consequence of the classical wave equation being second order in time in contrast to the quantum wave equation being first order.

— Quantum Methods with Mathematica

— Me@2022-12-16 10:23:45 AM

.

.

2022.12.17 Saturday (c) All rights reserved by ACHK

Euler problem 11.5

A project created by using Lazarus on one platform can be compiled on any other one which Free Pascal compiler supports. For desktop applications a single source can target macOS, Linux, and Windows, with little or no modification. An example is the Lazarus IDE itself, created from a single code base and available on all major platforms including the Raspberry Pi.

— Wikipedia on Lazarus (software)

.

.

What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid?

program e11;          

uses
   SysUtils, math;

type
   T2d_int_array = array of array of integer;

const
   filename = 't.txt';

var
   current_dir: string;
   ptext: TextFile;
   
   line_string: string;
   s: string = '';
   lines: array of string;
   array_string_2d: array of array of string;
   array_int_2d: T2d_int_array;
   
   isbegin: boolean = true;
   i: integer;
   j: integer;
   lenx: integer = 0;
   leny: integer = 0;
   c: integer = 0;


function max4_iter(a2d: T2d_int_array;
                  i, j: integer;
                   acc: longint): integer;
var
   dia_l: longint = 0;
   dia_r: longint = 0;
   hori: longint = 0;
   vert: longint = 0;
   k: integer = 0;
   accm: longint = 0;
   x: integer = 0;
   y: integer = 0;

begin
   if i <= (lenx - 4) then begin
      hori := 1;
      for k := 0 to 3 do begin
         hori := hori*a2d[i+k, j];
      end;
   end;

   if j <= (leny - 4) then begin
      vert := 1;
      for k := 0 to 3 do begin
         vert := vert*a2d[i, j+k];
      end;
   end;

   if (i <= (lenx - 4)) and (j <= (leny - 4)) then
   begin
      dia_r := 1;
      for k := 0 to 3 do begin
         dia_r := dia_r*a2d[i+k, j+k];
      end;
   end;

   if (i >= 3) and (j <= (leny - 4)) then begin
      dia_l := 1;
      for k := 0 to 3 do begin
         dia_l := dia_l*a2d[i-k, j+k];
      end;
   end;

   if (i = (lenx - 1)) and (j = (leny - 1)) then
   begin
      max4_iter := acc;
   end else begin
      accm := max(acc,
                  max(hori,
                      max(vert,
                          max(dia_l, dia_r))));
      
      if i = lenx - 1 then begin
         x := 0;
         y := j + 1;
      end else begin
         x := i + 1;
         y := j;
      end;
      max4_iter := max4_iter(a2d, x, y, accm);
   end;
end;

begin

   current_dir := GetCurrentDir;

   writeln(filename, ':');
   writeln('==================================');

   if not FileExists(filename) then begin
      writeln(filename, ' does not exist.');
      exit;
   end;

   assign(ptext, filename);
   reset(ptext);

   setLength(lines, 0);
   s := '';
   isbegin := true;
   while not eof(ptext) do begin
      readln(ptext, line_string);
      if isbegin then begin
         s := s + line_string;
         isbegin := false;
      end else begin
         s := s + LineEnding + line_string;
      end;
   end;
   close(ptext);

   lines := s.split(LineEnding);
   lenx := length(lines);
   setLength(array_string_2d, lenx);

   for i := 0 to (lenx - 1) do begin
      array_string_2d[i] := lines[i].split(' ');
   end;
   leny := length(array_string_2d[0]);

   setLength(array_int_2d, lenx);
   for i := 0 to (lenx - 1) do begin
      setLength(array_int_2d[i], leny);
   end;

   for i := 0 to (lenx - 1) do begin
      for j := 0 to (leny - 1) do begin
         val(array_string_2d[i][j],
             array_int_2d[i][j],
             c);
      end;
   end;

   writeln(max4_iter(array_int_2d, 0, 0, 0));
   writeln('==================================');
end.

— Me@2022-12-14 03:56:23 PM

.

.

2022.12.14 Wednesday (c) All rights reserved by ACHK

Direct from Dell

Euler problem 9.2

.

There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.

g p =
  [ [a, b, c]
    | m <- [2 .. limit],
      n <- [1 .. (m - 1)],
      let a = m ^ 2 - n ^ 2,
      let b = 2 * m * n,
      let c = m ^ 2 + n ^ 2,
      a + b + c == p
  ]
  where
    limit = floor . sqrt . fromIntegral $ p

— based on Haskell official

.

Euclid’s formula is a fundamental formula for generating Pythagorean triples given an arbitrary pair of integers m and n with m > n > 0. The formula states that the integers

\displaystyle{ a=m^{2}-n^{2},\ \,b=2mn,\ \,c=m^{2}+n^{2}}

form a Pythagorean triple. The triple generated by Euclid’s formula is primitive if and only if m and n are coprime and one of them is even. When both m and n are odd, then a, b, and c will be even, and the triple will not be primitive; however, dividing a, b, and c by 2 will yield a primitive triple when m and n are coprime.

Every primitive triple arises (after the exchange of a and b, if a is even) from a unique pair of coprime numbers m, n, one of which is even.

— Wikipedia on Pythagorean triple

— Me@2022-12-10 09:57:27 PM

.

.

2022.12.11 Sunday (c) All rights reserved by ACHK

Why does the universe exist? 7.0

ParEdit, 2

.

What is there before the beginning of the universe?

What does the universe change from?

— Me@2016-07-20 06:16:34 AM

.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(autoload 'enable-paredit-mode
  "paredit" "Turn on pseudo-structural editing." t)

;;;;;;;;;;;

(defun add-hooks (hooks fn)
  (mapc (lambda (hook)
      (add-hook hook fn))
    hooks))

(add-hooks (list
        'emacs-lisp-mode-hook
        'eval-expression-minibuffer-setup-hook
        'ielm-mode-hook
        'lisp-mode-hook
        'lisp-interaction-mode-hook
        'scheme-mode-hook)

       #'enable-paredit-mode)

;;;;;;;;;;;

(add-hook 'slime-repl-mode-hook
      (lambda () (paredit-mode +1)))

(defun override-slime-repl-bindings-with-paredit ()
   (define-key slime-repl-mode-map
     (read-kbd-macro paredit-backward-delete-key) nil))

(add-hook 'slime-repl-mode-hook
      'override-slime-repl-bindings-with-paredit)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

— Me@2022-12-09 01:24:55 PM

.

.

2022.12.09 Friday (c) All rights reserved by ACHK

Computing Note, 3


Summer 2002

1. Perhaps the Encyclopedia Britannica 
                    Research Assistant 
                        is written by[in] Java.

2. Work Hard Play Hard 
           Live your life with[in] all [its] fullness.

3. H(Learning): HyperLearning 真切學習:
[]
Be a professional professional: 比專業還專業

.

To edit Lazarus code in Emacs:

1. Open Emacs’ initialization file, whose location should be

~/.emacs

2. Add the follwing code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defmacro compile-with (command-string)

  `(progn

    (save-buffer)

    (unless visual-line-mode
      (visual-line-mode 1))

    (universal-argument)

    (compile ,command-string)))

(defmacro defcomp (fn command-string kbd-string)

  `(progn

     (defun ,fn ()

       (interactive)

       (compile-with ,command-string))

     (global-set-key (kbd ,kbd-string) ',fn)))

;;;;;;;;;;;;;;;;;;;;;

(defcomp g-la-com

    (concat
     "lazbuild "
     (replace-regexp-in-string
      "pas" "lpi" buffer-file-name))

    "C-x C-p")

;;;;;;;;;;;;;;;;;;;;;

(defcomp g-la-run

    (replace-regexp-in-string
     ".pas" "" buffer-file-name)

    "C-x C-[")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

3. Close Emacs.

4. Use the Lazarus IDE to create a console project named p11.

5. Close Lazarus.

6. Use Emacs to open the file p11.pas.

— Me@2022-12-07 08:35:48 PM

.

.

2022.12.08 Thursday (c) All rights reserved by ACHK

Pier, 2.2

Euler problem 9.1

.

There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.

(defun e9c ()
  (loop :for a :from 1 :to 1000 :do
    (loop :for b :from 1 :to a :do
      (let ((c (- 1000 (+ a b))))
        (if (= (+ (* a a) (* b b)) (* c c))
            (return-from e9c
                (list a b c (* a b c))))))))

— colorized by palette fm

— Me@2022-12-05 05:59:49 PM

.

.

2022.12.05 Monday (c) All rights reserved by ACHK

Fortran Package Manager

Haskell mode, 3

.

The goal of this blog post is to set up an integrated programming environment for Fortran.

.

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

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

3. Install the package manager Anaconda.

4. Use Anaconda to install the Fortran Package Manager (fpm), by following the fpm installation guide.

4.1. Add the additional channel mentioned in the fpm installation guide.

4.2. Install the fpm itself:

conda create -n fpm_env fpm

conda activate fpm_env

5. Install the Fortran language server:

conda install fortls

6. Install the Emacs plugin:

sudo apt-get install elpa-pyvenv

7. Open Emacs’ initialization file, whose location should be

~/.emacs

8. Add the following code to the file.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun gfortran-run ()

  (interactive)

  (save-buffer)

  (unless visual-line-mode
    (visual-line-mode 1))

  (universal-argument)

  (compile "fpm run"))

(global-set-key (kbd "C-x C-r") 'gfortran-run)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setenv "WORKON_HOME" "~/anaconda3/envs")

(pyvenv-mode 1)

(pyvenv-workon "fpm_env")

;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-hook 'f90-mode-hook #'lsp)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

— Me@2022-12-01 09:18:59 AM

.

.

2022.12.04 Sunday (c) All rights reserved by ACHK

Why does the universe exist? 7.3

Euler problem 10.4

.

program main

  implicit none

  integer :: p_max, p_count, i, j
  integer(kind = 16) :: p_sum
  logical, ALLOCATABLE, DIMENSION(:) :: is_prime

  p_max = 2000000

  ALLOCATE(is_prime(p_max))

  is_prime = .true.

  is_prime(1) = .false.

  do i = 2, ceiling(sqrt(real(p_max)))
     if (is_prime(i)) then
        do j = i*i, p_max, i
           is_prime(j) = .false.
        end do
     end if
  end do

  p_count = 0
  p_sum = 0
  do i = 1, p_max
     if (is_prime(i)) then
        p_count = p_count + 1
        p_sum = p_sum + i
     end if
  end do

  print *, "p_count == ", p_count
  print *, "p_sum == ", p_sum

  DEALLOCATE(is_prime)

end program main

For a universe part, which is partial in space or in time, you can ask for its cause.

But for the universe as a whole, you cannot.

If the big bang is the first cause, you cannot ask for the cause of its existence.

Asking for the cause of the existence of the universe is the same as asking for the cause of the first cause.

— Me@2012-10-15 08:33:01 AM

— Me@2022-11-27 09:09:53 PM

.

.

2022.12.04 Sunday (c) All rights reserved by ACHK

ParEdit

.

(autoload 'enable-paredit-mode
  "paredit" "Turn on pseudo-structural editing." t)

(add-hook 'emacs-lisp-mode-hook
      #'enable-paredit-mode)

(add-hook 'eval-expression-minibuffer-setup-hook   
      #'enable-paredit-mode)

(add-hook 'ielm-mode-hook
      #'enable-paredit-mode)

(add-hook 'lisp-mode-hook
      #'enable-paredit-mode)

(add-hook 'lisp-interaction-mode-hook
      #'enable-paredit-mode)

(add-hook 'scheme-mode-hook
      #'enable-paredit-mode)


(add-hook 'slime-repl-mode-hook
      (lambda () (paredit-mode +1)))

(defun override-slime-repl-bindings-with-paredit ()
   (define-key slime-repl-mode-map
     (read-kbd-macro paredit-backward-delete-key) nil))

(add-hook 'slime-repl-mode-hook
      'override-slime-repl-bindings-with-paredit)

.

— Me@2022-11-29 10:03:49 PM

.

.

2022.11.29 Tuesday (c) All rights reserved by ACHK

Ex 1.2-1 Stationary States

Quantum Methods with Mathematica

.

Assume a wavefunction of the form psi[x, t] == f[t] psi[x] and perform a separation of variables on the wave equation.

Show that f[t] = E^(-I w t) where h w is the separation constant. Try the built-in function DSolve.

Equate h w to the Energy by evaluating the [expected] value of hamiltonian[V] in the state psi[x, t].

~~~

Remove["Global`*"]


hbar := \[HBar]

H[V_] @ psi_  := -hbar^2/(2m) D[psi,{x,2}] + V psi



psi[x_,t_] := f[t] psi[x]

I hbar D [psi[x,t],t] == H[V] @ psi[x, t]

I hbar D [psi[x,t],t] / psi[x,t] == H[V] @ psi[x,t] / psi[x,t]

\displaystyle{i \hbar  \psi (x) f'(t)=V f(t) \psi (x)-\frac{\hbar ^2 f(t) \psi ''(x)}{2 m}}

\displaystyle{\frac{i \hbar  f'(t)}{f(t)}=\frac{V f(t) \psi (x)-\frac{\hbar ^2 f(t) \psi ''(x)}{2 m}}{f(t) \psi (x)}}

E1 := I hbar D [psi[x,t],t] / psi[x,t] == H[V] @ psi[x,t] / psi[x,t]

Simplify[E1]

\displaystyle{\frac{1}{2} \hbar  \left(\frac{\hbar  \psi ''(x)}{m \psi (x)}+\frac{2 i f'(t)}{f(t)}\right)=V}

E2 := - 1/2 hbar hbar (D[D[psi[x],x],x]/(m psi[x])) == hbar omega

DSolve[E2, psi[x], x]


E3 := 1/2 hbar 2 i D[f[t],t] / f[t] == hbar omega

DSolve[E3, f[t], t]

\displaystyle{\left\{\left\{\psi (x)\to c_1 \cos \left(\frac{\sqrt{2} \sqrt{m} \sqrt{\omega } x}{\sqrt{\hbar }}\right)+c_2 \sin \left(\frac{\sqrt{2} \sqrt{m} \sqrt{\omega } x}{\sqrt{\hbar }}\right)\right\}\right\}}

\displaystyle{\left\{\left\{f(t)\to c_1 e^{\frac{\omega  t}{i}}\right\}\right\}}


k

psi[x_] := c E^(I k x)

psi[x]

f[t_] := E^(-I omega t)

f[t]

psi[x_,t_] := f[t] psi[x]

psi[x,t]

\displaystyle{  \left\{k,c e^{i k x},e^{-i \omega  t},c e^{i k x-i \omega  t}\right\}  }

E4 := Conjugate[psi[x,t]] H[0] @ psi[x,t]

E4

E5 := Simplify[E4]

E5

k := Sqrt[2 m omega / hbar]

Refine[E5, {Element[{c, omega, m, t, hbar, k, x}, Reals]}]

\displaystyle{  \frac{c k^2 \hbar ^2 c^* \exp \left(-i \left(-(\omega  t-k x)^*-k x+\omega  t\right)\right)}{2 m}  }

\displaystyle{  = c^2 \omega  \hbar  }

E6 := Conjugate[psi[x,t]] psi[x,t]

Simplify[E6]

\displaystyle{  c c^* \exp \left(-i \left(-(\omega  t-k x)^*-k x+\omega  t\right)\right)  }

\displaystyle{  = c^2  }

.

\displaystyle{\begin{aligned}            \langle E \rangle     &= \frac{\int_{-\infty}^{\infty} \psi^* H_{V=0} \psi dx}{\int_{-\infty}^{\infty} \psi^* \psi dx} \\ \\     &= \frac{c^2 \omega  \hbar \int_{-\infty}^{\infty} dx}{c^2 \int_{-\infty}^{\infty} dx} \\ \\    &= \omega  \hbar \\    \end{aligned}}

.

— Me@2022-11-26 07:17:29 PM

.

.

2022.11.28 Monday (c) All rights reserved by ACHK

Euler problem 8.3

Directory[]

mString := Import["n.txt"]

nString := StringDelete[mString, "\n" | "\r"]

nList := Map[FromDigits, Characters[nString]]

take13[lst_] := Times @@ Take[lst,13]

Fmax13n[lst_, n_] := If[Length[lst] < 13,
                        n,
                        With[{t13 = take13[lst]},
                            If[n > t13,
                                Fmax13n[Rest[lst], n],
                                Fmax13n[Rest[lst], t13]]]]

Fmax13n[nList, 0]

Wmax13n[lst_, n_] := Which[
                        Length[lst] < 13, n,
                        t13 = take13[lst];
                            n > t13, Wmax13n[Rest[lst], n],
                            True, Wmax13n[Rest[lst], t13]]

Wmax13n[nList, 0]

Fmax13n[nList, 0] - Wmax13n[nList, 0]

— colorized by palette fm

— Me@2022-11-24 05:51:56 PM

.

.

2022.11.24 Thursday (c) All rights reserved by ACHK

Problem 14.5d1.2.2

A First Course in String Theory

.

The generating function is an infinite product:

\displaystyle{ \begin{aligned} \alpha' M_L^2: \end{aligned}}

\displaystyle{\begin{aligned} &f_{L, NS+}(x) \\ &= a_{NS+} (r) x^r \\ &= \frac{1}{x} \prod_{r=1}^\infty \frac{(1 + x^{r-\frac{1}{2}})^{32}}{(1 - x^r)^8} \\ \end{aligned}}

.

To evaluate the infinite product, you can use Mathematica (or its official free version Wolfram Engine) with the following commands:

TeXForm[
    HoldForm[
        (1/x)*Product[
                 (1+x^(r-1/2))^32/(1-x^r)^8,
                 {r, 1, Infinity}]]]

f[x_] := (1/x)*Product[
                 (1+x^(r-1/2))^32/(1-x^r)^8,
                 {r, 1, Infinity}]

Print[f[x]]

TeXForm[f[x]]

TeXForm[Series[f[x], {x,0,3}]]
\displaystyle{\frac{1}{x}\prod _{r=1}^{\infty } \frac{\left(1+x^{r-\frac{1}{2}}\right)^{32}}{\left(1-x^r\right)^8}}


                     1        32
    QPochhammer[-(-------), x]
                  Sqrt[x]
------------------------------------
        1    32                    8
(1 + -------)   x QPochhammer[x, x]
     Sqrt[x]


\displaystyle{\frac{\left(-\frac{1}{\sqrt{x}};x\right)_{\infty }^{32}}{\left(\frac{1}{\sqrt{x}}+1\right)^{32} x (x;x)_{\infty }^8}}


\displaystyle{\frac{1}{x}+\frac{32}{\sqrt{x}}+504+5248 \sqrt{x}+40996 x+258624 x^{3/2}+1384320 x^2+O\left(x^{5/2}\right)}

\displaystyle{ \begin{aligned}  &f_{L, NS+}(x) \\  \end{aligned}}

\displaystyle{  \approx \frac{1}{x}+\frac{32}{\sqrt{x}}+504+5248 \, \sqrt{x}+40996 \, x+258624 \, x^{\frac{3}{2}}+1384320 \, x^{2}+6512384 \, x^{\frac{5}{2}} + ...}

— Me@2022-11-23 04:40:28 PM

.

.

2022.11.23 Wednesday (c) All rights reserved by ACHK

Importance, 2.2

Euler problem 8.2

.

.

import Data.Char

max13 lst = max13n lst 0
  where
    max13n lst n | (length lst) < 13 = n
                 | n > take13        = max13n (tail lst) n
                 | otherwise         = max13n (tail lst) take13
      where
        take13 = product (take 13 lst)

str <- readFile "n.txt"

max13 (map (fromIntegral . digitToInt) . concat . lines $ str)

.

— Me@2022-11-19 12:04:41 PM

.

.

2022.11.19 Saturday (c) All rights reserved by ACHK

Pier, 1.2

Euler problem 8.1

.

.

73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450

Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product?

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

(file-get-lines #P"n.txt")

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

(let ((the-digits (char-to-integer-list
           (string-to-list
            (remove #\newline
                    (file-get-contents #P"n.txt"))))))

  (loop :for i :from 0 :to (- (length the-digits) 13)
        :maximize (apply #'*
                    (subseq
                      the-digits i (+ i 13)))))

.

— colorized by palette fm

— Me@2022-11-12 04:50:19 PM

.

.

2022.11.12 Saturday (c) All rights reserved by ACHK