So I don't know *why* I started pursuing this question, and I'm not really sure I understand fully what's going on here, but I figure it's time to release this to the wild (looking at you, vince and bplus) and see what happens.
Let's dwell on repeated multiplication. Consider any number q. Then multiply q by itself a lot of times, specifically n times, to get something like q * q * q * q * q ... = q^n. Now, the final form that q^n takes is entirely dependent on the original q:
- If q<1, then q^n will tend toward zero.
- On the other hand, if q>1, then q^n grows toward infinity.
- Only the special case q=1 leads to stable behavior, as you get q^n=1^n=1.
To make things interesting, let's again start with q, but then multiply q by a *random* number in each iteration. Taking QB64's RND function at face value, which gives you a random real number between 0 and 1, would only cause q to shrink to zero:
q = q * RND * RND * RND * RND ... --> 0
... This is because the average value of RND is 0.5. On average, it's *as if* we are calculating q = q * .5 * .5 * .5 * .5, which shrinks quickly.
Let's play a game then. Let us try to scale the RND function so that the long-term behavior in q neither shrinks to zero nor tends to infinity. It should seem obvious that choosing a random number between 0 and 2 would save the day, as the average of 2*RND is surely 1. Let's try it:
... which fails downward. The answer is still somehow dragged down toward zero. Hmmm. Let's see if 3*RND works instead:
... which fails in the other direction (toward infinity), as expected. But what the hell was wrong with 2*RND? Is it's average not one?
After a little bit of fiddling, I eventually found that there *is* a number between 2 and 3 that does the thing I'm asking. Turns out it's none other than Euler's constant, e=2.71828... . In the following code, you can see the randomly-updated X just meander up and down the real number line without picking a direction - that is, until we max out what type DOUBLE can keep track of.
The real question is, *why* does e=EXP(1) do the job, where plain 2 doesn't? Can we prove why the factor must be EXP(1)? Strangely, the best thing I can "prove" by hand is that the factor is equal to one plus the golden ratio, which is about 0.1 off from e itself. Beautiful, and close, but flat wrong. I can hand-wave my way to justifying the presence of e, but that's it. Read the attached paper, it contains my whole effort to date.