Yesterday I came by an article **100 billion steps of Pi visualized**. Here are the rules for the visualization taken from the site:
This is a walk made out of the first 100 billion digits of pi in base 4 with the following rules for the steps: 0 right, 1 up, 2 left, 3 down. The color indicates the progress of the digits, starting at the color red. Goal of the image is to show that the digits of Pi are random and don’t show any patterns.
This is based on original article **Walking on real numbers**. Well to compute 100 billion steps would require some time, but could we at least start this in Mathematica with maybe a jus few steps to see the result quickly?
Of course, but lets try something new, why repeat things already done? So instead of base 4 we consider base 8. This will allow us to add steps in diagonal directions to those in vertical and horizontal directions. Define rules that will map a base-8 digit into a step in a particular direction, given by unit increments {dx, dy}:
rules = {0 -> {0, 1}, 1 -> {0, -1}, 2 -> {1, 0}, 3 -> {-1, 0}}~Join~(Rule @@@ Thread[{Range[4, 7], Tuples[{1, -1}, 2]}]);
Now define a function the uses this rules to make a step st from a given point pt:
onEsteP[pt_, st_] := pt + (st /. rules)
And now lets walk on Pi !
ptsl = FoldList[onEsteP, {0, 0}, RealDigits[Pi, 8, 10^5][[1]]];
The last step of course to visualize it:
Graphics[MapIndexed[{Opacity[.5],
ColorData["Rainbow"][#2[[1]]/Length[ptsl]], Line[#1]} &,
Partition[ptsl, 2, 1]], Background -> Black]
And we can even create a scanning animation of a higher resolution image:
loi = Table[Graphics[MapIndexed[{Opacity[.5],
ColorData["Rainbow"][#2[[1]]/Length[ptsl]], Line[#1]} &,
Partition[ptsl, 2, 1]], Background -> Black,
PlotRange -> {{0, 50} + k, {-150, -100}}], {k, 1, 50}];
Export["bmsf.gif", loi]








– you have earned Featured Contributor Badge