Symbolic Closed-Form Fibonacci

2018-12-01, post № 207

Haskell, mathematics, programming, #diagonalization

Theoretical Framework

Let V:=\{(a_j)_{j\in\mathbb{N}}\subset\mathbb{C}|a_n=a_{n-1}+a_{n-2}\forall n>1\} be the two-dimensional complex vector space of sequences adhering to the Fibonacci recurrence relation with basis B:=((0,1,\dots),(1,0,\dots)).
Let furthermore f:V\to V,(a_j)_{j\in\mathbb{N}}\mapsto(a_{j+1})_{j\in\mathbb{N}} be the sequence shift endomorphism represented by the transformation matrix


By iteratively applying the sequence shift a closed-form solution for the standard Fibonacci sequence follows.

Prime Intirety

2018-11-03, post № 206

C, mathematics, programming, #integer, #list, #primes, #representation

Since ancient times humanity knew that there are infinitely many primes — though countable, writing a complete list of every prime is impossible if one intends to finish.
However, in practice one often only considers a minute subset of the naturals to work with and think about. When writing low-level languages like C, one is nearly forced to forget about almost every natural number — the data type u_int_32, for example, is only capable of representing \{\mathbb{N}_0\ni n<2^{32}\}.
Therefore, it is possible to produce a complete list of every prime representable in thirty-two bits using standard bit pattern interpretation — the entirety of the first 𝟤𝟢𝟥 𝟤𝟪𝟢 𝟤𝟤𝟣 primes.

Generating said list took about two minutes on a 4GHz Intel Core i7 using an elementary sieve approach written in C compiled with gcc -O2.
All primes are stored in little-endian format and packed densely together, requiring four bytes each.

Using the resulting file, one can quickly index the primes, for example p_{10^7}=179\,424\,691 = \text{ab1cdb3}_{16} (using zero-based indexing). Since each prime is stored using four bytes, the prime’s index is scaled by a factor of four, resulting in its byte index.

dd status=none ibs=1 count=4 if=primes.bin skip=40000000 | xxd 
00000000: b3cd b10a                                ....

Source code: prime-intirety.c
Prime list (gzipped and split): prime-intirety_primes.bin.gz.parts

Halloween MMXVIII

2018-10-31, post № 205

art, haiku, poetry, #bat

Tiny droplet falls.
A bat’s screech echoes through the cave.
Flowstone grew again.

Jonathan Frech's blog; built 2021/04/16 21:21:49 CEST