I've revisited the spigot algorithm (posted 25th September 2021), and in the spirit of exploration, looked at what happens if:
(a) d = d + 20 becomes d = d + BETA, where BETA is an integer;
(b) g = 2 * b - 1 becomes g = GAMMA * b ± ALPHA, where GAMMA and ALPHA are integers;
(c) d = d * b becomes optional.
These changes are interesting because they are easily implemented in the hardware, and enable numbers other than π to be computed. The first 'discovery' was:
ALPHA = 0, BETA = 10 and GAMMA = 1, with operation d = d * b omitted, which yields 🥁🥁🥁
1.718281828459045235360287471352662497757247093699959574966967627724076...
which is one less than Euler's number.
Or, how about ALPHA = -1, BETA = 10 and GAMMA = 1, with operation d = d * b omitted?
2.718281828459045235360287471352662497757247093699959574966967627724076...
which is Euler's number. Interestingly, the algorithm produces (and thus the TTL implementation should produce) an amazing 2,235 correct digits of e.
So, the project, which started as a challenge to compute π has morphed into computing π, e, and other constants; it's something of a game to figure out what the constant is that's been computed - for a given ALPHA, BETA and GAMMA (with d = d * b included or omitted). More on this later.
Here's the revised algorithm:
One other change: if (g == 0) g = 1; this is to avoid potential division by zero.Changing g = 2 * b - 1 to g = GAMMA * b ± ALPHA means some additional hardware to multiply a ten bit number (b) by GAMMA. To keep things reasonable, GAMMA is limited to a 3 bit value, i.e. GAMMA can range from 0 through 7. This needs a 10 bit times 3 bit multiplier...
No comments:
Post a Comment