Symbolic Closed-Form Fibonacci

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

A := M^B_B(f) = \begin{pmatrix}1&1\\1&0\end{pmatrix}.

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

Continue reading

Advertisements

Prime Intirety

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 203\,280\,221 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: intirety.c
Prime list: primes.bin (775.5 MiB)