From 942a606d0a668c264c31e4e5589254ea64060db3 Mon Sep 17 00:00:00 2001 From: Panadestein Date: Fri, 13 Sep 2024 16:51:43 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20Panadest?= =?UTF-8?q?ein/blog@a4aa09667e362cd4936be88a3b808a5b22a7d6f8=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hf.html | 41 +++++++++++++++++++++-------------------- qbqn.html | 40 ++++++++++++++++++++-------------------- rollim.html | 26 +++++++++++++------------- si.html | 12 ++++++------ spodat.html | 30 +++++++++++++++--------------- 5 files changed, 75 insertions(+), 74 deletions(-) diff --git a/hf.html b/hf.html index 905bd3c..fedc64b 100644 --- a/hf.html +++ b/hf.html @@ -234,9 +234,9 @@

Helonium's Hartree-Fock program

-
-

Exordium

-
+
+

Exordium

+

We will implement the Hartree-Fock1 program from the classic Szabo-Ostlund text, a staple in quantum chemistry. If you have any experience in the field, chances are you know it well. @@ -270,9 +270,9 @@

Exordium

-
-

STO-3G

-
+
+

STO-3G

+

Basis sets are used to transform the PDEs into linear algebra problems. Physical intuition suggests that Slater type orbitals4 should be a good choice for our Hamiltonian. However, the computation of the integrals @@ -289,9 +289,9 @@

STO-3G

-
-

Electronic integrals

-
+
+

Electronic integrals

+

Constructing the integrals' tensor is complicated6 and is the main reason for the poor scaling of electronic structure methods. The \(1s\) orbitals are the simplest case, and here two types of integrals @@ -329,9 +329,9 @@

Electronic integrals

-
-

Fock operator's matrix

-
+
+

Fock operator's matrix

+

The following function constructs the Fock matrix. Extending this code to an arbitrary number of atoms would imply mapping over a list of coordinates, as opposed to fusing them @@ -342,18 +342,19 @@

Fock operator's matrix

F ← {𝕊e1‿e2‿z1‿z2‿r:
   bs‿nb ← (⊢⋈≠∘⊑)⍉>STO¨ e1‿e2
-  B ← {∾‿×({2: {(⋈˜/nb‿nb) ⊔ 𝕎⌜˜𝕩}¨; 4: {𝕎⌜⍟3˜𝕩}¨}𝕩)○⊢<∘∾˘bs}
+  D ← {∾‿×({2: {(⋈˜/nb‿nb) ⊔ 𝕎⌜˜𝕩}¨; 4: {𝕎⌜⍟3˜𝕩}¨}𝕩)○⊢<∘∾˘bs}
 
   sm‿hcore ← {a𝕊d:
-    r1‿r2 ← <˘⍉⁼> (r⊸-⊸⋈˜×⟜r÷+)⌜´ ⊏bs
     mst ← ⌽⊸≍∾⟜0טr
+    r1‿r2 ← <˘⍉⁼> (r⊸-⊸⋈˜×⟜r÷+)⌜´ ⊏bs
     mv ← ט∘{[0‿2,3‿1]⊏({0‿𝕨¨𝕩}⟜𝕩¨𝕨)∾⋈⟜⍉r⋈¨𝕩}´¨⟨0‿r, r1⟩‿⟨r‿0, r2⟩
     (⊑⋈·+´1⊸↓)+´∘⥊¨¨ d<⊸× ({a𝕏¨¨mst}¨S‿T) ∾ z1‿z2{a∾⟜𝕨⊸V¨¨𝕩}¨mv
-  }´ B 2
+  }´ D 2
 
   erim ← {a𝕊d:
-    {↕𝕩¨↕4}≠bs
-  }´ B 4
+    i ← a{↕𝕩¨↕=𝕨}≠bs
+    {𝕩⊏0‿r}¨ i
+  }´ D 4
 }
 F system
 
@@ -402,9 +403,9 @@

Fock operator's matrix

-
-

SCF

-
+
+

SCF

+

Compare the electronic energy with the one computed using the original F66 program.

diff --git a/qbqn.html b/qbqn.html index ecd2c67..19f58be 100644 --- a/qbqn.html +++ b/qbqn.html @@ -197,9 +197,9 @@

BQN's Quantum Noise

-
-

Preamble

-
+
+

Preamble

+

We will implement and test a compact quantum interpreter in the BQN1 programming language. Initially, we import the necessary system functions and define a 1-modifier for handling @@ -207,7 +207,7 @@

Preamble

-
Sin‿Cos‿GCD ← •math
+
Sin‿Cos‿GCD ← •math
 U ← •rand.Range
 _cp ← {(-´𝔽¨)⋈(+´𝔽¨)⟜⌽}
 
@@ -221,16 +221,16 @@ 

Preamble

-
-

Interpreter

-
+
+

Interpreter

+

The (400 chars2) quantum interpreter is based on references arXiv:1711.02086 and arXiv:1608.03355. For simplicity, we always measure at the end of the execution:

-
Q ← {𝕊qb‿sc‿r:
+
Q ← {𝕊qb‿sc‿r:
   wf ← (1⌾⊑⋈⊢)⥊⟜0 2⋆qb
   M‿K ← ⟨+˝∘×⎉1‿∞ _cp, {1𝕊𝕩:𝕩; 𝕨𝕊1:𝕨; 𝕨∾∘×⟜<_cp𝕩}⟩
   E ← {0𝕊𝕩:1; K⍟(𝕨-1)˜𝕩}
@@ -246,9 +246,9 @@ 

Interpreter

-
-

Shor's algorithm

-
+
+

Shor's algorithm

+

As a test case, we employ the quantum circuit of Shor's algorithm for the number fifteen and base eleven, following references @@ -259,7 +259,7 @@

Shor's algorithm

-
n‿a‿qb‿r ← ⟨15, 11, 5, 0 U˜ 2⋆3⟩
+
n‿a‿qb‿r ← ⟨15, 11, 5, 0 U˜ 2⋆3⟩
 
 sc ← ⟨
   ⟨0⟩‿g.h ⋄ ⟨1⟩‿g.h ⋄ ⟨2⟩‿g.h
@@ -277,7 +277,7 @@ 

Shor's algorithm

-
C >+˝{Q qb‿sc‿𝕩}¨ r
+
C >+˝{Q qb‿sc‿𝕩}¨ r
 
@@ -291,9 +291,9 @@

Shor's algorithm

-
-

Epilogue

-
+
+

Epilogue

+

Why the hieroglyphs, you may ask? The tacit and functional style, coupled with numerous combinators, makes programming feel like solving a fun algebraic puzzle rather than drafting a manifesto. @@ -312,7 +312,7 @@

Epilogue

-
+
 ⟨ 44 64 ⟩
 
@@ -325,7 +325,7 @@

Epilogue

-
+
 ┌─                                                                                                                                                                                 
 ╵ '-' '´' '¨' '⋈' '+' '⟜' '⌽' '⊢' '≢' '⥊' '<' '=' '⌜' '˜' '↕' '∾' '○' '⌾' '⊸' '⊑' '÷' '√' '⊏' '⋆' '˝' '∘' '×' '⎉' '≡' '⊣' '⌊' '⁼' '≠' '⍟' '◶' '↓' '¬' '∊' '/' '»' '∨' '`' '>' '⍒'  
   8   8   10  5   8   3   6   7   1   5   9   6   3   12  6   5   2   5   7   9   5   1   1   5   4   8   5   1   3   3   1   1   5   1   2   1   1   1   1   1   1   2   3   1    
@@ -346,7 +346,7 @@ 

Epilogue

While the interpreter's performance is not particularly optimized, here is a comparison with the equivalent Common Lisp code:

-
+
 Benchmark 1: cbqn -f ./bqn/q.bqn
   Time (mean ± σ):      5.468 s ±  0.077 s    [User: 5.427 s, System: 0.005 s]
   Range (min … max):    5.358 s …  5.535 s    5 runs
@@ -369,7 +369,7 @@ 

Epilogue

-
+
 Got 25361 samples
 (REPL): 25361 samples:
      2│  Q ← {𝕊qb‿sc‿r:
diff --git a/rollim.html b/rollim.html
index ebf177a..657efce 100644
--- a/rollim.html
+++ b/rollim.html
@@ -241,9 +241,9 @@ 

A coding impromptu

Table of Contents

@@ -254,9 +254,9 @@

Table of Contents

juxtapose my implementations with those of seasoned BQNators, acknowledging their contributions in footnotes.

-
-

Z algorithm

-
+
+

Z algorithm

+

This is a very efficient procedure that finds prefix strings in linear time. The imperative implementation reads: @@ -338,9 +338,9 @@

Z algorithm

-
-

Longest increasing sub-sequence

-
+
+

Longest increasing sub-sequence

+

This problem can be solved in \(O(n\log n)\) using dynamic programming. Here is an imperative implementation which is quadratic, but can be optimized: @@ -382,9 +382,9 @@

Longest increasing sub-sequence

-
-

N-queens problem

-
+
+

N-queens problem

+

This problem is the archetypal example of backtracking. Initially, I tried to solve it using a function to place the queens in the full board, hoping that it would lead to a @@ -396,7 +396,7 @@

N-queens problem

-
+
 ┌─                 
 ╵ 0 1 0 1 0 1 0 0  
   0 0 1 1 1 0 0 0  
diff --git a/si.html b/si.html
index 0ac363c..a993d5e 100644
--- a/si.html
+++ b/si.html
@@ -197,9 +197,9 @@
 
 

Scheming a mise-en-abîme in BQN

-
-

Prelude

-
+
+

Prelude

+

We will build and interpreter for a subset of the Scheme programming language, following a Norvig's essay. An alternative reference would @@ -208,9 +208,9 @@

Prelude

-
-

A Lisp quine

-
+
+

A Lisp quine

+

Given the title of this post, I couldn't think of a better test for our interpreter than this one: diff --git a/spodat.html b/spodat.html index 67cc4d0..419e5b0 100644 --- a/spodat.html +++ b/spodat.html @@ -201,9 +201,9 @@

Songs to pave the seasons

I have analyzed my Spotify data1 for the period 2016-2024. The results accurately represent my actual music taste2.

-
-

Technical details

-
+
+

Technical details

+

This is a suitable task for an array language, so I rely on BQN which is my favorite one: @@ -235,15 +235,15 @@

Technical details

-
-

Top songs

-
+
+

Top songs

+
s Q spd	
 
-
+
 ┌─                                                     
 ╵ 1  "Countless Skies"                                 
   2  "Divertimento I, K.136: Allegro"                  
@@ -269,15 +269,15 @@ 

Top songs

-
-

Top artists

-
+
+

Top artists

+
a Q spd
 
-
+
 ┌─                              
 ╵ 1  "Opeth"                    
   2  "Wolfgang Amadeus Mozart"  
@@ -303,9 +303,9 @@ 

Top artists

-
-

Bonus: Opeth anthology

-
+
+

Bonus: Opeth anthology

+

This is the Opeth album I would recommend to anyone. The query function needs to be modified a bit for generating it. But before that, let's look at the official discography: @@ -334,7 +334,7 @@

Bonus: Opeth anthology

-
+
 ┌─                             
 ╵ 1 "Ghost of Perdition"       
   2 "River"