<?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>Programmer Luddite &#187; math</title>
	<atom:link href="https://programmerluddite.com/category/math/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmerluddite.com</link>
	<description>The Blog of Barney Boisvert, Software Craftsman</description>
	<lastBuildDate>Tue, 26 Apr 2022 13:20:50 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>Domino Functions</title>
		<link>https://programmerluddite.com/2013/04/domino-functions/</link>
		<comments>https://programmerluddite.com/2013/04/domino-functions/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 20:39:34 +0000</pubDate>
		<dc:creator><![CDATA[barneyb]]></dc:creator>
				<category><![CDATA[math]]></category>

		<guid isPermaLink="false">http://programmerluddite.com/?p=69</guid>
		<description><![CDATA[At Gram and Gramp&#8217;s this weekend we played dominos, and the question came up of counting a set of dominos.  In particular, Gramps wanted to know how many dominos there were in a set with double twelves. After we were &#8230; <a href="https://programmerluddite.com/2013/04/domino-functions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>At Gram and Gramp&#8217;s this weekend we played dominos, and the question came up of counting a set of dominos.  In particular, Gramps wanted to know how many dominos there were in a set with double twelves.</p>
<p>After we were done playing, we lined them all up in the &#8220;domino triangle&#8221; with and Emery and I figured it out.    The domino triangle is simply an arrangement of dominos with double zero in one corner, the zero-one next to it, followed by zero-two (etc.), and with the double one at the end, followed by the double two (etc.).  Here is a partial rendering of the triangle for our double nine set:</p>
<pre>+-+   +-+         +-+
|0|   |0|         |0|
+-+   +-+   ...   +-+
|0|   |1|         |9|
+-+   +-+         +-+

+-+         +-+
|1|         |1|
+-+   ...   +-+
|1|         |9|
+-+         +-+

...

+-+
|9|
+-+
|9|
+-+</pre>
<p>To start, let <img src='http://s.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' /> equal the number of the largest double (twelve, if our case).  We&#8217;re looking for <img src='http://s.wordpress.com/latex.php?latex=f%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='f(n)' title='f(n)' class='latex' />, which is the number of dominos in a set with largest double <img src='http://s.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' />.  Simply counting the dominos in the triangle gives us a values for our function, but not the one we want:</p>
<pre>  n  | f(n)
-----+-------
  0  |   1
  6  |  28
  9  |  55
 12  |  ??</pre>
<p>Before dealing with <img src='http://s.wordpress.com/latex.php?latex=f%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='f(n)' title='f(n)' class='latex' />, let <img src='http://s.wordpress.com/latex.php?latex=g%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g(n)' title='g(n)' class='latex' /> denote the number of doubles in the set.  A quick glance at the triangle will show that the formula for this function is</p>
<img src='http://s.wordpress.com/latex.php?latex=g%28n%29%3Dn%2B1&#038;bg=ffffff&#038;fg=333333&#038;s=1' alt='g(n)=n+1' title='g(n)=n+1' class='latex block' />
<p>because there is one double for each</p>
<img src='http://s.wordpress.com/latex.php?latex=%5B0%2C%20n%5D%20%3D%20%5C%7Bx%20%5Cin%20%5Cmathbb%7BN%7D%20%5C%2C%7C%5C%2C0%20%5Cle%20x%20%5Cle%20n%5C%7D&#038;bg=ffffff&#038;fg=333333&#038;s=1' alt='[0, n] = \{x \in \mathbb{N} \,|\,0 \le x \le n\}' title='[0, n] = \{x \in \mathbb{N} \,|\,0 \le x \le n\}' class='latex block' />
<p>Now thinking back to the &#8220;domino triangle&#8221;, it&#8217;s easy to see that <img src='http://s.wordpress.com/latex.php?latex=g%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g(n)' title='g(n)' class='latex' /> is both the width (base) and the height of the triangle.  If you recall from planar geometry, the area of a triangle is half it&#8217;s base times height:</p>
<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7Bbase%20%5Ctimes%20height%7D%7B2%7D&#038;bg=ffffff&#038;fg=333333&#038;s=2' alt='\frac{base \times height}{2}' title='\frac{base \times height}{2}' class='latex block' />
<p>So a first guess at <img src='http://s.wordpress.com/latex.php?latex=f%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='f(n)' title='f(n)' class='latex' /> would be this:</p>
<img src='http://s.wordpress.com/latex.php?latex=f%28n%29%3D%5Cfrac%7B%28g%28n%29%29%5E2%7D%7B2%7D&#038;bg=ffffff&#038;fg=333333&#038;s=2' alt='f(n)=\frac{(g(n))^2}{2}' title='f(n)=\frac{(g(n))^2}{2}' class='latex block' />
<p>But that isn&#8217;t correct.  Thinking back to the domino triangle quickly shows why.  If you were to take two copies of the triangle to make a rectangle (the reason the triangle area formula works), you&#8217;d see that you&#8217;d have to offset them by one domino in one direction, so the rectangle is actually <img src='http://s.wordpress.com/latex.php?latex=g%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g(n)' title='g(n)' class='latex' /> by <img src='http://s.wordpress.com/latex.php?latex=g%28n%29%20%2B%201&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g(n) + 1' title='g(n) + 1' class='latex' />.  So the right formula is this:</p>
<img src='http://s.wordpress.com/latex.php?latex=f%28n%29%3D%5Cfrac%7Bg%28n%29%5C%2C%28g%28n%29%20%2B%201%29%7D%7B2%7D&#038;bg=ffffff&#038;fg=333333&#038;s=2' alt='f(n)=\frac{g(n)\,(g(n) + 1)}{2}' title='f(n)=\frac{g(n)\,(g(n) + 1)}{2}' class='latex block' />
<p>Simplifying by inlining the formula for <img src='http://s.wordpress.com/latex.php?latex=g%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g(n)' title='g(n)' class='latex' /> yields:</p>
<img src='http://s.wordpress.com/latex.php?latex=f%28n%29%3D%5Cfrac%7B%28n%20%2B%201%29%28n%20%2B%202%29%7D%7B2%7D&#038;bg=ffffff&#038;fg=333333&#038;s=2' alt='f(n)=\frac{(n + 1)(n + 2)}{2}' title='f(n)=\frac{(n + 1)(n + 2)}{2}' class='latex block' />
<p>This turns out to be the correct formula, and yields 91 when its argument is twelve.  Thus a set of double twelve dominos will have 91 dominos.</p>
<p>What was particularly striking as Emery and I worked through the formulas, is that Emery had more trouble with the larger multiplication (which he hasn&#8217;t done in school) than following the function notation, doing the step-wise evaluation of the functions, and even the function nesting.</p>
]]></content:encoded>
			<wfw:commentRss>https://programmerluddite.com/2013/04/domino-functions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
