## Random Walk Through PI

```For any positive integer n let d[n] denote the nth decimal digit
of PI.  For example, d[1]=3.  Now consider the sum of the digits
of PI with alternating signs, i.e., define the function

s(k)  =  d[1] - d[2] + d[3] - d[4] + ... -(-1)^k d[k]

Just doing a quick check, the value of s(k) is negative for k=8,
10, 12, and 14, but then it seems to go positive for quite a
while.  In fact, it remains positive for all subsequent k up to
10000, where we have s(10000)=180.  The maximum value achieved
by s(k) in this range is 415.

At what point does s(k) again go negative?  Matthew Galati checked
the first 50000 digits and found that s(k) falls below zero at
k=16124.  His computations also indicate that there is an
interesting negative spike at about k=30000, where the value
of s(k) dips to nearly -300 very briefly.

I then checked the value of s(k) for k up to 100,000, based on
Bob Breid's (North Dakota State University) handy file of digits.
The results are as shown below:

This looks very consistent with Galati's data (which covered only
the first 50000 digits), including the down-spike near k=30000.
Interestingly, in the range from 50000 to 100000 there is evidently
a pronounced upward trend.  Presumably this is just a statistical
fluctuation, since I can see no reason the odd-numbered decimal
digits of pi would be consistently larger than the even-numbered
digits.  Still, it would be interesting to know at what value of
k the function s(k) again goes negative.

In October 99 I received an email from Peter Kosinar, extending the
random walk up through 8 million digits of PI.  He kindly provided the
minimum and maximum values attained by s(k) for k over each 50000 step
interval from 0 to 8 million, and these ranges are indicated by the
vertical yellow bars in the figure below.  Thus the intervals from
0 to 50000 and from 50000 to 100000 in the above plot are represented
by the first two vertical yellow bars in the figure below.

This shows that the interval from 500000 to 100000 is indeed some-
what of an anomaly, in jumping up rather rapidly, and the function
subsequently does indeed go negative again, between about 1.5
million and 5 million.  Then once again it trends positive.  This
is a nice illustration of a one-dimensional (pseudo) random walk.
Presumably for any base b we could generate an essentially
"independent" random walk by summing the base-b digits of PI in
this same manner.
```