Notes

Chapter 2: The Crucial Experiment

Section 1: How Do Simple Programs Behave?


Comments on Mathematica functions

CenterList works by first creating a list of n 0's, then replacing the middle 0 by a 1. (In Mathematica 4 and above PadLeft[{1}, n, 0, Floor[n/2]] can be used instead.) ElementaryRule works by converting num into a base 2 digit sequence, padding with zeros on the left so as to make a list of length 8. The scheme for numbering rules works so that if the value of a particular cell is q, the value of its left neighbor is p, and the value of its right neighbor is r, then the element at position 8 - (r + 2 (q + 2 p)) in the list obtained from ElementaryRule will give the new value of the cell.

CAStep uses the fact that Mathematica can manipulate all the elements in a list at once. RotateLeft[a] and RotateRight[a] make shifted versions of the original list of cell values a. Then when these lists are added together, their corresponding elements are combined, as in {p, q, r} + {s, t, u} → {p+s, q+t, r+u}. The result is that a list is produced which specifies for each cell which element of the rule applies to that cell. The actual list of new cell values is then generated by using the fact that {i, j, k}[[{2, 1, 1, 3, 2}]] → {j, i, i, k, j}. Note that by using RotateLeft and RotateRight one automatically gets cyclic boundary conditions.

CAEvolveList applies CAStep t times. Many other evolution functions in these notes use the same mechanism. In general NestList[s[r, #]&, i, 2] → {i, s[r, i], s[r, s[r, i]]}, etc.


From Stephen Wolfram: A New Kind of Science [citation]