Angelic and Evil Numbers

Copyright Chris Lomont, 2004

Click here for the mathematica notebook (400K).

This notebook explains how to compute the "probability that an irrational number has initial digits summing to 666".

This was motivated by the fact mentioned on the website on Sept 29,2004, that adding the initial (after the decimal) 144 digits of π gives a sum of 666, and it was also noted this works for summing the first 146 digits after the decimal point of the Golden Ratio φ. Here we note the built-in Mathematica Glaisher constant also has a sum of 666 for the first 153 digits after the decimal point. The question was posed: how likely is this? To analyze this problem, first we make a function to find the sum of m digits, taking every nth digit after the decimal point:

We call such numbers Evil. Note that this does not work for the natural base e, so not all numbers are Evil:

However, if we add every 15th digit of e, we find by adding 137 digits, that e is somewhat evil....

Like a good numerologist, we find similarly the smallest skip making each common Mathematica constant evil, ranking them by total digits needed to detect their evilness. Note it took a lot of digits to find 666 in the Catalan number.

Mysterious! Are all numbers inherently evil? All this really shows is not to trust numerology books like the Bible Code. It's easy to find number patterns if you look and fiddle with data.

To show that it is easy to find these, we will show the probability of a sequence of random digits adding to an arbitrary positive integer k is roughly 1/5,and give a way to compute the exact probability p[k]. Thus we are quite likely to find evil numbers (for some digit skip) almost everywhere. In fact, I conjecture they are dense in the set of real numbers.

First some reductions, all intuitively stated, although they can be rigorously proven. Consider a random variable X that returns a digit from 0 to 9 inclusive with uniform probability. Then consider all sequences . Note this returns an irrational number with probability 1 (rational numbers with period m must have repeating sequences after the first m digits, which has 0 chance of happening). We want the probability p[k], given a positive integer k, that there is an integer m such that the sequence sums to k. For an example let's compute p[2] the hard way. We can get 2 for the sum from two types of sequences: all zeros ended by a 2, and a sequence of all zeros and a single 1 in any order, followed by a 1. Computing these probabilities takes a bit of work, since we need two infinite sums.

Note these sums can be done by hand. The proof to do the first one with a geometric series can easily be adapted and used twice to compute the second sum. But there is a better way.

Note the 0's in the sequence do not affect the sum, so we want to remove 0s from the problem. First, note the probability is 0 of the variable X returning all 0s (note that it could happen, it just has arbitrarily small probability, thus 0). Secondly, note that for a fixed positive integer n, the probability is 0 that the sequence sum never surpasses n, since that would mean that after at most n digits X returns all 0s, again which has 0 probability. Thus we are safe in removing the 0s, since they will not affect the final probabilities p[k]. So redefine X such that X only returns digits 1 to 9, with uniform probability.

To show how useful this is, let's recompute p[2] the new way. There are now only two ways to do it- a sequence of {2} and a sequence {1,1} with probability:

Note we get the same answer as before (which is nice). To compute the general formula, we make some observations. For k<10, the probability of getting a digit sum of k is the probability of getting k on the first digit, plus the probabilities of getting a smaller value times the probability of jumping to k from the smaller value. This defines the probabilities recursively. We note p[1] = . Thus we have for k<10

We note that this is a geometric series (which unfortunately is not repeated for k>9). There should be a nice way to see these probabilities directly, but I have not found it.

Next we use a similar observation to compute p[k] for k>9. In this case, to get a sum of k means before the last digit d is added obtaining k, we were at k-d. So for each last possible digit 1-9, we compute the probability of reaching k-d by any means, times the 1/9 probability of getting last digit d. This gives

We used the Mathematica trick of reassigning each value with p[k_] := p[k]=... which speeds up computation greatly by storing precomputed values, at the cost of storage space. Unfortunately, if we try to evaluate p[666], we get an error since we exceed the recursion limit. So we "precompute" values, say the first 1000, using a trick to do 100 at a time. Plus this is much faster than trying to compute p[666] directly.

We just created the first 1000 values in memory. Now we get the exact answer! What is the probability of a uniformly chosen infinite string of digits containing a prefix sum of 666? It is.....

Hmmm, not very nice. However we show how close it is to 20%. We compute to 75 digits, otherwise we only get noise since the machine precision is usually around .

So the probability of a given number being Evil right off the bat is 20%. Thus is it very likely that by fiddling with the spacing between digits summed that any irrational number will turn out to be evil. What is the probability of summing to 7 and being Angelic?

At least this gives some hope - a random number is more likely to be Angelic (20.9%) than Evil (20%). That was close! All the constants tested above for (somewhat) Evilness become (somewhat) Angelic with less digits than it takes to find Evil, except the Catalan constant, since the first digit after the decimal is 9, and so it has no Angelic possibilities. Also the Angelic numbers cannot be dense, since some irrationals begin 0.8... or 0.9... So we find out (again) that we can find patterns wherever we look. Here are the constants again, showing Angelic properties with minimal digits.

How close is p[k] to 20% for the largest k we computed? Note we have to fiddle with the precision to get good answers. We find the maximum distance the p[k] varies from 20% for k from 900 to 1000.

Very close.... It seems ALL the probabilities are converging to 20%. Proving this convergence would be a good challenge.

Some pictures to show the self similar nature of the graph.

To show some of how this probability behaves, let's graph it for various intervals of k.

So it looks wild at first, but perhaps is smooths out? Let's look closer.

Is it jumpy early on. Does it stabilize? Let's look at some intervals.

The first several graphs are similar at different scales - fractals? The graph tapers off to near a probability of 1/5, but still oscillates. It is likely we have run up against the numerical limits of Mathematica, and have not actually stabilized. To test this hypothesis, we compute a intervals as above, and measure the difference from 1/5 to see that the fractal oscillations are still occurring:

So it seems this probability function is oscillates and converges to 20% as we thought, even at large k values.

A pressing question: can we find a closed form? Mathematica has a built in function to solve for this, but it may be a very hard recurrence to solve since each p[k] relies on 9 previous terms for k>9. Using the RSolve command ran for several hours, but had no results by then....

We can show two nice forms for the generating function (found by hand) of p[k]. Finding a closed form from this is a lot of work (I tried).

First note we can replace the recursion by p[k+1] = (10 p[k]-p[k-9])/9 for k ≥ 10 by computing p[k+1]-p[k], and simplifying. This eases the work of finding the generating function. Even this simpler form does not work well in RSolve.

So the probability p[k] is now found as the kth coefficient in the Taylor Series of f[t] .

Here are some misc computations used while trying to find a closed form, which show a nice closed form for k < 20. These formulae are able to be found for higher k, but they get very messy.

And a final sanity check - test some random digit sequences against the probability formula.

Although the experimental data has a lot of noise, it is comforting that it also seems to center around a probability of 20% for large k.

THE END. I hope you have enjoyed this. Visit or .

Created by Mathematica (October 5, 2004)