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. @@ -286,9 +286,9 @@
Exordium
Basis set
-Basis set
+Basis sets are used to transform the PDEs into linear algebra problems. Physical intuition suggests that Slater type orbitals4 are a good choice for our Hamiltonian. However, the computation of the integrals @@ -306,9 +306,9 @@
Basis set
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 @@ -387,7 +387,7 @@
Electronic integrals
+Got 38006 samples (self-hosted runtime1): 1067 samples (REPL): 36939 samples: @@ -416,9 +416,9 @@Electronic integrals
Fock matrix
-Fock matrix
+The following function constructs the Fock matrix, our approximation to the true Hamiltonian of the system:
@@ -472,9 +472,9 @@Fock matrix
Self-consistent field
-Self-consistent field
+The final stage of the computation involves solving the pseudo-eigenvalue problem using a fixed-point iteration. This process is commonly known as the self-consistent field method, a term coined by D. R. Hartree. diff --git a/nm.html b/nm.html index ad85302..c3ae724 100644 --- a/nm.html +++ b/nm.html @@ -197,13 +197,13 @@
A numerical methods bonsai display
-Foreword
+Foreword
Bibliography
-Bibliography
+These are my favorite books on numerical analysis, in descending order of preference. I use the first two very often, and consult the others to deepen my understanding: diff --git a/nn.html b/nn.html index 4e80275..2f82c75 100644 --- a/nn.html +++ b/nn.html @@ -234,9 +234,9 @@
The miniaturist's neural network (WIP)
-Preface
-Preface
+We will implement a fully-connected feed-forward neural network1, in other words, a
@@ -280,9 +280,9 @@Preface
Tinn's diminution
-Tinn's diminution
+The original C implementation has 175 lines excluding the optimization loop. The BQN version has only
@@ -355,9 +355,9 @@Tinn's diminution
Learning the logistic map
-Learning the logistic map
+
_minn
should handle digit recognition just fine3. However, I would like to switch clichés for the demonstration.
Instead, we will use it to learn the logistic map4. This is a quintessential example of how chaos can emerge from simple systems.
diff --git a/qbqn.html b/qbqn.html
index cec83db..e982e2d 100644
--- a/qbqn.html
+++ b/qbqn.html
@@ -197,9 +197,9 @@
BQN's Quantum Noise
-Preamble
-Preamble
+We will implement and test a Schrödinger-style1 quantum simulator in the BQN2 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 chars3) 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
-@@ -291,9 +291,9 @@C >+˝{Q qb‿sc‿𝕩}¨ r +C >+˝{Q qb‿sc‿𝕩}¨ rShor'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 094c83c..27d69dc 100644 --- a/rollim.html +++ b/rollim.html @@ -241,13 +241,13 @@A coding impromptu
Table of Contents
Table of Contents
would devise 35 to 40 distinct solutions to even the simplest problem in BQN. Therefore, I will frequently juxtapose my implementations with those of seasoned BQNators2. -Z algorithm
-Z algorithm
+This is a very efficient procedure that finds prefix strings in linear time. The imperative implementation reads: @@ -326,9 +326,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: @@ -368,7 +368,7 @@
Longest increasing sub-sequence
Let's)explain
this optimized version, so we can truly appreciate its beauty:
-++´∞≠∞¨{𝕨⌾((⊑𝕩⍋𝕨-1)⊸⊑)𝕩}´⌽ │ │ │ ││ │ │ │ │ │ │ │ │ │ {┼────┼─┼─┼──┼─┼─´│ @@ -398,9 +398,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 @@ -412,7 +412,7 @@
N-queens problem
+┌─ ╵ 0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 0 @@ -460,9 +460,9 @@N-queens problem
Majority element
-Majority element
+
The Boyer–Moore algorithm allows for finding the majority element (element that appears
more than ⌊𝕩÷2
times in the array) in linear time. If such element exists, then it is
@@ -497,9 +497,9 @@
Majority element
An identity on the naturals
-An identity on the naturals
+Some time ago, while working on performance optimization of linear algebra operations with Boolean arrays, I encountered an @@ -534,9 +534,9 @@
An identity on the naturals
Depth of nested lists
-Depth of nested lists
+Studying tree algorithms in APL, I learned about the depth vector representation. If the nested object in consideration is a string, the best approach is using boolean masks. @@ -554,9 +554,9 @@
Depth of nested lists
H-index
-H-index
+This metric is one of the reasons for the deplorable state of modern academia, and the headaches for outsiders trying to get in. Consider that Peter Higgs diff --git a/si.html b/si.html index 6feb9b4..2b98c0a 100644 --- a/si.html +++ b/si.html @@ -229,9 +229,9 @@
Scheming a mise-en-abîme in BQN
-Prelude
-Prelude
+We will build an interpreter for a subset of the Scheme programming language, following an essay by Peter Norvig. An alternative reference would @@ -242,9 +242,9 @@
Prelude
A R5RS dialect
-A R5RS dialect
+Our goal is to adhere to the Revised\(^5\) Report on the Algorithmic Language Scheme (R5RS). However, seasoned schemers will quickly notice that our implementation still has @@ -337,9 +337,9 @@
A R5RS dialect
A Lisp quine
-A Lisp quine
+Given the title of this post, it's only fitting that we test our interpreter with a quine. In fact, building this interpreter was, for me, an exercise in bootstrapping the necessary machinery to produce this recursive effect: diff --git a/spodat.html b/spodat.html index 6699dc7..7c67023 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"