Monday, March 14, 2022

π fs - the data-free filesystem, with Pi spigot algorithm

 philipl/pifs: πfs - the data-free filesystem!

"π (or pi) is one of the most important constants in mathematics and has a variety of interesting properties (which you can read about at wikipedia)

One of the properties that π is conjectured to have is that it is normal, which is to say that its digits are all distributed evenly, with the implication that it is a disjunctive sequence, meaning that all possible finite sequences of digits will be present somewhere in it. If we consider π in base 16 (hexadecimal) , it is trivial to see that if this conjecture is true, then all possible finite files must exist within π. The first record of this observation dates back to 2001.

πfs is a revolutionary new file system that, instead of wasting space storing your data on your hard drive, stores your data in π! You'll never run out of space again - π holds every file that could possibly exist! They said 100% compression was impossible? You're looking at it!"


Bailey–Borwein–Plouffe formula - Wikipedia

is a formula for π.

The BBP formula gives rise to a spigot algorithm for computing the nth base-16 (hexadecimal) digit of π (and therefore also the 4nth binary digit of π) without computing the preceding digits. This does not compute the nth decimal of π (i.e., in base 10).[3] BBP and BBP-inspired algorithms have been used in projects such as PiHex[4] for calculating many digits of π using distributed computing.


With a nod to fellow pi-hound Dik T Winter, three equal lines of C give 32k digits of pi:

http://leapsecond.com/tools/pi3.c

brilliant method of embedding his name in the code without wasting lines for comments

iijlab-seminar-20170327.pdf


A Spigot Algorithm for the Digits of π Authors: Stanley Rabinowitz and Stan Wagon



Here's a C version from Winter and Flammenkamp:

unsigned s, P, I, g[109970], o = 10000, t = 109970, by, Dik, T, Winter;
main() {
  for (; s = t, t -= 14; Winter = printf("%04d", Dik + P / o), Dik = P % o)
    while (I = --s * 2)
      P = T * s + o * (Winter ? g[s] : o / 5), T = P / --I, g[s] = P - I * T;

No comments: