The order and disorder of binary representations of the natural numbers < 28 is measured using the BiEntropy function. Significant differences are detected between the primes and the non-primes. The BiEntropic prime density is shown to be quadratic with a very small Gaussian distributed error. The work is repeated in binary using a Monte Carlo simulation of a sample of natural numbers < 232 and in trinary for all natural numbers < 39 with similar but cubic results. We found a significant relationship between BiEntropy and TriEntropy such that we can discriminate between the primes and numbers divisible by six. We discuss the theoretical basis of these results and show how they generalise to give a tight bound on the variance of Pi(x)–Li(x) for all x. This bound is much tighter than the bound given by Von Koch in 1901 as an equivalence for proof of the Riemann Hypothesis. Since the primes are Gaussian due to a simple induction on the binary derivative, this implies that the twin primes conjecture is true. We also provide absolutely convergent asymptotes for the numbers of Fermat and Mersenne primes in the appendices.
We design, implement and test a simple algorithm which computes the approximate entropy of a finite binary string of arbitrary length. The algorithm uses a weighted average of the Shannon Entropies of the string and all but the last binary derivative of the string. We successfully test the algorithm in the fields of Prime Number Theory (where we prove explicitly that the sequence of prime numbers is not periodic), Human Vision, Cryptography, Random Number Generation and Quantitative Finance.
The distribution of prime numbers has long been viewed as a balance between order and randomness. In this work, we investigate the relationship between entropy, periodicity, and primality through the computational framework of the binary derivative. We prove that periodic numbers are composite in all bases except for a single trivial case and establish a set of twelve theorems governing the behavior of primes and composites in terms of binary periodicity. Building upon these results, we introduce a novel scale-invariant entropic measure of primality, denoted p(s′), which provides an exact and unconditional entropic probability of primality derived solely from the periodic structure of a binary number and its binary derivatives. We show that p(s′) is quadratic, statistically well-defined, and strongly correlated with our earlier BiEntropy measure of binary disorder. Empirical analyses across several numerical ranges demonstrate that the variance in prime density relative to quadratic expectation is small, binormal, and constrained by the central limit theorem. These findings reveal a deep connection between entropy and the randomness of the primes, offering new insights into the entropic structure of number theory, with implications for the Riemann Hypothesis, special classes of primes, and computational applications in cryptography.