In this series of posts, Katie investigates simple mathematical concepts using the Google Sheets spreadsheet app on her phone. If you have a simple maths trick, pattern or concept you’d like to see illustrated in this series, please get in touch.
Spreadsheets are wonderfully versatile, and the fact that I can now carry spreadsheets around on my phone, in my pocket, is a marvellous result of the smartphone boom. I’m always pleased to see so many people wandering around using spreadsheets on their phones (I assume).
So when my Aperiodicolleague CL-P sent me a link to his latest spreadsheet creation, I was pretty excited to find yet another application of spreadsheets – for modelling cellular automata! As we’ve previously written about on this site, cellular automata are systems that have a set of rules to determine how they change over time, on a cell-by-cell basis (spreadsheets are really the natural choice here). While many automata, such as Conway’s famous Game of Life, are 2-dimensional, that’s slightly difficult to represent on a spreadsheet, as you’d need a separate sheet for each point in time. 1-dimensional automata can be displayed on a spreadsheet though, by simply using the top row to represent the cells you’re starting with and then iterating time down the sheet.
CL-P’s spreadsheet models the famous Rule 30 cellular automaton, named for the specific rule it encodes. Stephen Wolfram, of Wolfram who brought you the maths programme Mathematica and many other cool maths things, named the set of Elementary Cellular Automata rules (0 to 31), each using a different pattern of outputs. The rules tell you how the cells in the row above determine the next row – each triple of three cells determines the value of the cells below, and each cell is allowed to be ‘on’ or ‘off’ (much like in Conway’s Game of Life, where the cells are ‘alive’ or ‘dead’). Since there are 8 possible combinations of on/off across 3 cells, the rule is encoded by knowing whether each of the 8 combinations results in the cell below being ‘on’ or ‘off’. These 8 on/off values determine a binary number less than 32, and the rule is named after the number given by the set of on/offs it uses, as 0/1 digits.
Of the 31 possible rule-sets Wolfram determined in this way, 30 is probably the most well-known, mainly because it’s the most interesting. $30 = 00011110_2$, which means if the number given by the three cells above as binary digits is 0,6,7 or 8 then the cell below should have a 0, and if not then it should have a 1.
Some of them end up dying a death pretty quickly (rule 0 is particularly boring – whatever you start with, everything in the second row is dead, and everything after that is dead forever). Rule 30 however, gives a pleasing pattern of shapes and even if you just start with a single ‘on’ cell in the top row, propagates a pattern across the whole sheet. Christian’s found a way to incorporate the statement of Rule 30 into a single formula:
=if(mod(4*[cell above left]+2*[cell above]+[cell above right]-3,7)<4,0,1)
This says, if the three cells above left to right are A, B and C, then if $4A + 2B + C – 3 $ (the binary number given by the numbers above, minus 3) is less than $4 \mod 7$ – so, if the number above is 0,6,7 or 8, then don’t colour the cell, and if it’s not then do colour the cell. Conditional formatting is used to make cells with a 1 in turn green, and cells with a 0 will remain white.
Christian’s sheet is here: CP’s Rule 30 spreadsheet
If you’d like to play with it, you can make a copy of it in your own Drive and edit there – we’ve left this one as view-only so you can always come back and get an undamaged version if you make a mess of things. Try starting with different combinations of 0/1 across the top, and make sure you give it a little time to calculate the rest of the sheet – it’s thinking pretty hard for a little phone!