<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nathaniel Johnston &#187; Integer Sequences</title>
	<atom:link href="http://www.nathanieljohnston.com/index.php/tag/integer-sequences/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nathanieljohnston.com</link>
	<description>A blog of recreational math and coding</description>
	<lastBuildDate>Tue, 18 May 2010 12:49:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Generating Sequences of Primes in Conway&#8217;s Game of Life</title>
		<link>http://www.nathanieljohnston.com/index.php/2009/08/generating-sequences-of-primes-in-conways-game-of-life/</link>
		<comments>http://www.nathanieljohnston.com/index.php/2009/08/generating-sequences-of-primes-in-conways-game-of-life/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 12:00:11 +0000</pubDate>
		<dc:creator>Nathaniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Conway's Game of Life]]></category>
		<category><![CDATA[Integer Sequences]]></category>

		<guid isPermaLink="false">http://www.nathanieljohnston.com/?p=598</guid>
		<description><![CDATA[One of the most interesting patterns that has ever been constructed in Conway&#8217;s Game of Life is primer, a gun that fires lightweight spaceships that represent exactly the prime numbers. It was constructed by Dean Hickerson way back in 1991, yet arguably no pattern since then has been constructed that&#8217;s as interesting. It seems somewhat [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most interesting patterns that has ever been constructed in <a href="http://www.conwaylife.com/wiki/index.php?title=Conway's_Game_of_Life">Conway&#8217;s Game of Life</a> is <a href="http://www.conwaylife.com/wiki/index.php?title=Primer">primer</a>, a gun that fires <a href="http://www.conwaylife.com/wiki/index.php?title=Lightweight_spaceship">lightweight spaceships</a> that represent exactly the prime numbers. It was constructed by Dean Hickerson way back in 1991, yet arguably no pattern since then has been constructed that&#8217;s as interesting. It seems somewhat counter-intuitive at first that the prime numbers, which seem somehow &#8220;random&#8221; or &#8220;unpredictable&#8221;, can be generated by this (relatively simple) pattern in the completely deterministic Game of Life.</p>
<div id="attachment_632" class="wp-caption aligncenter" style="width: 479px"><a href="http://www.conwaylife.com/wiki/index.php?title=Primer"><img class="size-full wp-image-632    " title="Primer" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/08/primer.png" alt="Primer, the prime-generating gun" width="469" height="324" /></a><p class="wp-caption-text">Primer, the prime-generating gun</p></div>
<p>The gun works by firing lightweight spaceships westward, and destroying them via glider guns that emulate the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Eratosthenes</a>. A lightweight spaceship makes it past the left edge of the gun at generation 120N if and only if N is a prime number (though for technical reasons, 2 and 3 are not outputted).</p>
<div id="attachment_633" class="wp-caption aligncenter" style="width: 539px"><a href="http://www.nathanieljohnston.com/wp-content/uploads/2009/08/output.png"><img class="size-full wp-image-633   " title="Primer output" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/08/output.png" alt="The first six lightweight spaceships output by primer and the numbers they represent" width="529" height="27" /></a><p class="wp-caption-text">The first six lightweight spaceships output by primer</p></div>
<p>It wasn&#8217;t too long after making primer that Hickerson realized that he could attach a gun to the bottom-left corner of it to turn it into a <a href="http://en.wikipedia.org/wiki/Twin_prime">twin prime</a> calculator by allowing each lightweight spaceship through only if another lightweight spaceship passed through 240 generations earlier. Similarly, Jason Summers constructed a <a href="http://en.wikipedia.org/wiki/Fermat_number#Primality_of_Fermat_numbers">Fermat prime</a> calculator in 2000 by shooting a glider at the lightweight spaceship stream every generation of the form 120(2<sup>N</sup> + 1), which ends up detecting exactly the Fermat primes.</p>
<p>So what other families of primes can we compute in Life by altering the output of the original prime-generating gun?</p>
<h3>Mersenne Primes</h3>
<p><a href="http://en.wikipedia.org/wiki/Mersenne_prime">Mersenne primes</a> can easily be computed using the exact same method as was used in the Fermat prime calculator &#8212; use a <a href="http://www.conwaylife.com/wiki/index.php?title=7-engine_Cordership">7-engine Cordership</a> (in <span style="color: #0000ff;">blue</span> below) to bounce a <a href="http://www.conwaylife.com/wiki/index.php?title=Glider">glider</a> back at the stream of lightweight spaceships, with the time required for the glider to reach the stream doubling each time. An inverter (in <span style="color: #008000;">green</span> below) eliminates all lightweight spaceships that try to get past it <em>unless</em> it just received a glider from the Cordership. By fiddling around with timing a tiny bit, we then have a Mersenne prime calculator:</p>
<div id="attachment_636" class="wp-caption aligncenter" style="width: 600px"><img class="size-full wp-image-636  " title="Mersenne Prime Calculator" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/08/mersenne.png" alt="Mersenne Prime Calculator" width="590" height="402" /><p class="wp-caption-text">Mersenne Prime Calculator</p></div>
<ul>
<li>Java link: <a href="http://www.conwaylife.com/?p=mersenneprimecalculator">here</a></li>
<li>RLE file: <a href="http://www.conwaylife.com/pattern.asp?p=mersenneprimecalculator.rle">here</a></li>
</ul>
<h3>Prime Quadruplets</h3>
<p>Four prime numbers are said to form a <a href="http://en.wikipedia.org/wiki/Prime_quadruplet">prime quadruplet</a> if they are of the form (p, p+2, p+6, p+8) for some prime number p, which is the closest that four prime numbers can be together (except for the degenerate cases of (2,3,5,7) and (3,5,7,11)). Prime quadruplets are easy to compute because they can be thought of as consecutive pairs of twin primes. Since we already have a twin prime calculator, we can just repeat its reaction.</p>
<p>The twin prime calculator works by attaching a period 240 gun (in <span style="color: #008000;">green</span> below) to the bottom-left corner of primer. If it is timed correctly, it has the effect of allowing a lightweight spaceship through at generation 240N if and only if a lightweight spaceship tried to pass through at generation 240(N-1). Thus, it will only allow a lightweight spaceship through if it represents a prime number of the form p+2, where p is another prime number. Well, simply attaching a period 720 gun (in <span style="color: #0000ff;">blue</span> below) then allows a spaceship through at generation 720N if and only if a lightweight spaceship tried to pass through at generation 720(N-1). This has the effect of allowing a lightweight spaceship to pass through only if it represents a twin prime pair (p,p+2), and there is another twin prime pair of the form (p-6,p-4). That is, the only lightweight spaceships allowed through are those representing the upper members of prime quadruplets.</p>
<div id="attachment_640" class="wp-caption aligncenter" style="width: 555px"><img class="size-full wp-image-640" title="Prime quadruplet calculator" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/08/quad.png" alt="Prime quadruplet calculator" width="545" height="353" /><p class="wp-caption-text">Prime quadruplet calculator</p></div>
<ul>
<li>Java link: <a href="http://www.conwaylife.com/?p=primequadrupletcalculator">here</a></li>
<li>RLE file: <a href="http://www.conwaylife.com/pattern.asp?p=primequadrupletcalculator.rle">here</a></li>
</ul>
<h3>Prime Pairs of the Form (p, p+2k)</h3>
<p>The twin prime calculator mentioned earlier gives a way of computing prime pairs of the form (p,p+2), but what about pairs where the gap is larger than 2? For example, the k=2 case gives what are known as <a href="http://en.wikipedia.org/wiki/Cousin_prime">cousin primes</a>, and the k=3 case gives <a href="http://en.wikipedia.org/wiki/Sexy_primes">sexy primes</a> (yes, really).</p>
<p>For the case of cousin primes, the thing to notice is that every pair of cousin primes (except for the first pair, (3,7)) must be of the form (6n+1, 6n+5) for some natural number n. Thus, we can use two period 720 guns (in <span style="color: #0000ff;">blue</span> below) to allow only the upper prime in a cousin prime pair to pass through. This is achieved by having the top gun fire at the lightweight spaceships representing primes of the form 6n+1 &#8212; if a lightweight spaceship is hit, then a block is created in the path of the other gun, which is fired at lightweight spaceships representing primes of the form 6n+5. If a prime was present at 6n+1, then the lightweight spaceship makes it through unharmed at 6n+5. If there was no prime present at 6n+1, then the bottom gun destroys the lightweight spaceship representing 6n+5.</p>
<div id="attachment_643" class="wp-caption aligncenter" style="width: 493px"><img class="size-full wp-image-643" title="Cousin prime calculator" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/08/cousin.png" alt="Cousin prime calculator" width="483" height="383" /><p class="wp-caption-text">Cousin prime calculator</p></div>
<ul>
<li>Java link: <a href="http://www.conwaylife.com/?p=cousinprimecalculator">here</a></li>
<li>RLE file: <a href="http://www.conwaylife.com/pattern.asp?p=cousinprimecalculator.rle">here</a></li>
</ul>
<p>Extending this idea to prime pairs of the form (p,p+2k) for k ≥ 3 is a bit more challenging, however, because it is possible for pairs to overlap. For example, (37,43) is a sexy prime pair, as is (41,47). Up until now we have only been able to detect single pairs at a time, since the block that acts as our &#8220;counter&#8221; that keeps track of whether a prime was detected earlier is placed in the stream of incoming lightweight spaceships. Thus, if it&#8217;s possible for two pairs to overlap, we will get lightweight spaceships colliding with the block, causing a mess.</p>
<p>To get around this problem, we use a device (known as a fanout, in <span style="color: #008000;">green</span> below) that duplicates the stream of lightweight spaceships. We then check for certain pairs on one stream, and the rest of the pairs on the other stream (these devices are outlined in <span style="color: #0000ff;">blue</span> below). Once we&#8217;re done, we merge the resulting streams of lightweight spaceships back together (using the devices in <span style="color: #800080;">purple</span> below).</p>
<p>To make this process a bit more explicit, I present a gun that computes prime pairs of the form (p,p+8). In particular, a lightweight spaceship will make it past the left edge of this pattern at about generation 1620+120N if and only if both N and N+8 are prime.</p>
<div id="attachment_645" class="wp-caption aligncenter" style="width: 600px"><a href="http://www.nathanieljohnston.com/wp-content/uploads/2009/08/pp8.png"><img class="size-full wp-image-645   " title="(p, p+8) prime calculator" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/08/pp8.png" alt="(p, p+8) prime calculator" width="590" height="377" /></a><p class="wp-caption-text">(p, p+8) prime calculator</p></div>
<ul>
<li>Java link: <a href="http://www.conwaylife.com/?p=pp8primecalculator">here</a></li>
<li>RLE file: <a href="http://www.conwaylife.com/pattern.asp?p=pp8primecalculator.rle">here</a></li>
</ul>
<p>We now have all of the tools needed to build any pattern that computes prime pairs of the form (p, p+2k) as long as k = 1 or 2 (mod 3), though we may need to use the fanout device multiple times if it&#8217;s possible for more than one pair to overlap. If k = 0 (mod 3), however, it&#8217;s much more difficult to construct the desired pattern, because not only can you have overlapping prime pairs like (5, 11) and (7, 13), but you can have prime pairs in sequence such as (5, 11) and (11, 17). This problem can be remedied using the same tools as used in the (p,p+8) prime calculator, though you may need to use a <em>lot </em>of fanout devices to make things work. For example, computing the sexy primes using these tools would require at least four fanouts, and some clever elimination logic on each of the resulting five lightweight spaceship streams. I don&#8217;t feel up to that task myself, but it&#8217;s nice to know that we have a method for constructing a sexy prime calculator.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nathanieljohnston.com/index.php/2009/08/generating-sequences-of-primes-in-conways-game-of-life/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>11630 is the First Uninteresting Number</title>
		<link>http://www.nathanieljohnston.com/index.php/2009/06/11630-is-the-first-uninteresting-number/</link>
		<comments>http://www.nathanieljohnston.com/index.php/2009/06/11630-is-the-first-uninteresting-number/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 12:00:28 +0000</pubDate>
		<dc:creator>Nathaniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Integer Sequences]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://www.nathanieljohnston.com/?p=374</guid>
		<description><![CDATA[There&#8217;s an old math paradox that says that all natural numbers are interesting, since otherwise there would have to be a smallest uninteresting number, and that in itself is pretty interesting. Of course, this is meant to show that ideas in the English language do not always translate to well-defined mathematical concepts, but let&#8217;s ignore [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s <a href="http://en.wikipedia.org/wiki/Interesting_number_paradox">an old math paradox</a> that says that all natural numbers are interesting, since otherwise there would have to be a smallest uninteresting number, and that in itself is pretty interesting. Of course, this is meant to show that ideas in the English language do not always translate to well-defined mathematical concepts, but let&#8217;s ignore our better mathematical sense and tinker with the idea of how interesting different numbers are a little bit. In particular, I claim that 11630 is utterly bland and uninteresting.</p>
<h3>Why 11630?</h3>
<p>Before saying why 11630 is uninteresting, I should probably say what I consider &#8220;interesting&#8221; to even <em>mean</em>. Interesting, to me, means that it has some (semi-unique) mathematical property that sets it apart from other numbers. 11 is interesting because it is prime, 16 is interesting because it is a perfect power (16 = 4<sup>2</sup>), and so on. Clearly, there is some ambiguity in this definition, since one could consider composite numbers interesting, just as I considered prime numbers interesting. Additionally, do we consider 2719 interesting simply because it is prime? I&#8217;d say no, since there are hundreds of prime numbers that come before it &#8212; perhaps only the first few numbers that satisfy a given property should be considered interesting as a result of it?</p>
<p>Using these ideas, it seems like determining how interesting a number is would be a task perfectly suited to the <a href="http://www.research.att.com/~njas/sequences/">Online Encyclopedia of Integer sequences</a> (OEIS). If you&#8217;re unfamiliar with it (i.e., if you&#8217;re not a math person and have no place reading my blog), the OEIS is a database containing thousands of (you guessed it) integer sequences that have been submitted by users over the last decade or so (such as the sequence of prime numbers <a href="http://www.research.att.com/~njas/sequences/A000040">2, 3, 5, 7, 11,&#8230;</a> and the sequence of perfect powers <a href="http://www.research.att.com/~njas/sequences/A001597">1, 4, 8, 9, 16,&#8230;</a>). Presumably, if an integer is interesting then it will appear in at least one or two of the 159437 sequences contained in the database, right? Indeed, it seems that we can get a rough idea of how interesting a number is by looking at how many sequences that number appears in in the database compared to other numbers of similar size.</p>
<p>11630 is the first number that is not listed in a single sequence in the OEIS. It is not prime, nor is it highly composite (11630 = 2×5×1163). It doesn&#8217;t have any particularly notable residue properties, and it doesn&#8217;t come up in counting problems. It&#8217;s boring in every way, and it seems as though not a single mathematician has found a use for it in the last dozen or so years (let me know if you&#8217;ve discovered otherwise).</p>
<h3>What Numbers <em>are</em> Interesting?</h3>
<p>First off, I&#8217;m not going to deal with particularly small numbers (say in the range of 1 &#8211; 50) since, as the <a href="http://en.wikipedia.org/wiki/Strong_Law_of_Small_Numbers">strong law of small numbers</a> quips, these numbers will appear all over the place just because they&#8217;re small. You could probably argue that most (if not all) of them are interesting, so I&#8217;ll instead take a look at a couple larger numbers that are particularly interesting.</p>
<p>The number 421 appears in some 1894 sequences, while most numbers that size appear in about 940 sequences. This seems to indicate that 421 is a particularly interesting number, but why? What&#8217;s so special about 421? Well, it&#8217;s prime (in fact, it&#8217;s a <a href="http://www.research.att.com/~njas/sequences/A006512">twin prime</a>, <a href="http://www.research.att.com/~njas/sequences/A002144">Pythagorean prime</a>, <a href="http://www.research.att.com/~njas/sequences/A007645">cuban prime</a>, <a href="http://www.research.att.com/~njas/sequences/A005846">lucky number of Euler prime</a>, <a href="http://www.research.att.com/~njas/sequences/A046704">additive prime</a>, and <a href="http://www.research.att.com/~njas/sequences/A000928">irregular prime</a>), it&#8217;s congruent to 1 mod 2,3,4, 5, 6,7, 10, 12, it&#8217;s the sum of five primes, and 421<sup>2</sup> = 420<sup>2</sup> + 29<sup>2</sup>. Similarly, 512 appears in 2116 sequences even though most numbers around 512 appear in about 800 sequences. This is perhaps less surprising than 421, since 512 = 2<sup>9</sup> = 8<sup>3</sup> = 16<sup>2</sup> + 16<sup>2</sup> is a number that somehow seems &#8220;nice&#8221; due to it being a perfect power. Additionally, 512 is a <a href="http://www.research.att.com/~njas/sequences/A076980">Leyland number</a>, <a href="http://www.research.att.com/~njas/sequences/A005349">Harshad number</a>, and it comes up in <a href="http://www.research.att.com/~njas/sequences/A078436">all</a> <a href="http://www.research.att.com/~njas/sequences/A001523">sorts</a> <a href="http://www.research.att.com/~njas/sequences/A103314">of</a> <a href="http://www.research.att.com/~njas/sequences/A107848">counting</a> <a href="http://www.research.att.com/~njas/sequences/A120434">problems</a>.</p>
<h3>What of the Paradox?</h3>
<p>Recalling the paradox from earlier, we are now forced to ask ourselves whether or not 11630 is now interesting as a result of it being the first number not included in the OEIS. Rather than come up with an answer, I&#8217;m going to take the easy way out and let the OEIS decide. The sequence of uninteresting numbers is 11630, 12067, 12407, 12887, 13258, 13794, 13882, 13982, 14018, 14163,&#8230; Let&#8217;s submit that to the OEIS and see if they consider it to be interesting or not.</p>
<p><strong><span style="color: #800000;">Update [June 13, 2009]:</span></strong> I got word back via e-mail today that this sequence didn&#8217;t make the cut. So there you have it — these numbers truly are uninteresting.</p>
<p><strong><span style="color: #800000;">Update [November 12, 2009]:</span></strong> It looks like 11630 is now <a href="http://www.research.att.com/~njas/sequences/A163279">listed in the OEIS</a>. Additionally, 12067 was <a href="http://www.research.att.com/~njas/sequences/A163675">recently added</a>, meaning that 12407 is now the first uninteresting number.</p>
<p><strong>Downloads:</strong></p>
<ul>
<li><a href="http://www.nathanieljohnston.com/wp-content/uploads/2009/06/oeis-counts.xls">OEIS counts (1 &#8211; 50000)</a> [Excel spreadsheet — 6.81MB]</li>
<li><a href="http://www.nathanieljohnston.com/wp-content/uploads/2009/06/oeis-counts.txt">OEIS counts (1 &#8211; 50000)</a> [.txt — 444kB]</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nathanieljohnston.com/index.php/2009/06/11630-is-the-first-uninteresting-number/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Rectangular Oscillators in the 2&#215;2 (B36/S125) Cellular Automaton</title>
		<link>http://www.nathanieljohnston.com/index.php/2009/05/rectangular-oscillators-in-the-2x2-b36s125-cellular-automaton/</link>
		<comments>http://www.nathanieljohnston.com/index.php/2009/05/rectangular-oscillators-in-the-2x2-b36s125-cellular-automaton/#comments</comments>
		<pubDate>Fri, 22 May 2009 04:00:36 +0000</pubDate>
		<dc:creator>Nathaniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cellular automata]]></category>
		<category><![CDATA[Integer Sequences]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://www.nathanieljohnston.com/?p=267</guid>
		<description><![CDATA[One interesting Life-like cellular automaton, known as &#8220;2&#215;2&#8220;, is particularly abundant with frequently-occurring oscillators and has thus attracted some attention from Life enthusiasts over the years. The 2&#215;2 automaton takes place on a grid much like Conway&#8217;s Game of Life, but cells are born if they have exactly 3 or 6 neighbours, and they survive if [...]]]></description>
			<content:encoded><![CDATA[<p>One interesting Life-like cellular automaton, known as &#8220;<a href="http://www.conwaylife.com/wiki/index.php?title=2x2">2&#215;2</a>&#8220;, is particularly abundant with frequently-occurring oscillators and has thus attracted some attention from Life enthusiasts over the years. The 2&#215;2 automaton takes place on a grid much like <a href="http://www.conwaylife.com/wiki/index.php?title=Conway's_game_of_life">Conway&#8217;s Game of Life</a>, but cells are born if they have exactly 3 or 6 neighbours, and they survive if they have exactly 1, 2, or 5 neighbours (this behaviour is summarized by the rulestring &#8220;B36/S125&#8243;).</p>
<div id="attachment_268" class="wp-caption aligncenter" style="width: 223px"><a href="http://www.conwaylife.com/?p=2x2period2oscillators"><img class="size-full wp-image-268" title="2x2 oscillators" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/05/anim.gif" alt="Some small oscillators in B36/S125" width="213" height="73" /></a><p class="wp-caption-text">Some small period 2 oscillators in B36/S125</p></div>
<p>Take a look at the second oscillator from the left in the top row of the above image &#8212; it is a 2 × 4 rectangle that oscillates back and forth. The oscillators that I will be looking at in this post are rectangles like this; rectangles of sizes 2m × 2n such that m + n is odd (the reason for these restrictions on the sizes of the rectangles is simply that they aren&#8217;t oscillators otherwise (<span style="color: #ff0000;">not quite</span>, see the correction in <a href="http://www.nathanieljohnston.com/index.php/2009/05/rectangular-oscillators-in-the-2x2-b36s125-cellular-automaton/comment-page-1/#comment-1454">the comments</a>)). The next two smallest of these rectangular oscillators are shown here:</p>
<div id="attachment_269" class="wp-caption aligncenter" style="width: 235px"><a href="http://www.conwaylife.com/?p=2x2blockoscillators"><img class="size-full wp-image-269" title="2x2 block oscillators" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/05/anim1.gif" alt="Block oscillators in B36/S125" width="225" height="113" /></a><p class="wp-caption-text">Rectangular oscillators in B36/S125</p></div>
<p>As you can see, the oscillators behave a bit more unpredictably as their size increases. The question that I will answer now is <em>&#8220;What is the period of a 2m × 2n rectangular oscillator in the 2&#215;2 rule in terms of m and n?&#8221;</em></p>
<p>I will present the final answer right now, since it isn&#8217;t particularly simple: the period is 2<sup>k+1</sup> &#8211; 2, where k is the least natural number such that 2<sup>k</sup> = ± 1 mod (m + n). While this answer isn&#8217;t exactly pretty, the k values have at least already been computed up to m + n = 2001 (see Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A003558">A003558</a>), and there is at least some theory developed about them (see <a href="http://mathworld.wolfram.com/SuborderFunction.html">Suborder Function</a> at Mathworld).</p>
<p>It is perhaps worth noting that B36/S125 isn&#8217;t the only rule in which these oscillators work; it&#8217;s simply the most well-known. These rectangular oscillators behave the same in any rule from B3/S5 to B3678/S012567.</p>
<h3>Deriving the Answer</h3>
<p><em><strong>Disclaimer:</strong> The following contains much handwaving. It can be made rigorous, but I don&#8217;t particularly want to; the argument is long enough as it is, and this is recreational mathematics, after all.</em></p>
<p>Before proceeding, let&#8217;s make a simplification by noticing that a 2m × 2n rectangle is simply another phase of a 2 × 2(m + n &#8211; 1) rectangular oscillator. It is thus enough to consider 2 × 4n rectangular oscillators, where n is an integer.</p>
<p>The thing to notice about these oscillators is that, as described by Dean Hickerson in <a href="http://groups.google.tk/group/comp.theory.cell-automata/browse_frm/thread/b059a5fb0c796743/c5683380affb8068?lnk=gst&amp;q=2x2#c5683380affb8068">this thread</a>, each phase of these block oscillators can be described as an XOR of rectangles. For example, consider the following phase of one of the above oscillators:</p>
<div id="attachment_274" class="wp-caption aligncenter" style="width: 123px"><a href="http://www.conwaylife.com/?p=2x2blockoscillators"><img class="size-full wp-image-274" title="Rectangular oscillator phase" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/05/pattern_13_12.png" alt="2 × 12 XOR 6 × 8" width="113" height="65" /></a><p class="wp-caption-text">2 × 12 XOR 6 × 8</p></div>
<p>The above phase can be considered the XOR of a 2 × 12 rectangle and a 6 × 8 rectangle. Different phases may require a different number of rectangles to be XORed, but every phase can always be represented in this way. More important, however, is the fact that the evolution of the oscillators occurs in a very predictable way when modeled like this. Consider the following grid.<em> (Aside: you will likely recognize that it resembles very closely one half of the </em><a href="http://en.wikipedia.org/wiki/Sierpinski_triangle"><em>Sierpinski triangle</em></a><em>. This is no coincidence; it turns out that these oscillators are, in a sense, emulating the &#8220;</em><a href="http://mathworld.wolfram.com/Rule90.html"><em>Rule 90</em></a><em>&#8221; 1D cellular automaton.)</em></p>
<div id="attachment_281" class="wp-caption aligncenter" style="width: 259px"><img class="size-full wp-image-281" title="Sierpinski XOR Table" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/05/serp.png" alt="XOR table" width="249" height="249" /><p class="wp-caption-text">XOR grid</p></div>
<p>The way to read the above grid is that that row represents the current generation and the column represents the size of the rectangle that is being XORed (the first column represents a 2 × 4n rectangle, the second column represents a 4 × (4n &#8211; 2) rectangle, the third column represents a 6 × (4n &#8211; 4) rectangle, and so on). Thus, you &#8220;start&#8221; in the top-left cell, and that represents the 2 × 4n rectangle that you start with (in generation 0). To go to generation 1, go to the next row, where we see that the only filled in cell is in the second column, which is the 4 × (4n &#8211; 2) column. Thus, the first generation will just be a filled-in 4 × (4n &#8211; 2) rectangle. To see what generation 2 will look like, go to the next row, where we see that two cells are filled in, corresponding to 2 × 4n and 6 × (4n &#8211; 4) rectangles. Thus, XOR together two rectangles of those sizes (in the sense described earlier) to get what generation 2 must look like.</p>
<p>The key to determining the oscillators&#8217; periods comes from realizing that if we continue to label the columns in the way I described, eventually we hit zero-length rectangles, which doesn&#8217;t make a whole lot of sense. Thus, we simply do not XOR any of those rectangles that are of length zero. But what about rectangles of negative length? Instead of counting down into negative numbers, start counting back up. This is probably easiest to illustrate with an example, so I&#8217;ll use the n = 3 case.</p>
<div id="attachment_283" class="wp-caption aligncenter" style="width: 259px"><img class="size-full wp-image-283" title="serp1" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/05/serp1.png" alt="Coloured XOR grid (n = 3)" width="249" height="249" /><p class="wp-caption-text">Coloured XOR grid (n = 3)</p></div>
<p>Red columns represent 2 × 12, orange represent 4 × 10, yellow represent 6 × 8, green represent 8 × 6, blue represent 10 × 4, purple represent 12 × 2, and grey represent zero-width rectangles that can be ignored. Thus, we see that (for example), in generation 9 (row 10), there is a puple and a green and so the oscillator will look like a 12 × 2 rectangle XORed with an 8 × 6 rectangle.</p>
<p>The period can be determined by grids of this type by going down the rows, looking for the first row (after row 1) that has an odd number of red cells filled in (so that after XORing, a 2 × 4n rectangle will be present) and an even number of each other colour besides grey (so that after XORing, no rectangles of other sizes will be present). It can be shown that the first time this occurs must be at the bottom of one the triangles that reaches all the way to the left (so in row 3, 7, 15, 31, and so on). This corresponds to the oscillators always having period that is equal to 2<sup>k</sup> &#8211; 2, where k is some integer. To determine what that integer is, notice that if one of these oscillators starts off as a 2 × 4n rectangle, then it will appear rotated 90 degrees as a 4n × 2 rectangle halfway through its period. Thus, we need the least k such that row 2<sup>k-1</sup> contains a single purple cell (i.e., 2<sup>k-1</sup> = ± 1 mod (2n + 1)).</p>
<p>By transforming back to 2m × 2n rectangles and shifting around k a little bit, we see that the period is 2<sup>k+1</sup> &#8211; 2, where k is the least integer such that 2<sup>k</sup> = ± 1 mod (m + n).</p>
<p>Thus, using Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A003558">A003558</a> as our guide, we see that the period of a 2m × 2n rectangle for m + n = 3, 5, 7, 9, &#8230; is 2, 6, 14, 14, 62, 126, 30, 30, 1022, &#8230;</p>
<p><strong><span style="color: #800000;">Update [May 28, 2009]:</span></strong> This sequence is now listed in the OEIS as Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A160657">A160657</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nathanieljohnston.com/index.php/2009/05/rectangular-oscillators-in-the-2x2-b36s125-cellular-automaton/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>On Maximal Self-Avoiding Walks</title>
		<link>http://www.nathanieljohnston.com/index.php/2009/05/on-maximal-self-avoiding-walks/</link>
		<comments>http://www.nathanieljohnston.com/index.php/2009/05/on-maximal-self-avoiding-walks/#comments</comments>
		<pubDate>Tue, 05 May 2009 15:18:06 +0000</pubDate>
		<dc:creator>Nathaniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Graph Theory]]></category>
		<category><![CDATA[Integer Sequences]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://www.nathanieljohnston.com/?p=182</guid>
		<description><![CDATA[Given a k × n grid, a self-avoiding walk (SAW) on that grid is a connected path that never touches the same square more than once and never doubles back on itself (note that some sources make the convention that the path is drawn on the edges of the grid from vertex to vertex, but [...]]]></description>
			<content:encoded><![CDATA[<p class="paragraph_text">Given a <span class="math_inline">k × n</span> grid, a self-avoiding walk (SAW) on that grid is a connected path that never touches the same square more than once and never doubles back on itself (note that some sources make the convention that the path is drawn on the edges of the grid from vertex to vertex, but here I will make the convention that the path connects the centres of the squares that the grid forms). I will define a <em>maximal</em> self-avoiding walk to be a self-avoiding walk that touches every square of the grid on which it resides. One natural question that we can ask in this setting is <em>&#8220;How many maximal self-avoiding walks are there on a <span class="math_inline">k × n</span> grid?&#8221;</em></p>
<p><img class="alignright" src="http://www.nathanieljohnston.com/NJimages/math_sa_walks_1.gif" alt="(In)valid self-avoiding walks" width="206" height="120" align="top" /></p>
<p class="paragraph_text">Before proceeding, let&#8217;s simplify things slightly by making the restriction that the maximal self-avoiding walks must start in the bottom-l<span style="font-family: Verdana;"><span style="font-family: Georgia;">eft corner of the grid (this restriction leaves us with the walks that are known as &#8220;Greek-key tours&#8221;). Let <span class="math_inline">f(k, n)</span> denote the number of maximal self-avoiding walks on a <span class="math_inline">k × n</span> grid. Unfortunately, finding an expression for <span class="math_inline">f(k, n)</span> in complete generality seems to be out of reach, so we will instead try to answer the question for certain fixed values of <span class="math_inline">k</span>.</span></span></p>
<p class="paragraph_text"><strong><span style="text-decoration: underline;">Case 1: <span class="math_inline">k = 1</span></span></strong><br />
Regardless of <span class="math_inline">n</span>, there is clearly only one maximal self-avoiding walk in this case: a straight line. Thus, <span class="math_inline">f(1, n) = 1</span> regardless of the value of <span class="math_inline">n</span>.</p>
<p class="paragraph_text"><strong><span style="text-decoration: underline;">Case 2: <span class="math_inline">k = 2</span></span></strong><br />
It is not difficult to prove (by induction, for example) that <span class="math_inline">f(2, n) = n</span>.</p>
<p class="paragraph_text"><strong><span style="text-decoration: underline;">Case 3: <span class="math_inline">k = 3</span></span></strong><br />
This is the first case whose solution does not seem trivial. It is well-known (by people who have looked at this problem, anyways) that the number of maximal self-avoiding walks on a <span class="math_inline">3 × n</span> grid for <span class="math_inline">n = 1, 2, &#8230;</span> is <span class="math_inline">1, 3, 8, 17, 38, &#8230;</span> (Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A046994" target="_sloane">A046994</a>). This sequence is defined by the following recurrence relations:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://www.nathanieljohnston.com/NJimages/math_sa_walks_2.gif" alt="f(3,1) = 1 \\ f(3,2m) = 3 \cdot 2^{m-1} + \sum_{i=2}^{2m-1}{ f(3,i) } \text{, for } m = 1, 2, \ldots \\ f(3,2m + 1) =  5\cdot 2^{m-1} + \sum_{i=2}^{2m}{ f(3,i) } \text{, for } m = 1, 2, \ldots" width="381" height="138" /></p>
<p>Well, from these recurrence relations we can derive the following closed form expression for <span class="math_inline">f(3, n)</span>:</p>
<p><img class="aligncenter" src="http://www.nathanieljohnston.com/NJimages/math_sa_walks_3.gif" alt="f(3,n) = 11 \cdot 2^{n-3} - \left( 4 + \left( -1 \right)^n \right)\left( 2^{\left( \frac{2n - 7 - (-1)^n}{4} \right)} \right) \text{, for } n \geq 2" /></p>
<p class="paragraph_text">It may be worth noting that this formula can be simplified significantly if you consider the case when <span class="math_inline">n</span> is odd separately from the case when <span class="math_inline">n</span> is even, and write <span class="math_inline">f(3, n)</span> as a branch function.</p>
<p class="paragraph_text"><strong><span style="text-decoration: underline;">Case 4: <span class="math_inline">k = 4</span></span></strong><br />
The number of maximal self-avoiding walks on a <span class="math_inline">4 × n</span> grid for <span class="math_inline">n = 1, 2, &#8230;</span> is <span class="math_inline">1, 4, 17, 52, 160, &#8230;</span> (Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A046995" target="_sloane">A046995</a>), but to date no simple closed-form formula for <span class="math_inline">f(4, n)</span> has been found. In 2003, Dean Hickerson proposed the following recurrence relation to define <span class="math_inline">f(4, n)</span>, which holds at least for the first 25 terms of the sequence:</p>
<p><img class="aligncenter" src="http://www.nathanieljohnston.com/NJimages/math_sa_walks_4.gif" alt="f(4,1) = 1 \\ f(4,2) = 4 \\ f(4,3) = 17 \\ f(4,4) = 52 \\ f(4,5) = 160 \\ f(4,6) = 469 \\ f(4,7) = 1337 \\ f(4,8) = 3750 \\ f(4,9) = 10347 \\ f(4,m) = 3f(4,m-1) + 3f(4,m-2) - 9f(4,m-3) - 6f(4,m-4) + 5f(4,m-5) + f(4,m-6) - 3f(4,m-7) + f(4,m-8) \text{, for } m = 10, 11, 12, \ldots" /></p>
<p class="paragraph_text">While it is possible to derive a closed-form formula for <span class="math_inline">f(4, n)</span> from the above recurrence relation using standard difference equation techniques, the formula is extremely long and cumbersome. One piece of information that we can extract from the closed-form formula (which I won&#8217;t write out here) is that <span class="math_inline">f(4, n) ∈ O(2.539<sup>n</sup>)</span>.</p>
<p class="paragraph_text"><strong><span style="text-decoration: underline;">Case 5: <span class="math_inline">k ≥ 5</span></span></strong><br />
It is now clear that this problem grows very large very quickly, and proceeding in this manner may not be (realistically) feasible. Not much is known about <span class="math_inline">f(k, n)</span> when both <span class="math_inline">k</span> and <span class="math_inline">n</span> are greater than or equal to <span class="math_inline">5</span>. The best approach in this case is likely that of brute force.</p>
<p class="paragraph_text">
<h3>Computing the Number of Maximal SAWs</h3>
<p>Here I provide two programs for computing the number of maximal SAWs on a grid of your chosen size. It is recommended that you use the C script rather than the Visual Basic program, as the C script is <em>much</em> faster.</p>
<p class="paragraph_text">If the Visual Basic file below gives you an error message when you try to run it, you may need to download and install the Visual Basic 6.0 run time files. <a href="http://www.nathanieljohnston.com/software/vbrun60sp5.exe">Click here</a> to download these files. As far as I know, this program should work on Windows 98, ME, 2000, XP and Vista, but I can&#8217;t make any guarantees about its compatability.</p>
<p><strong>Download:</strong></p>
<ul>
<li><a href="http://www.nathanieljohnston.com/software/MaxSAWCalc.exe">Maximal SAW Calculator in Visual Basic</a> [Windows exe — 28.0kB]</li>
<li><a href="http://www.nathanieljohnston.com/wp-content/uploads/2009/05/maxsawcalc1.exe">Maximal SAW Calculator in C</a> [Windows exe — 17.6kB]</li>
<li><a href="http://www.nathanieljohnston.com/wp-content/uploads/2009/05/maxsawcalc1.zip">Maximal SAW Calculator in C source code</a> [zip — 1.06kB]</li>
</ul>
<h3>Maximal SAW Table of Values</h3>
<p>This is a table giving the number of maximal SAWs on a <span class="math_inline">k × n</span> grid. Several of the values in the table below were calculated using the above software — the cells that have &#8220;<em>?</em>&#8221; in them correspond to values that are currently unknown due to computational limits. Note that there is trivially symmetry across the main diagonal of the table. I apologize for the unreadably small font.</p>
<table style="font-size:5.5pt;" border="0">
<tbody>
<tr>
<td style="border-bottom:3px double #000000;border-right:3px double #000000;font-size:8pt;" align="center"><strong><sub>k</sub>\<sup>n</sup></strong></td>
<td style="border-bottom:3px double #000000;border-top:1px solid #000000;border-right:1px solid #888888;font-size:8pt;" align="center"><strong><strong>1</strong></strong></td>
<td style="border-right:1px solid #888888;border-bottom:3px double #000000;border-top:1px solid #000000;font-size:8pt;" align="center"><strong><strong>2</strong></strong></td>
<td style="border-right:1px solid #888888;border-bottom:3px double #000000;border-top:1px solid #000000;font-size:8pt;" align="center"><strong><strong>3</strong></strong></td>
<td style="border-right:1px solid #888888;border-bottom:3px double #000000;border-top:1px solid #000000;font-size:8pt;" align="center"><strong><strong>4</strong></strong></td>
<td style="border-right:1px solid #888888;border-bottom:3px double #000000;border-top:1px solid #000000;font-size:8pt;" align="center"><strong><strong>5</strong></strong></td>
<td style="border-right:1px solid #888888;border-bottom:3px double #000000;border-top:1px solid #000000;font-size:8pt;" align="center"><strong><strong>6</strong></strong></td>
<td style="border-right:1px solid #888888;border-bottom:3px double #000000;border-top:1px solid #000000;font-size:8pt;" align="center"><strong><strong>7</strong></strong></td>
<td style="border-right:1px solid #888888;border-bottom:3px double #000000;border-top:1px solid #000000;font-size:8pt;" align="center"><strong><strong>8</strong></strong></td>
<td style="border-right:1px solid #888888;border-bottom:3px double #000000;border-top:1px solid #000000;font-size:8pt;" align="center"><strong><strong>9</strong></strong></td>
<td style="border-bottom:3px double #000000;border-top:1px solid #000000;border-right:1px solid #888888;font-size:8pt;" align="center"><strong><strong>10</strong></strong></td>
<td style="border-bottom:3px double #000000;border-top:1px solid #000000;border-right:1px solid #000000;font-size:8pt;" align="center"><strong><strong>General Term</strong></strong></td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>1</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>2</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">2</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">3</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">4</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">5</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">6</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">7</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">8</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">9</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">10</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">n</td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>3</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">3</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">8</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">17</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">38</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">78</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">164</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">332</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">680</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1368</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A046994" target="_new">A046994</a></td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>4</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">4</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">17</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">52</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">160</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">469</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1337</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">3750</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">10347</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">28249</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A046995" target="_new">A046995</a></td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>5</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">5</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">38</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">160</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">824</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">3501</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">16262</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">68591</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">304177</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1276805</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A145156" target="_new">A145156</a></td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>6</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">6</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">78</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">469</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">3501</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">22144</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">144476</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">899432</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">5585508</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">34092855</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A160240" target="_new">A160240</a></td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>7</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">7</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">164</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1337</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">16262</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">144476</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1510446</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">13506023</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">132712481</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1185979605</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A160241" target="_new">A160241</a></td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>8</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">8</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">332</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">3750</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">68591</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">899432</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">13506023</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">180160012</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #888888;font-size:8pt;" align="center"><strong>9</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">9</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">680</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">10347</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">304177</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">5585508</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">132712481</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
</tr>
<tr>
<td style="border-right:3px double #000000;border-left:1px solid #000000;border-bottom:1px solid #000000;font-size:8pt;" align="center"><strong>10</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">10</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1368</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">28249</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1276805</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">34092855</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">1185979605</td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center"><em>?</em></td>
</tr>
<tr>
<td style="border-right:1px solid #888888;" colspan="10"></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;font-size:8pt;" align="right"><strong>n × n grid:</strong></td>
<td style="border-bottom:1px solid #888888;border-right:1px solid #888888;" align="center">Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A145157" target="_new">A145157</a></td>
</tr>
</tbody>
</table>
<p><span class="sub_header_text"><strong>Related Links:</strong></span></p>
<ul>
<li><a href="http://mathforum.org/kb/message.jspa?messageID=174703" target="_new"><strong>&#8216;Greek-key&#8217; tours on 3 × n chessboards</strong></a> — A mathforum.org posting by Thomas Womack in April 1999 about maximal SAWs.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nathanieljohnston.com/index.php/2009/05/on-maximal-self-avoiding-walks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Counting Lakes</title>
		<link>http://www.nathanieljohnston.com/index.php/2009/02/counting-lakes/</link>
		<comments>http://www.nathanieljohnston.com/index.php/2009/02/counting-lakes/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 00:00:52 +0000</pubDate>
		<dc:creator>Nathaniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Conway's Game of Life]]></category>
		<category><![CDATA[Integer Sequences]]></category>

		<guid isPermaLink="false">http://www.nathanieljohnston.com/?p=74</guid>
		<description><![CDATA[In Conway&#8217;s Game of Life, a lake is a pattern that is a simple closed loop made up of diagonally-adjacent dominoes. It is a fact that lakes are always still lifes and that their number of cells is always a multiple of eight, but no one seems to have calculated the number of distinct (ie. [...]]]></description>
			<content:encoded><![CDATA[<p>In Conway&#8217;s Game of Life, a <a href="http://www.conwaylife.com/wiki/index.php?title=Lake" target="_new">lake</a> is a pattern that is a simple closed loop made up of diagonally-adjacent dominoes. It is a fact that lakes are always <a href="http://www.conwaylife.com/wiki/index.php?title=Still_life" target="_new">still lifes</a> and that their number of cells is always a multiple of eight, but no one seems to have calculated the number of distinct (ie. not the same under rotation or reflection) lakes that exist on 8n cells; possibly because it&#8217;s not a particularly interesting problem (blasphemy!) or possibly because it&#8217;s a rather difficult problem (or most likely a combination of the two).</p>
<p>Indeed, computing an explicit formula for the number of lakes on 8n cells seems to be nigh intractable (although <a href="http://www.conwaylife.com/forums/viewtopic.php?f=7&amp;t=12" target="_new">some people</a> disagree). In place of an explicit formula I have simply gone the computer science route and coded a little C program to do the counting. The program&#8217;s running time is somewhere in the area of O(4<sup>n</sup>) since it basically brute-forces the solution by noting that lakes are in 1-1 correspondence with walks on a 2D lattice that have three properties: 1) they turn 90 degrees after each step of length one, 2) they eventually return to the starting position, and 3) they never cross a grid point that they&#8217;d previously visited (except on the last step when they return to the start).</p>
<p>The sequence (as far as I have computed it) of the number of lakes on 8n cells for <span class="math_inline">n = 1, 2, 3, &#8230;</span> is <span class="math_inline">1, 0, 1, 1, 4, 7, 31, 98, 446, 1894, 9049, 43151<span class="math_inline"> &#8230; (Sloane&#8217;s <a href="http://www.research.att.com/~njas/sequences/A156228">A156228</a>).</span> The C source code is provided below in case you&#8217;re interested.</span></p>
<p><strong>Download:</strong></p>
<ul style="text-align: left;">
<li>C source code (zip file): <a href="http://www.nathanieljohnston.com/scripts/numLakes.zip">numLakes.zip</a> (1.48kB)</li>
<li>C source code (plaintext): <a href="http://www.nathanieljohnston.com/scripts/numLakes.txt">numLakes.txt</a></li>
</ul>
<p><strong>The two smallest lakes, </strong><a href="http://www.conwaylife.com/wiki/index.php?title=Pond" target="_new"><strong>pond </strong></a><strong>and </strong><a href="http://www.conwaylife.com/wiki/index.php?title=Lake_2" target="_new"><strong>lake 2</strong></a><strong>:</strong></p>
<p><a href="http://www.conwaylife.com/wiki/index.php?title=Pond"><img style="margin-left: 24px; margin-right: 24px; border: 0px initial initial;" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/02/pond.png" border="0" alt="" width="97" height="97" /></a><a href="http://www.conwaylife.com/wiki/index.php?title=Lake_2"><img style="border: 0px initial initial;" src="http://www.nathanieljohnston.com/wp-content/uploads/2009/02/lake2.png" border="0" alt="" width="97" height="97" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nathanieljohnston.com/index.php/2009/02/counting-lakes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
