<?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>The Flickering Tubelight &#187; Tidbits</title>
	<atom:link href="http://flickeringtubelight.net/blog/category/tidbits/feed/" rel="self" type="application/rss+xml" />
	<link>http://flickeringtubelight.net/blog</link>
	<description></description>
	<lastBuildDate>Sat, 05 Feb 2011 02:30:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A simple problem that led us to Ramanujan&#8217;s work on Integer Partitioning</title>
		<link>http://flickeringtubelight.net/blog/2010/09/a-simple-problem-that-led-us-to-ramanujans-work-on-integer-partitioning/</link>
		<comments>http://flickeringtubelight.net/blog/2010/09/a-simple-problem-that-led-us-to-ramanujans-work-on-integer-partitioning/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 14:12:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Family]]></category>
		<category><![CDATA[Tidbits]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/?p=182</guid>
		<description><![CDATA[Raghu, my cousin, sent me an email with the following problem a few months ago.
Question
Manish was on his way to an interview. On the way, he encountered his long lost cousin, Vijay, whom he hadn&#8217;t met in more than a decade. They started catching up on lost time. Manish learned that Vijay had 3 sons. [...]]]></description>
			<content:encoded><![CDATA[<p>Raghu, my cousin, sent me an email with the following problem a few months ago.</p>
<h2>Question</h2>
<p>Manish was on his way to an interview. On the way, he encountered his long lost cousin, Vijay, whom he hadn&#8217;t met in more than a decade. They started catching up on lost time. Manish learned that Vijay had 3 sons. When he asked about their ages, Vijay replied, &#8220;You&#8217;re going for an interview, right? Consider this a trial question. Figure out their ages from this: The product of the ages of my three sons is 36.&#8221; To this, Manish grumbled that he needed more information. Vijay, then, pointed to a sign board across the street that displayed the address of the area and said that the sum of the ages of his three children was equal to the last two digits of the <span id="lw_1255020725_0" class="yshortcuts">pin code (zip code)</span> of that area. Manish demanded still more information. Finally, Vijay said, &#8220;My eldest son wore a black shirt today. This is all I can tell you.&#8221;</p>
<p>What were the ages of the three children?<span id="more-182"></span></p>
<h2>Solution</h2>
<p>Say the ages are a, b and c. We know from clue 1 that a.b.c = 36, where &#8220;.&#8221; represents multiplication. First step in identifying such factors is to factorize 36 into its smallest factors &#8211; 1.2.2.3.3. The next step is to figure out how to group these 5 numbers into 3 groups. Note that we can have more 1s in the factorization. For example, what if 2 kids are 1 year old and 1 &#8220;kid&#8221; is 36 years old? So, to allow that to happen, we need another 1 in the factors. So the factors are 1.1.2.2.3.3. By trial and error, we recognize that the way to make 3 groups from 6 objects is by making groups of:</p>
<p>1 + 1 + 4 (call it Grouping Style 1, or GS1)</p>
<p>1 + 2 + 3 (call it Grouping Style 2, or GS2)</p>
<p>and 2 + 2 + 2 (call it Grouping Style 3, or GS3)</p>
<p>GS1 requires selecting 1 out of 6 for the first component, 1 out of remaining 5 for the second component and the remaining 4 automatically go into the third component. There are 6 ways to choose the first component, 5 ways to choose the second component and 1 way to chose the third component. This gives us a total of 6.5=30 combinations for GS1. Many of these will turn out to be identical. After some work, we can whittle down the GS1 groupings to the following:</p>
<p>1,1,36</p>
<p>1,2,18</p>
<p>1,3,12</p>
<p>2,2,9</p>
<p>2,3,6</p>
<p>3,3,4</p>
<p>GS2 requires selecting 1 out of 6 for the first component, 2 out of 5 for the second component and the remaining 3 automatically go into the third component. There are 6 ways to choose the first component, 5C2 = 10 ways to choose the second component, and 1 way to choose the third component. This gives us a total of 6.10=60 combinations for GS2. In reality it is easier to work it out by trial and error. After some work, and after recognizing and ignoring the combinations that we have already seen under GS1, we can whittle down the GS2 groupings to the following:</p>
<p>1,4,9</p>
<p>1,6,6</p>
<p>Similar analysis for GS3 gives us no new combinations.</p>
<p>Before we can use clue 2, we need to add up the ages in these combinations. Doing so, we get the following:</p>
<p>1+1+36=38</p>
<p>1+2+18=21</p>
<p>1+3+12=16</p>
<p>2+2+9=13</p>
<p>2+3+6=11</p>
<p>3+3+4=10</p>
<p>1+4+9=14</p>
<p>1+6+6=13</p>
<p>Notice that all the combinations give us unique totals, except for two combinations which both give us 13. The fact that the second clue did not suffice to answer the question indicates that the total of the ages must have been 13. The children could be aged (2,2 and 9) or (1,6 and 6). Any other value for the total age and the answer would have been clear after clue 2.</p>
<p>Clue 3 tells us of the existence of an eldest child. The color of the shirt is immaterial. In the (1,6 and 6) combination, there is no eldest child. There are 2 elder children, who are twins. In the (2,2 and 9) combination, there is an eldest child. Hence, that is the answer. The children are aged 2 years, 2 years and 9 years.</p>
<h2>Intersecting Ramanujan&#8217;s trail</h2>
<p>With the specific problem out of the way, let us think about a generalization to the problem. India&#8217;s best known mathematician, Srinivasa Ramanujan, hiked (given his genius, he probably breezed) along a mathematical thought process, probably in 1913, leading to his work on Integer Partitions. In attempting to solve this problem, I seem to have unknowingly stepped onto this trail briefly. Let me explain. Remember that we had to figure out how many ways could 6 objects be grouped into 3 groups. I listed these out as groupings with (1,1,4), (1,2,3) and (2,2,2) objects. There are 3 grouping styles possible, no more, no less. But as the number of total objects grows larger, or the number of groups to create changes, the number of such grouping styles are harder to figure out. At least they seem to follow no simple pattern. For example, to group 6 objects into 2 groups, there are also 3 ways &#8211; {5,1}, {4,2} and {3,3}. To group 7 objects into 2 groups, there are only 3 groupings &#8211; {6,1} and {5,2} and {4,3}. To group 7 objects into 3 groups, however, there are 4 groupings &#8211; {1,1,5}, {1,2,4}, {1,3,3}, and {2,2,3}.</p>
<p>The question is, is there a more general formula to figure this (the number of distinct ways to group N objects into G groups) out? And another question is &#8211; what is Integer Partitioning and how is that related to this problem?</p>
<p>So before going into the theory, let us try to do look at this problem from different angles, and we may see an opening to solving it. Let us use the following example &#8211; find the number of ways of grouping 7 objects into 2 groups. We discovered (through some mental enumerations, I admit) that there are three grouping styles &#8211; {6,1}, {5,2}, {4,3} &#8211; possible here. But now, let me draw your attention to a simple fact &#8211; notice that the sum of the numbers each of the groupings is equal to 7. Hardly a surprise, you say. There were 7 objects to begin with. And regardless of how we group them, the total object count is 7. Big deal! But it is often rewarding to look at problems from a different perspective. We now know that &#8220;grouping 7 objects into 2 groups&#8221; is essentially the same as &#8220;finding 2 positive integers that add up to 7&#8243;. How many ways are there to add up 2 positive integers to get a total of 7? 6+1=7 and 5+2=7 and 4+3=7. No more ways to do it. So, the number of ways to group N things into G groups is equal to the number of ways to add G positive integers to make N. Allow me create a short hand notation to identify this count. I will use P(N,G). P for partition, but really you can use any symbol. I think it only makes sense when N&gt;=G. Otherwise P(N,G)=0.</p>
<p>P(N,G) = number of ways to add G positive integers to make N = numbers of ways to divide N objects into G groups</p>
<p>There are a couple of simple properties of P(N,G) which are easy to observe. There is only 1 way to divide N objects into N groups, and that is to assign 1 object per group. Similarly there is 1 way to divide N objects into 1 group, and that is to place all objects into 1 group. Symbolically,</p>
<p>P(N,N) = 1</p>
<p>P(N, 1) = 1</p>
<p>OK, I think we have beaten that one into submission (if not to death).</p>
<p>Note that we have only defined it. We we after a general formula for P(N,G). And we do not have that yet.</p>
<p>Now, let us visualize this slightly differently, meditate upon it a bit, and see if we can uncover some other properties about P(N,G). The following figure shows the objects, and groupings, visually. This style of representation, called, Ferrers Diagrams, uses one dot for one object. And it arranges the dots in each group along a <em>column</em>. There are 3 groupings shown &#8211; these are our friends {6,1}, {5,2} and {4, 3}. If we stare at this for some time we realize that the reason there are 2 columns is because we wanted 2 groups. This means there is at least 1 <em>row</em>, the first row, which has 2 dots in each of the groupings. Now, imagine that we remove those two dots from each of the groupings. What are we left with?</p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2010/09/IntegerPartitioning1.png"><img class="alignnone size-medium wp-image-660" title="IntegerPartitioning1" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/09/IntegerPartitioning1-299x174.png" alt="" width="299" height="174" /></a></p>
<p>The figure below shows the case where the 2 dots in the first row are removed. We are left with 5 dots. But more importantly notice the groupings that are left. {5}, {4,1} and {3,2}. These are some of the ways you can group 5 objects. This time, we do not necessarily group 5 objects into 2 groups &#8211; since we have a grouping, {5}, with only 1 group. It may be interesting to see how many ways there are in all to group 5 objects &#8211; not necessarily into 1 or 2 groups, but rather into <em>any</em> number of groups.</p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2010/09/IntegerPartitioning2.png"><img class="alignnone size-medium wp-image-661" title="IntegerPartitioning2" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/09/IntegerPartitioning2-299x168.png" alt="" width="299" height="168" /></a></p>
<p>The following figure shows <em>all</em> the ways to group 5 objects.</p>
<p>1 group &#8211; {5}</p>
<p>2 groups &#8211; {4,1}, {3,2}</p>
<p>3 groups &#8211; {3,1,1}, {2,2,1}</p>
<p>4 groups &#8211; {2,1,1,1}</p>
<p>5 groups &#8211; {1,1,1,1,1}</p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2010/09/IntegerPartitioning3.png"><img class="alignnone size-full wp-image-659" title="IntegerPartitioning3" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/09/IntegerPartitioning3.png" alt="" width="748" height="268" /></a></p>
<p>Note that the number of ways to group 5 into 1 and 2 groups in this figure exactly matches the 3 groups in the previous figure. That is P(7,2) = P(5,1)+P(5,2)! That is a breakthrough. So maybe there is a way to break down any P(N,G) into smaller and smaller pieces and add up the totals of the smaller pieces. For example, P(N,G) = P(N-G,1)+P(N-G,2)+ &#8230; + P(N-G,G). Let&#8217;s try this for P(7,2).</p>
<p>P(7,2) = P(5,1) + P(5,2) = 1 + P(3,1) + P(3,2) = 1 + 1 + P(1,1) = 1 + 1 + 1 = 3</p>
<p>Not quite a closed form, but an recursive solution.</p>
<h2>Integer Partitioning and a Generating Function for it</h2>
<p>By the way, this is a good place to (finally) get into Integer Partitioning. In the figure above we listed out <em>all</em> the ways to group 5 objects. That <em>is</em> the Integer Partitioning of 5. I use P(5) to represent it.</p>
<p>P(5) = P(5,1) + P(5,2) + P(5,3) + P(5,4) + P(5,5)</p>
<p>Though it is possible to use the recursive technique I described above to solve for P(5) term by term, there is a very interesting alternative way to figure it out. It is based on a near mind-bending technique, based on <em>Generating Functions</em>. It is powerful technique, used in many different places. I have not yet been able to pin down if the abstraction involved in using Generating Functions is pure genius or if it simply falls out of the mechanics of mathematics if only you start from the correct perspective. Let me attempt to convey how Generating Functions work in this specific situation.</p>
<p>We want to find out all the possible ways to group N objects. But instead of starting with this specific problem we turn the problem on its head and solve a much more general problem. Let us use a bunch of 1s, a bunch of 2s, a bunch of 3s etc. and see what we can add them up to. We do this exhaustively. That is, we we do not let <em>any</em> combination fall through the cracks. Then, we can count up all the different ways a bunch of addends give us the total N. For example, if N is 5, and we do this exhaustive (but structured) adding of all integers (repetitions allowed) and see how many combinations add to 5. We can be sure that none of the addends will be 6 or greater. Similarly, the <em>number</em> of addends will also be no greater than 5, because each addend is at least 1, and with 5 1s we already are at 5. So, the number of combinations we need to look at only needs to cover the addends 1 through 5, and no more than 5 of those addends.</p>
<p>This exhaustive search seems hard to do. But <em>generating functions</em> provide a structured method to approach this. Let us do it one step at a time. We will look at the potential contributions to the total, of each candidate addend one at a time.Â  Let us look at the addend 1. What totals can 1 contribute to? 1s can add up to 1 in 1 way, {1}. 1s can add up to 2 in 1 way, {1,1}. 1s can add up to 3 in 1 way {1,1,1} and so on. That is, 1 alone can add up to <em>any</em> N, AND, in only 1 way for each given N. In fact if there is no 1 in the addends, then 1 can contribute 0 to the total. In generating function terms this would be represented as follows:</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_69a03512c3aee910860f83d0009cf6e3.png" align="absmiddle" class="tex" alt="1+ x+x^2+x^3+x^4+ ... " /></p>
<p>What? Where did that come from? That is typically, always the reaction in my own mind when I see that. Essentially, the order of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_1f31f8c0da2e32b6acaa5b9a0e5154e9.png" align="absmiddle" class="tex" alt="x^k" />, which is k, indicates the total that the addends (remember we are only talking about the addends being 1) add up to. The coefficient of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_1f31f8c0da2e32b6acaa5b9a0e5154e9.png" align="absmiddle" class="tex" alt="x^k" />, which is 1, indicates the number of ways the addends can be added up to get to k. There is only 1 way to do this using only 1s. And there may be no 1s in the addends, and that is the term <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_1fbafd7495b60c9332f7887a3ae2c07e.png" align="absmiddle" class="tex" alt="x^0=1" />.</p>
<p>But what if 2s are allowed? There can be 1 two, or 2 twos, or 3 twos, etc. Thus the generating function based on contributions only from twos is as follows:</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_5dba174bc073f3ef8503acb33dc3e5e0.png" align="absmiddle" class="tex" alt="1+ x^2 + x^4 + x^6 + ... " /></p>
<p>This basically means twos can add up to 0 or 2 or 4 or 6 or 8 etc.</p>
<p>Now, we know that we can have both 1s and 2s in the set of addends. In fact, we can have 1s, and 2s, and 3s, and 4s etc. Let us restrict the addends to 1s and 2s for the time being. There can be 1 one and 1 two, or 1 one and 2 twos or 2 ones and 1 two etc. How do we mathematically express these combinations? This is where the true import of the elegance of generating functions becomes clear. By allowing the contributions of the addends to be in the power of x position, products of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_347b99be8c291ade0c6b4d680e18916a.png" align="absmiddle" class="tex" alt="x^a" /> and <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_dcfb056901a422c68ba50c438ae7c635.png" align="absmiddle" class="tex" alt="x^b" /> correctly give us the sum in the power&#8217;s position, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_0e23fc9dd1637fc9aa5c3cb8c3c2f91f.png" align="absmiddle" class="tex" alt="x^(a+b)" />.Â  Further, if there are multiple ways to add up to a given addend, they show up in the coefficient position. That is, as an example, say we want to figure out the Integer Partitions of any number N, using only the addends 1 and 2, we can <em>multiply</em> the individual addends&#8217; generating polynomials.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_5f53fc51b5b4e8fcdf493e680d47b4b7.png" align="absmiddle" class="tex" alt="(1+x+x^2+x^3+x^4+...) . (1+x^2+x^4+x^6+...)" /></p>
<p>This product of infinite polynomials will give us every possible way to add up 1s and 2s to get us to a specific total N. Say N=5, then we know we need not worry about <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_aca32a2d4ede6a4a5babdc499b929bff.png" align="absmiddle" class="tex" alt="x^5" /> and above in either polynomial.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_b270911d642c04b98671cc6751caeaaf.png" align="absmiddle" class="tex" alt="(1+x+x^2+x^3+x^4) . (1+x^2+x^4)" /></p>
<p>And after some math, we end up with the necessary coefficient for <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_aca32a2d4ede6a4a5babdc499b929bff.png" align="absmiddle" class="tex" alt="x^5" />, and that is the number of ways to get to 5 using only 1s and 2s.</p>
<p>Now, just extending this to allow contributions from the addends 3, 4, 5 etc., we get the full generating function for Integer Partitioning.</p>
<p>P(N) = coefficient of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_bb8ff14b3a9066cd00876b872d73a795.png" align="absmiddle" class="tex" alt="x^N" /> in <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7e371625f7427d6278d6d104e2d52ddb.png" align="absmiddle" class="tex" alt="(1+x+x^2+x^3+x^4+...) . (1+x^2+x^4+x^6+...) . (1+x^3+x^6+x^9+...) . (1+x^4+x^8+x^12+...)..." /></p>
<p>Whew! So we have that out of the way. What amazes me no end is how generating functions are able to hijack this polynomial product form to solve (or, more accurately, bring structure to) seemingly impossible scenarios that need counting. Notice that we still do not have a closed form for the Partition of Integers, P(N). Computers can be employed for the multiplication of terms and accumulation of coefficients.</p>
<h2>A Closed Form Approximation</h2>
<p>In 1918, Srinivasa Ramanujan and his advisor, G. Hardy, came up with a <em>closed form</em> , albeit a closed form for an <em>approximation</em> to P(N). With the current understanding of Integer Partitioning, this seems like an amazing accomplishment. This closed form was:</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_6cc545f579fa05596cc8fbb9e88f2ca2.png" align="absmiddle" class="tex" alt="P(N) \approx \frac{e^{\pi\cdot\sqrt{2N/3}}}{4N\sqrt{3}}" /></p>
<p>This produces pretty good approximations. For example, P(100) = 190,569,292, and this closed form approximates it to around 199 million.</p>
<h2>References</h2>
<p>1. Joseph Laurendi, Partitions of Integers, 2005, http://www.artofproblemsolving.com/Resources/Papers/LaurendiPartitions.pdf</p>
<p>2. Wikipedia, http://en.wikipedia.org/wiki/Partition_%28number_theory%29</p>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2010/09/a-simple-problem-that-led-us-to-ramanujans-work-on-integer-partitioning/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Discovering Hamming Codes</title>
		<link>http://flickeringtubelight.net/blog/2010/07/discovering-hamming-codes/</link>
		<comments>http://flickeringtubelight.net/blog/2010/07/discovering-hamming-codes/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 02:43:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Tidbits]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/?p=480</guid>
		<description><![CDATA[Digital data, transmitted over a communication medium (wireless, optical fiber, copper wire), or stored in some storage medium (such as computer memory or hard disk), is prone to bit-flips and errors. For example, if the message &#8220;10110101000101010&#8243; means &#8220;BILL JOHN&#8221; and communication channel noise flips a bit, the message received may be &#8220;10010101000101010&#8243;, meaning, &#8220;KILL [...]]]></description>
			<content:encoded><![CDATA[<p>Digital data, transmitted over a communication medium (wireless, optical fiber, copper wire), or stored in some storage medium (such as computer memory or hard disk), is prone to bit-flips and errors. For example, if the message &#8220;10110101000101010&#8243; means &#8220;BILL JOHN&#8221; and communication channel noise flips a bit, the message received may be &#8220;10010101000101010&#8243;, meaning, &#8220;KILL JOHN&#8221;. Now, that could create a problem. The problem also exists in data that is sitting untouched on a digital storage medium. Have you ever noticed that if you open some photo file on your computer, after years of storage, they develop strange colors and often do not display fully? This could be due to some bit errors in the stored 1s and 0s that represent the image file data.<span id="more-480"></span></p>
<p>One way to avoid (or, at least drastically reduce) this problem is to either send or store multiple copies of the information. Say you send the message &#8220;BILL JOHN&#8221; 3 times. One of the times the error converts this to &#8220;KILL JOHN&#8221;, but two of the times the message transmits successfully. Then you know that most likely the intended message was &#8220;BILL JOHN&#8221;. Similarly, your bank probably stores your account information of multiple storage locations to avoid this and other problems (such as, catastrophic data loss due to a fire).Â  However, redundancy is not very efficient, and may be overkill. Further, it may not be always possible to apply (say the communication takes a long time and repeat communication is not possible).</p>
<p>Another solution is to add a small amount of extra information to the message being communicated or stored to validate the correctness of the data. This is, in effect, redundancy, but is often a more space-efficient form of it. Its purpose is primarily to detect errors in the message data, not to handle catastrophic destruction of data (which is the primary purpose of full redundancy). The most common way to detect errors in transmitted data is by the use of parity bits. The data is first divided into blocks of bits, say 7 or 15-bit blocks. Next, for each block of bits a parity bit is added, thus making the block size 8 or 16 bits. For example, if the original data is &#8220;10110101000101010&#8243;, and the block size is 7 +1 parity bit, then the data is first extended to make it a multiple of 7. So, say the message is changed to &#8220;000010110101000101010&#8243;. Then, it is broken into 7-bit blocks &#8211; &#8220;0000101&#8243;, &#8220;1010100&#8243;, &#8220;0101010&#8243;. And finally, for each 7-bit block one more bit is added. Say, it is added to the right end. The parity bit is dependent on the data bits. The parity bit is set to a 1 or a 0 depending on the number of 1s in the message. If there are an odd number of 1s in the message, the parity bit is set to 1 to make the total parity of the 8-bit block even. I am assuming even parity in this example; the parity may also be set up to be odd. Going back to the example, if there are already an even number of 1s in the 7-bit data block the parity bit is set to 0. The recipient knows what the block size is, where the parity bit appears, and what kind of parity (Even or Odd Parity) is being used. This is part of a pre-established communication agreement. For example, &#8220;0000101&#8243; has 2 1s, that is, an even number of 1s. The parity bit is set to 0 and appended to these 7 bits to make the transmission block, &#8220;0000101<strong>0</strong>&#8220;. Upon transmission, say there is a bit flip and the message becomes &#8220;00101010&#8243;. The receiver can then figure out that the parity, which is supposed to be even is now odd, and therefore indicates an error. The receiver can then request a retransmission. Notice that the parity bit itself may be transmitted in error, and that triggers an error as well (even though in reality the data bits were all transmitted fine). The size of the block is set to be small enough so that the probability of a bit flip is very very low. More importantly, the probability of <em>two</em> flips is infinitesimally small. Notice that if there <em>are</em> two flips, however, a single bit parity scheme as described above will not work. There is then a need for a more involved parity scheme. If the channel or storage medium has a propensity for unidirectional flips (that is, say it can only flip a 1 to a 0, bit never a 0 to a 1), then a counter may be maintained along with the data to count the number of 1s in the data block. If the number of 1s changes, then the receiver can detect an error. It is a little tricky once you realize that the number of 1s counted must include the number of 1s in the counter itself! The counter bits need to be transmitted as well, and are subject to bit flips as well.</p>
<p>In some situations, there may not be a second copy to rerequest the data upon detecting the error. Or in case of a communication channel, it may take too long to request a replay. And regardless of the application, it seems mathematically challenging to come up with a way to send a message such that not only is the error detected, it is also corrected by the receiver. This was the challenge that Richard Hamming took up an solved in an ingenious way. Here I would like to think through the same problem and come with a solution, which will then help us think through some of Hamming&#8217;s thoughts in the 1930s and 40s.Â  We will stick to the single bit error scenario. We can always reduce the block size sufficiently that only a single bit error can occur with any meaningful probability.</p>
<p>The first insight that led to the discovery of the Hamming code seems to be that some extra meta data (just like parity) needs to be transmitted in addition to the main data. In the presence of this extra data the receiver must be able to identify a bit flip in any bit in the transferred message (including a bit flip in the meta bits).Â  How do we uniquely identify a bit that flipped? We need to identify the position of the bit that flipped. In a message with d bits of data and p bits of meta data, the total number of transmitted bits is d+p. To identify a unique position where the flip may have occurred, we need log2(d+p) bits. The genius of Hamming was in recognizing that the bits being transmitted should be grouped into several groups such that each bit was a member of a unique set of groups. Further, the binary representation of the bit positions was the simplest way to identify the groups.</p>
<p>Say the message were 10 bits long. That is, d+p=10. The 10 positions can be represented as:</p>
<p>0001 &#8211; message bit 1<br />
0010 &#8211; message bit 2<br />
0011 &#8211; message bit 3<br />
0100 &#8211; message bit 4<br />
0101 &#8211; message bit 5<br />
0110 &#8211; message bit 6<br />
0111 &#8211; message bit 7<br />
1000 &#8211; message bit 8<br />
1001 &#8211; message bit 9<br />
1010 &#8211; message bit 10</p>
<p>Notice that we start from 0001, and not 0000. This is because we need to make sure all numbers have 1 (or 0). This means to represent 8 positions (d+p=8), we actually need 4 bits. So the number of groups = log2(d+p+1). Further, notice that the binary representation of every message-bit-position has 1s in unique power-of-2 positions. This is obvious. After all, that is how we represent the positions uniquely. But the insight Hamming was able to draw was that each of the representations (left column above) with a 1 in a certain power-of-2 position could be clubbed together into a group. That is, in the example above, message bits with a 1 in the 2^0 position could be grouped into Club 0. Message bits with a 1 in the 2^1 position could be grouped into Club 1. Notice that some of the numbers which were members of Club 1 were also members Club 0 (for example message bit 3). Similarly, Club 2 and Club 3 could be formed. Further, exactly 4 clubs were needed to identify every bit (including the meta bits uniquely).</p>
<p>0 | 0 | 0 | 1 | &#8211; message bit 1Â  &#8211; Club 0<br />
0 | 0 | 1 |0 | &#8211; message bit 2 &#8211; Club 1<br />
0 | 0 | 1 | 1 | &#8211; message bit 3 &#8211; Club 0,1<br />
0 | 1 | 0 | 0 | &#8211; message bit 4 &#8211; Club 2<br />
0 | 1 | 0 | 1 | &#8211; message bit 5 &#8211; Club 0, 2<br />
0 | 1 | 1 | 0 | &#8211; message bit 6 &#8211; Club 1, 2<br />
0 | 1 | 1 | 1 | &#8211; message bit 7 &#8211; Club 0, 1, 2<br />
1 | 0 | 0 | 0 | &#8211; message bit 8 &#8211; Club 3<br />
1 | 0 | 0 | 1 | &#8211; message bit 9 &#8211; Club 0, 3<br />
1 | 0 | 1 | 0 | &#8211; message bit 10 &#8211; Club 1, 3</p>
<p>Notice that <em>no</em> two bit-position-representations <em>can</em> belong to the same set of Clubs. After all, every bit position is represented uniquely in binary, and a 1 in the binary representation corresponds to a &#8220;key&#8221; to a certain club. No two binary representations are the same and so no two bit-positions can belong to the same club combination.</p>
<p>The groups/clubs thus formed are:</p>
<p>Club 0 &#8211; message bits 1, 3, 5, 7, 9<br />
Club 1 &#8211; message bits 2, 3, 6, 7, 10<br />
Club 2 &#8211; message bits 4, 5, 6, 7<br />
Club 3 &#8211; message bits 8, 9, 10</p>
<p>Now, Hamming must have realized that he has created clubs with careful membership such that a unique member could be located if we knew which clubs he belonged to. So, a flipping bit can be located if that flip can identify all the clubs the bit belongs to. The clubs must start with some common property, and the flip must change that property for each club that it belongs to. This would help identify the clubs in which the flipped bit has membership, and by that unique combination, we can identify the flipped bit.</p>
<p>That unique property that Hamming gave each club was parity. Since no two clubs has the same membership, each club needed at least 1 unique parity bit. Since we want to keep the number of parity bits as small as possible to keep the message overhead as small as possible, the smallest solution would need as many parity bits as clubs. And we know that for transmitting d+n bits, we need log2(d+p+1) bits to represent the positions and, therefore, log2(d+p+1) clubs. This leads to the following observation:</p>
<p>The minimum overhead bits/parity bits = log2(d+p+1). But we assumed that the number of parity bits = p.</p>
<p>p &gt;= log2(d+p+1)</p>
<p>Now we know how many groups, which bits make up the groups and the minimum number of parity bits. In the above example with d+p=10, p=4. Thus for 6 data bits we need to transmit 4 parity bits. But we must recognize that the parity bits cannot be simply lumped together into any casually selected positions. This is because without careful selection we may not have at least 1 parity bit per group. For example if the first 4 bit positions of a 10 bit message are used for parity, there would be no parity bits in Club 3. If we instead used the last 4 bits in a 10-bit message for parity, each club would have at least one parity bit, but all 3 of Club 3&#8217;s members would be parity bits. This creates a dependency on filling out the parity bits on the sender side. First parity bit 7 would have to be established based on Club 2 which has 3 data bits and only 1 parity bit. Then the remaining parity bits in Club 0 and Club 1 would have to be established, followed finally by the parity for Club 3. Hamming realized that it would be much easier to ensure that one parity bit belonged to 1 club, no more no less. All the members of a club are data bits except the one parity. This helps speed up setting the parity bit &#8211; there is no dependency and fixed order in which the parity bits need to be established. The bit positions in the message which belong t0 only 1 club are positions with a single 1 and all else 0s. These are also the power-of-two bit positions. Bit position 1, 2, 4 and 8. By making these bits parity bits, there is another advantage. At the receiving end, once parity is established for the various clubs, if it turns out that club 2 and club 1 are not maintaining parity, then to identify the bit position which flipped all that is needed is to calculate 2^2 + 2^1 = 6. Bit at position 6 is the only bit which is a member of Club 2 and 1 and no other club.</p>
<p>References:<br />
I found this video of a class, held in University of New South Wales, Australia, and taught by Professor Richard Buckland, to be very useful in helping me understand how Hamming Codes work. The Hamming Code material starts at minute 8:00.<a href="http://www.youtube.com/watch?v=kE7V7UI4jpk"> http://www.youtube.com/watch?v=kE7V7UI4jpk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2010/07/discovering-hamming-codes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fascinating course on Justice by Michael Sandel</title>
		<link>http://flickeringtubelight.net/blog/2010/06/interesting-course-on-justice-by-michael-sandel/</link>
		<comments>http://flickeringtubelight.net/blog/2010/06/interesting-course-on-justice-by-michael-sandel/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 16:17:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Tidbits]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/?p=460</guid>
		<description><![CDATA[Here is a link to video lectures from Harvard University&#8217;s course on Justice, taught by Professor Michael Sandel. (Watch the introductory video which should start automatically, and then look for the Episode list to the bottom right of the page. 12 hour long lectures &#8211; but worth the time.)
http://www.justiceharvard.org/
It contains some fascinating discussions on morals, [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a link to video lectures from Harvard University&#8217;s course on Justice, taught by Professor Michael Sandel. (Watch the introductory video which should start automatically, and then look for the Episode list to the bottom right of the page. 12 hour long lectures &#8211; but worth the time.)</p>
<p><a href="http://www.justiceharvard.org/">http://www.justiceharvard.org/</a></p>
<p>It contains some fascinating discussions on morals, philosophy, rights and justice. Professor Sandel has a very interesting teaching style, where he almost helps the students discover right vs. wrong, rather than just teaching it to them. Also, he has an extraordinary delivery style &#8211; careful and sincere. It is clear that he is actively participating in the discussion himself; he tailors the material such that it conveys all the crucial points while at the same time allowing the journey to these crucial points to be shaped by the students in the classroom. The class itself is comprised of over a thousand students, hanging on to every word from the teacher, and is a sight to behold.</p>
<p>A must watch. More accurately, a must think.</p>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2010/06/interesting-course-on-justice-by-michael-sandel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts on the mathematical constant e</title>
		<link>http://flickeringtubelight.net/blog/2010/05/thoughts-on-the-mathematical-constant-e/</link>
		<comments>http://flickeringtubelight.net/blog/2010/05/thoughts-on-the-mathematical-constant-e/#comments</comments>
		<pubDate>Sun, 16 May 2010 15:54:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Tidbits]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/?p=432</guid>
		<description><![CDATA[e for exponential
The mathematical constant  shows up in strange places. Moreover, its significance is not as easy to grasp as that of the other famous constant, , because there is no easy physical object in whose context to imagine it. For example,   is the ratio of the circumference to the diameter of [...]]]></description>
			<content:encoded><![CDATA[<h2>e for exponential</h2>
<p>The mathematical constant <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up in strange places. Moreover, its significance is not as easy to grasp as that of the other famous constant, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_4f08e3dba63dc6d40b22952c7a9dac6d.png" align="absmiddle" class="tex" alt="\pi" />, because there is no easy physical object in whose context to imagine it. For example,  <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_4f08e3dba63dc6d40b22952c7a9dac6d.png" align="absmiddle" class="tex" alt="\pi" /> is the ratio of the circumference to the diameter of  a circle. Yes, it is irrational, but if you can get over that mystery (or ignore it for the time being), it is straightforward to <em>imagine</em> what <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_4f08e3dba63dc6d40b22952c7a9dac6d.png" align="absmiddle" class="tex" alt="\pi" /> is. Every circle does seem to have a certain <em>circleness</em>, which makes them all look the same. It is intuitively not hard to agree with the hunch that every circle has an unchanging ratio between the circumference and the diameter; and it makes sense to keep that ratio handy and give it a name.</p>
<p>The constant <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> is considerably more elusive. It appears, at first, to be a number you would not go hunting after. You just happen to stumble upon in during one of your mathematical excursions; it seems interesting enough that you then pick it up and put in in your pocket for some potential use later. After stumbling upon the same thing along other mathematical excursions, in hindsight, it does seem to be something rather useful. Something you <em>should</em> have gone looking for.<span id="more-432"></span></p>
<p>Jacob Bernoulli, sometime in the late 1600s, stumbled upon this constant when he was trying to calculate the maximum compound interest that can be earned on an investment by compounding continuously.</p>
<p>If you invest 1 dollar in an account that earns 100% annual interest, then after 1 year the value of your investment will be 2 dollars assuming the compounding (interest calculation) happens once during the year. Assuming you do not touch the money and let it grow, by the end of 2 years, the money would have doubled again and you&#8217;ll have 4 dollars in all. Now, imagine the bank decided to compound every 6 months instead of once a year. The annual interest rate remains the same, 100%. 50% is applied at the end of 6 months and another 50% is applied at the end of the year. The 1 dollar grows to 1.50 after the first 6 months. For the second half of the year 1.50 dollars grow in value. At the end of the first year, the total value in your account is 1.50 + (1.50*50%), that is, 2.25 dollars. Not bad! Just by compounding every 6 months you made 2.25 instead of 2. Now you start thinking (as, perhaps, did Jacob Bernoulli). What if the bank compounded every 3 months? What if the bank compounded every month? Every week? Every day? Every second? Every picosecond? A similar question is what Jacob Bernoulli asked himself in the late 1600s. It turns out that this calculation results in an infinite series, which when added up closes in on 2.718281&#8230;This means if your bank was really generous and compounded <em>continuously</em>, your 1 dollar would become 2.718281 dollars at the end of the year. Quite a swing there &#8211; between 2 and 2.71, wouldn&#8217;t you say? And this given that the interest rate is unchanged between the two scenarios. (Aside: In general, pay some attention to how often your investments are being compounded, not <em>just</em> to the the annual rate of return.)</p>
<p>That number, 2.718281&#8230;, shows up in such seemingly disparate scenarios that it may be hard to see the connection between those scenarios. I recall that the way this constant was introduced to me in school was entirely different from the discussion above. I was taught that <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_c9d81daf1dc94d468bf1ad47a8180461.png" align="absmiddle" class="tex" alt="c\cdot{e^{x}}" />, where <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_4a8a08f09d37b73795649038408b5f33.png" align="absmiddle" class="tex" alt="c" /> is a constant, is the only function whose derivative is equal to itself. That is, the slope of the curve is the value of the curve. Wow, I thought. That is quite a curve. I now feel that though that was correct, it may not have been the best way to introduce <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" />; it does not say <em>why</em> <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_c9d81daf1dc94d468bf1ad47a8180461.png" align="absmiddle" class="tex" alt="c\cdot{e^{x}}" /> is the <em>only</em> function that satisfies this property. Further, it is not explained why a function that does satisfy this property should even <em>be</em> of the basic form <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_378ef468365a2fd4ae953f909ad2dee0.png" align="absmiddle" class="tex" alt="a^{x}" />, where a is a constant.</p>
<p>I decided therefore to think through two things. First, I wanted to understand <em>why</em> <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_c9d81daf1dc94d468bf1ad47a8180461.png" align="absmiddle" class="tex" alt="c\cdot{e^{x}}" /> the <em>only </em>function whose slope at a given <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> is the same as its value. I wanted to approach this problem by using the knowledge of this special property, and then trying to come up with the function <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> which would fit this requirement. Second, I wanted to tie together the two seemingly different arenas where e shows up &#8211; continuous compounding and as the base of the curve whose slope is equal to its value. There are other areas where <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up also. For example, if the probability of winning a wager is 1 in <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" />, and a man places <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" /> bets, then the probability that he wins at least one bet is <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e829777ab97c93ef78b95b37ec071e96.png" align="absmiddle" class="tex" alt="\frac{1}{e}" />. This question is related closely to the <em>hat check</em> problem (also known as <a href="http://en.wikipedia.org/wiki/Derangement">Derangements</a>). <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> also shows up in <a href="http://en.wikipedia.org/wiki/Euler%27s_identity">Euler&#8217;s Identity</a>. I will need to do more digging before I attempt to understand, intuitively, why <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up in those scenarios so I may not tackle these in much depth in this article.</p>
<h2><em>Why</em> is <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_c9d81daf1dc94d468bf1ad47a8180461.png" align="absmiddle" class="tex" alt="c\cdot{e^{x}}" /> the <em>only</em> function whose slope at a given <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> is the same as its value?</h2>
<p>Before I looked at this particular issue and attempted to uncover the function <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> which gave me this special property, I decided to start small. I decided to look at some other canonical functions that might have been interesting. For example, &#8220;What is a function whose value, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" />, is equal to <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" />?&#8221;, &#8220;What is a function whose value is equal to <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_32f5240d0dbf2ccbe75ef7f8ef2015e0.png" align="absmiddle" class="tex" alt="x^2" />?&#8221;, &#8220;What is a function whose value is equal to <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" />?&#8221;. The first question is easy. It defines <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_f8abf34599677984dfe91b4f300389f6.png" align="absmiddle" class="tex" alt="f(x)=x" />. The curve for this is a straight line at a <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_4af7d16ee8abbb68901ca728d6d66eb5.png" align="absmiddle" class="tex" alt="45^{\circ}" /> angle through the origin. The second one is easy as well. It defines <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_d271cedde6675e55152d3c7a4236f775.png" align="absmiddle" class="tex" alt="f(x)=x^2" />. A parabola passing through the origin, (1,1) and (-1,1). The third question is the easiest of all, but the one that gets us closest to the question we are going after. It defines <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_a8057018c4637b6521b5be0a17519865.png" align="absmiddle" class="tex" alt="f(x)=f(x)" />! That is silly. Any function will fit. Notice, however, that in the third question the value of the function is dependent on the value of the function and not directly on <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" />. This starts to highlight the significance of the question we are trying to answer. We want to discover a function, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_48879efd6f01be071ce5f17d2d102051.png" align="absmiddle" class="tex" alt="f(x)=f'(x)" />. There is something quirky going on here. The right hand side is the derivative of the left hand side. So which comes first? It seems like you cannot really know the slope at <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" />, until you define <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" />. But then, you need the slope of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> to define <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> because its value <em>is</em> the slope of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" />. It is a bit confusing. The trick is to realize that this function is continuous. So the value of the slope of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> will be pretty close to the value of the slope of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_38a932caefd461a1063aa32f21fb5ffd.png" align="absmiddle" class="tex" alt="f(x-\Delta{x})" />, the slope of the curve <em>just</em> prior to x. (This recursion also vaguely points to an upcoming infinite series.)</p>
<p>Now, let us try to find the function which satisfies the interesting property, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_48879efd6f01be071ce5f17d2d102051.png" align="absmiddle" class="tex" alt="f(x)=f'(x)" />. In words, this means the <em>rate</em> of growth of this function at a given point is equal to the value of the function at that point. More on that in a bit. Let us use the fact that the function is continuous and therefore, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_74caf4d1ec90d3a36ea7c7bbfe65b516.png" align="absmiddle" class="tex" alt="f'(x)" />, the slope of the function <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> at <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> is given by the following.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_cb461640770db1f53f41d005ba80f131.png" align="absmiddle" class="tex" alt="f'(x)=\frac{f(x+\Delta{x})-f(x)}{\Delta{x}}" /></p>
<p>Since we <em>know</em> that the function we are trying to uncover has the special property that <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_48879efd6f01be071ce5f17d2d102051.png" align="absmiddle" class="tex" alt="f(x)=f'(x)" />, we can substitute <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> instead of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_74caf4d1ec90d3a36ea7c7bbfe65b516.png" align="absmiddle" class="tex" alt="f'(x)" /> in the previous equation, to get the following.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_559b621365785f1f261b7e3ee234d980.png" align="absmiddle" class="tex" alt="f(x)=\frac{f(x+\Delta{x})-f(x)}{\Delta{x}}" /></p>
<p>This can be rewritten as</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_8907255c33a0872cf41376aea67ad54b.png" align="absmiddle" class="tex" alt="f(x)\cdot\Delta{x}=f(x+\Delta{x})-f(x)" /></p>
<p>which in turn can be rewritten as</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_77af21e01765b6968d7b9b8645dae9d2.png" align="absmiddle" class="tex" alt="f(x)\cdot(1+\Delta{x})=f(x+\Delta{x})" /></p>
<p>I will substitute <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> with <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_0d99278a0c5a59c1ed3ef4e8420682cb.png" align="absmiddle" class="tex" alt="x-\Delta{x}" /> (this is unfortunately one of those things which you do <em>after</em> you have worked out the steps and realize that doing something like this may make things a little cleaner to understand).</p>
<p>So we get, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_ce43eacc5ce2f8253c77387cd0905b88.png" align="absmiddle" class="tex" alt="f(x-\Delta{x})\cdot(1+\Delta{x})=f(x)" /></p>
<p>Swapping the right and left sides, we get the following.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_ee82a2c1deb4a2c008de1dc38cdb3095.png" align="absmiddle" class="tex" alt="f(x)=f(x-\Delta{x})\cdot(1+\Delta{x})" /></p>
<p>The above equation represents <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> in terms of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_38a932caefd461a1063aa32f21fb5ffd.png" align="absmiddle" class="tex" alt="f(x-\Delta{x})" />. Using steps similar to the ones shown above if we express <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_38a932caefd461a1063aa32f21fb5ffd.png" align="absmiddle" class="tex" alt="f(x-\Delta{x})" /> in terms of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_0742b20f5c77cfb3ed26433fa693a2b8.png" align="absmiddle" class="tex" alt="f(x-2\cdot\Delta{x})" /> we get the following.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_37b2607446f16c5128f87a967aa050d0.png" align="absmiddle" class="tex" alt="f(x)=f(x-2\cdot\Delta{x})\cdot(1+\Delta{x})^2" /></p>
<p>Extending this process <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" /> times we get the following.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_25a4cf252408c54a9ef8179507799639.png" align="absmiddle" class="tex" alt="f(x)=f(x-n\cdot\Delta{x})\cdot(1+\Delta{x})^n" /></p>
<p>If <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" /> is large enough that <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_72feff558dbc6136047b57d529b409a1.png" align="absmiddle" class="tex" alt="n\cdot\Delta{x}=x" /> then the above equation becomes very interesting.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7a69f9b00ed22198ac9029021a84216f.png" align="absmiddle" class="tex" alt="f(x)=f(0)\cdot(1+\frac{x}{n})^n" /></p>
<p>Notice that <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> is still not a power to any base. So <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" /> is still not an exponential curve, at least it does not look so. It does seem like it may expand into a sum of polynomials with the largest polynomial being of degree <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" />. A polynomial, however large in degree, grows slower than an exponential curve (as long as the degree is finite). However, note that <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" /> is not a finite integer. It is an infinitely large number because <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_56f4fb7d80196b954a5a33facf4b9a23.png" align="absmiddle" class="tex" alt="\Delta{x}" /> is infinitesimally small. So there is still hope that this sum of polynomials may catch up to an exponential curve. Now, we apply a trick which changes the nature of this curve. A sum of polynomials becomes an exponential curve, and the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> goes up to a &#8220;position of power&#8221;. We simply reapply the equation <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_72feff558dbc6136047b57d529b409a1.png" align="absmiddle" class="tex" alt="n\cdot\Delta{x}=x" /> to the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_15699da5162c6174d970b58e778138fc.png" align="absmiddle" class="tex" alt="\frac{x}{n}" /> and the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" /> term in the above equation to get the following.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_0887549c642d568058f69931f1f19ced.png" align="absmiddle" class="tex" alt="f(x)=f(0)\cdot(1+\Delta{x})^\frac{x}{\Delta{x}}" /></p>
<p>Now, say we represent <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_1d32d8aaaa8ce8210bc9de688c09308c.png" align="absmiddle" class="tex" alt="\frac{1}{\Delta{x}}" /> by a new variable, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_8d9c307cb7f3c4a32822a51922d1ceaa.png" align="absmiddle" class="tex" alt="N" />. Then the above equation can be written as follows.</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_69f8cd0a4cb9b4df957ee96502f04bcf.png" align="absmiddle" class="tex" alt="f(x)=f(0)\cdot(1+\frac{1}{N})^{{x}\cdot{N}}" /></p>
<p>which in turn can be written as</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_786bb06d74932edeebe61d219c8abcc0.png" align="absmiddle" class="tex" alt="f(x)=f(0)\cdot((1+\frac{1}{N})^N)^x" /></p>
<p>And now we start seeing the exponential form emerge. The <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> is the power to which <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_0750543f1200a9510dc39b462722fe68.png" align="absmiddle" class="tex" alt="(1+\frac{1}{N})^N" /> must be raised to evaluate <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_50bbd36e1fd2333108437a2ca378be62.png" align="absmiddle" class="tex" alt="f(x)" />.</p>
<p>This term, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_0750543f1200a9510dc39b462722fe68.png" align="absmiddle" class="tex" alt="(1+\frac{1}{N})^N" />, when expanded out (remember that <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_8d9c307cb7f3c4a32822a51922d1ceaa.png" align="absmiddle" class="tex" alt="N" /> is infinitely large) hones in on a constant, 2.718281. And that is why, a special name is given to this term (<img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" />). The right hand side thus becomes <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_ff2d26be6b0b506663911208302f91b3.png" align="absmiddle" class="tex" alt="e^x" />.</p>
<p>This takes the general form <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_eb415307499a489e6e9ebf6d2f506853.png" align="absmiddle" class="tex" alt="f(x)=c\cdot{e^x}" />, where <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_07bab375a7f255602b9f2985b304fe9a.png" align="absmiddle" class="tex" alt="c = f(0)" />, the value of the function at <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e11729b0b65ecade3fc272548a3883fc.png" align="absmiddle" class="tex" alt="x=0" />. In other words we have proved that a function that satisfies the property that the curve&#8217;s value at any point is equal to the slope of the curve at that point follows the general form of an exponential curve.</p>
<h2>How is continuous compounding related to the base of the exponential curve whose slope is  equal to its value?</h2>
<p>Now that we understand the general structure of the exponential curve and its special property, slope equals value, let us revisit the issue of continuous compounding. How is that related to this curve? It is intuitive once we realize that the <em>rate</em> at which money grows at any point in time is directly proportional to the <em>amount</em> of money in the account at that point in time. This is the same as saying the <em>slope</em> of the curve at a given point is directly proportional to the <em>value</em> of the function at that point. The interest rate plays the role of tempering the <em>proportionality</em>. For example, if the interest rate is 100%, the value of the continuously compounding account after <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> units of time (<img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> years) is <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_8867b399ea90faa4cb5d5163025016f6.png" align="absmiddle" class="tex" alt="f(x) =c \cdot e^{100\% \cdot x}" />. Here <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_4a8a08f09d37b73795649038408b5f33.png" align="absmiddle" class="tex" alt="c" /> is the amount in the account at the beginning (value of the function at <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_f4bff8c9a4fa0cfee395df7e0dade218.png" align="absmiddle" class="tex" alt="x=0, f(0)" />). If the interest rate is 8%, then the value at time <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> years is <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_c61324159496444763875a29718388e8.png" align="absmiddle" class="tex" alt="f(x)=c\cdot e^{80\% \cdot x}" />. Once we see that the two phrases, &#8220;slope of a curve is proportional to its value&#8221; and &#8220;rate of growth of something is proportional to the amount of that something&#8221;, are saying the same thing, it is clearer that these two ways of defining or discovering <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> are equivalent.</p>
<h2>Other places <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up</h2>
<p>Another place <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up is called Derangements, as in the opposite of arrangement. A popular example used to explain this issue is the <em>hat check</em> problem. Say there are <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" /> people who check in at a party, and the butler takes their hats as they enter the party. There are boxes to hold the hats, one per guest. The boxes have names on them to identify which guest&#8217;s hat should go into it. The butler, however, does not know the names of the guests. He puts the hats into those boxes randomly. When the number of hats (and boxes) is large, the probability that <em>no hat is in the right box</em> is <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e829777ab97c93ef78b95b37ec071e96.png" align="absmiddle" class="tex" alt="\frac{1}{e}" />. I have been able to work this out mathematically, but I still have not been able to understand this intuitively. Maybe the reason <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up here has nothing to do with the properties of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_ff2d26be6b0b506663911208302f91b3.png" align="absmiddle" class="tex" alt="e^x" />. Maybe it just so happens that the same summation, which adds up to e, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_58cb916ff717ed6eed51eb31eaad66c4.png" align="absmiddle" class="tex" alt="(1+\frac{1}{n})^n" />, shows up here.</p>
<h3>Solution to Hat Check Problem: An Outline</h3>
<p>The probability that all hat are in wrong boxes = 1 &#8211; probability that at least one hat is in the right box</p>
<p>= 1 &#8211; (prob. that the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_207540b5d67149d0d26722001b22e54e.png" align="absmiddle" class="tex" alt="1^{st}" /> hat is in the right box OR prob that the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_d517e3a509a09010ea03e8b689dae5d0.png" align="absmiddle" class="tex" alt="2^{nd}" /> hat is the right box OR &#8230; OR probability that the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_dee7141541b0575f29b52d84bb7580f6.png" align="absmiddle" class="tex" alt="n^{th}" /> hat is in the right box)</p>
<p>Note that for the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_97361f12a3555fc4fc4e2ffce1799ac3.png" align="absmiddle" class="tex" alt="i^{th}" /> hat to be in the right box the first i-1 hats have to avoid that box. Therefore,</p>
<p>Probability that the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_97361f12a3555fc4fc4e2ffce1799ac3.png" align="absmiddle" class="tex" alt="i^{th}" /> hat is in the right box = (probability that the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_207540b5d67149d0d26722001b22e54e.png" align="absmiddle" class="tex" alt="1^{st}" /> hat has not taken up the right  box of  the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_97361f12a3555fc4fc4e2ffce1799ac3.png" align="absmiddle" class="tex" alt="i^{th}" /> hat).(probability that the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_d517e3a509a09010ea03e8b689dae5d0.png" align="absmiddle" class="tex" alt="2^{nd}" /> hat has not taken up the right  box of  the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_97361f12a3555fc4fc4e2ffce1799ac3.png" align="absmiddle" class="tex" alt="i^{th}" />  hat)&#8230;(probability that the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_084e59c9abe583f3018a6e8ea6b6b9b0.png" align="absmiddle" class="tex" alt="i-1^{th}" /> hat has not taken up the right  box of  the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_97361f12a3555fc4fc4e2ffce1799ac3.png" align="absmiddle" class="tex" alt="i^{th}" />  hat).(the <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_97361f12a3555fc4fc4e2ffce1799ac3.png" align="absmiddle" class="tex" alt="i^{th}" /> hat <em>does</em> take up the right box)</p>
<p>Using this, the probability that all hat are in wrong boxes</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_933d03fccb87d944badf2c4497699935.png" align="absmiddle" class="tex" alt=" = 1 -  (     \frac{1}{n} + ( \frac{1}{n} \cdot (1-\frac{1}{n}))   +  (  \frac{1}{n}  \cdot  (1-\frac{1}{n})^2  )  +  (  \frac{1}{n}  \cdot  (1-\frac{1}{n})^3  )  + ... + (  \frac{1}{n}  \cdot  (1-\frac{1}{n})^n  )    )" /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9c53f508e1ffbc9fec17b45f696f4646.png" align="absmiddle" class="tex" alt=" = 1 - ( \frac{1}{n}) \cdot (1 + (1-\frac{1}{n}) + (1-\frac{1}{n})^2  + (1-\frac{1}{n})^3 + ... + (1-\frac{1}{n})^n ) " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_08033a55378c88eb5ee235a2c780609e.png" align="absmiddle" class="tex" alt=" = 1 - \frac{1}{n} \cdot A " /></p>
<p>where,</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_49934049f07e96662510c93af42fcc0b.png" align="absmiddle" class="tex" alt=" A = 1 + (1-\frac{1}{n}) + (1-\frac{1}{n})^2 + (1-\frac{1}{n})^3 + ... +  (1-\frac{1}{n})^n " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_c2e78d8d3114caf8ff7bbb64f1e129af.png" align="absmiddle" class="tex" alt=" A \cdot (1-\frac{1}{n}) = (1-\frac{1}{n}) + (1-\frac{1}{n})^2 + (1-\frac{1}{n})^3 + ... +   (1-\frac{1}{n})^n + (1-\frac{1}{n})^{n+1} " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_eb114c837a9f7e16843a0f83fd242908.png" align="absmiddle" class="tex" alt=" A \cdot (1-\frac{1}{n}) + 1 = 1 + (1-\frac{1}{n}) + (1-\frac{1}{n})^2 + (1-\frac{1}{n})^3 + ... +   (1-\frac{1}{n})^n + (1-\frac{1}{n})^{n+1} " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_eae36eee648aa46b8b871c4f64d95c94.png" align="absmiddle" class="tex" alt=" A \cdot (1-\frac{1}{n}) + 1 = A + (1-\frac{1}{n})^{n+1} " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9ef776cb210292aba7a1b12cfdb630eb.png" align="absmiddle" class="tex" alt=" A = \frac{(1-\frac{1}{n})^{n+1} - 1}{(1-\frac{1}{n}) - 1} " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_eb0d481fae6699c9a128549ab06a24c5.png" align="absmiddle" class="tex" alt=" A = \frac{(1-\frac{1}{n})^{n+1} - 1}{-\frac{1}{n}} " /></p>
<p>Putting this <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_7fc56270e7a70fa81a5935b72eacbe29.png" align="absmiddle" class="tex" alt="A" /> back in the equation for the probability we are looking for, we get,</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_859f8463e8461ae5b9879f594d550d27.png" align="absmiddle" class="tex" alt=" = 1 + (1-\frac{1}{n})^{n+1} - 1 " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_203b286cc7e79623e1bb7c6e93770913.png" align="absmiddle" class="tex" alt=" = (1-\frac{1}{n})^{n+1} " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_f00f81432918c4d66c9e8e808c4e5bf3.png" align="absmiddle" class="tex" alt=" = (\frac{n-1}{n})^{n+1} " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e0da64a2acfb5251c39c5c111c4b126f.png" align="absmiddle" class="tex" alt=" = (\frac{n}{n-1})^{-n-1} " /></p>
<p>now, replacing <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_a438673491daae8148eae77373b6a467.png" align="absmiddle" class="tex" alt="n-1" /> by <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_8d9c307cb7f3c4a32822a51922d1ceaa.png" align="absmiddle" class="tex" alt="N" />,</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_877897a189ef3731d1ef592fea407842.png" align="absmiddle" class="tex" alt=" = (\frac{N+1}{N})^{-N-2} " /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_9c9f867217b465ae2eddd42e385543ab.png" align="absmiddle" class="tex" alt=" = (1+\frac{1}{N})^{-N} \cdot (1+\frac{1}{N})^{-2} " /></p>
<p>The second term goes to <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_cfcd208495d565ef66e7dff9f98764da.png" align="absmiddle" class="tex" alt="0" /> as <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_8d9c307cb7f3c4a32822a51922d1ceaa.png" align="absmiddle" class="tex" alt="N" /> increases. So we are left with,</p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_3d0b87f27a338090cf360b91bebe5520.png" align="absmiddle" class="tex" alt=" = \frac{1}{(1+\frac{1}{N})^{N}}" /></p>
<p><img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_454d15e1e90ac89c99605653ea34e126.png" align="absmiddle" class="tex" alt=" = \frac{1}{e}" /></p>
<p>I do not know why <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up here. But, well, it does. Yet another place where <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up with unabated vigor is when representing complex numbers, and, of course, in that famous Euler&#8217;s equation that brings together 5 of the most interesting quantities in mathematics, <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_66d24771ec114e071c1c13223f816869.png" align="absmiddle" class="tex" alt="e^{i\pi}+1=0" />. I will go into exploring that another time.</p>
<h2>References and Acknowledgments</h2>
<p>My discussions with  my friend Mani, and my investigations on the internet led to this write up. I found the Wikipedia site very useful to tie together the seemingly unconnected ways in which the constant <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> shows up in real life. The BetterExplained.com website has a very good illustrated tutorial for those who want to understand the concept of <img src="http://flickeringtubelight.net/blog/wp-content/cache/tex_e1671797c52e15f763380b45e841ec32.png" align="absmiddle" class="tex" alt="e" /> in simple terms.</p>
<p>Wikipedia.com &#8211; <a href="http://en.wikipedia.org/wiki/E_%28mathematical_constant%29">http://en.wikipedia.org/wiki/E_(mathematical_constant)</a></p>
<p>BetterExplained.com &#8211; <a href="http://betterexplained.com/articles/an-intuitive-guide-to-exponential-functions-e/">http://betterexplained.com/articles/an-intuitive-guide-to-exponential-functions-e/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2010/05/thoughts-on-the-mathematical-constant-e/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>We, the people &#8230;</title>
		<link>http://flickeringtubelight.net/blog/2010/05/we-the-people/</link>
		<comments>http://flickeringtubelight.net/blog/2010/05/we-the-people/#comments</comments>
		<pubDate>Sun, 02 May 2010 21:24:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Tidbits]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/?p=326</guid>
		<description><![CDATA[Reference for the population figure: http://www.google.com/publicdata?ds=wb-wdi&#38;met=sp_pop_totl&#38;tdim=true&#38;dl=en&#38;hl=en&#38;q=world+population

]]></description>
			<content:encoded><![CDATA[<a href="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/worldPop.png"><img class="size-full wp-image-327 " title="worldPop" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/worldPop.png" alt="" width="827" height="559" /></a>
<p>Reference for the population figure: http://www.google.com/publicdata?ds=wb-wdi&amp;met=sp_pop_totl&amp;tdim=true&amp;dl=en&amp;hl=en&amp;q=world+population</p>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2010/05/we-the-people/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The 4 squares problem &#8211; extended</title>
		<link>http://flickeringtubelight.net/blog/2010/05/the-4-squares-problem-extended/</link>
		<comments>http://flickeringtubelight.net/blog/2010/05/the-4-squares-problem-extended/#comments</comments>
		<pubDate>Sat, 01 May 2010 13:54:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Family]]></category>
		<category><![CDATA[Tidbits]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/?p=197</guid>
		<description><![CDATA[A &#8220;4 Squares Puzzle&#8221; is doing the rounds over the internet nowadays. here are the original Microsoft Powerpoint slides which I received via email from my father. (Not sure who the original author of these slides is, but the slides report the author to be Nakit Yonetimi.) It may be useful to look over the [...]]]></description>
			<content:encoded><![CDATA[<p>A &#8220;4 Squares Puzzle&#8221; is doing the rounds over the internet nowadays. here are the original Microsoft Powerpoint <a href="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/fourSquares.pdf">slides</a> which I received via email from my father. (Not sure who the original author of these slides is, but the slides report the author to be Nakit Yonetimi.) It may be useful to look over the pdf file once before proceeding. The question posted in the slides is different from the one I am going to pose, but going through the slides helps build context and helps get mentally warmed up.</p>
<p><img class="alignleft size-full wp-image-219" title="sq_fig1" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/sq_fig11.gif" alt="" width="168" height="112" />The question I posed to myself after thinking through the puzzle was,  &#8220;How can we divide a square into 7 equal parts with only a straight edge  and a compass available?&#8221; Note that the question implies that we do not  have a ruler or a scale. We have a straight edge, but without any markings on it to indicate inches or centimeters. Even if it did have the markings, such markings can only measure accurately up to a certain level. For example, say you have a scale with markings at the granularity of a millimeter. Say the square had a side equal to some irrational number, say <img src='http://s.wordpress.com/latex.php?latex=pi&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='pi' title='pi' class='latex' /> or <img src='http://s.wordpress.com/latex.php?latex=%5Csqrt%7B2%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\sqrt{2}' title='\sqrt{2}' class='latex' />, or, even a simple integer which is not a multiple of 7, such as, 8 millimeters. There is no way to measure <img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7Bpi%7D%7B7%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{pi}{7}' title='\frac{pi}{7}' class='latex' /> or <img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%5Csqrt%7B2%7D%7D%7B7%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{\sqrt{2}}{7}' title='\frac{\sqrt{2}}{7}' class='latex' /> or <img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B8%7D%7B7%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{8}{7}' title='\frac{8}{7}' class='latex' /> millimeters using such a scale.</p>
<p>There are at least 2 approaches to dividing this square into 7 parts. The first is a simpler approach and the second is slightly more involved. Let me talk about the second one first. The first one will then become easy to see. The main intuition behind the first idea is that a triangle&#8217;s area depends only on its base and height. If we can mark out 7 equidistant points along the square&#8217;s border, thus creating 7 equal bases, we can join the bases to the center of the square to create 7 regions with equal areas. The heights of these shapes will be equal, and the bases are equal by construction.<span id="more-197"></span></p>
<p><img class="alignleft size-full wp-image-222" title="sq_fig4" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/sq_fig41.gif" alt="" width="390" height="166" /></p>
<p>As shown in the figure to the far left, the corners of the square are joined, and the intersection gives us the center of the square. Then, assuming we already have the 7 equidistant points of the square&#8217;s edge marked out,  joining the center to the 7 points creates 7 regions with equal area, as shown in the figure to the immediate left. It may not be obvious why these regions are equal in area. If you divide up the quadrilateral regions (regions with 4 edges) into 2 triangles, you should start seeing that the area of the quadrilateral piece is the same as the area of a triangular piece since they both have the same height (<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7Bl%7D%7B2%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{l}{2}' title='\frac{l}{2}' class='latex' />, where <img src='http://s.wordpress.com/latex.php?latex=l&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='l' title='l' class='latex' /> is the length of the square&#8217;s side) and same base (<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%7B4%7D%5Ccdot%7Bl%7D%7D%7B7%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{{4}\cdot{l}}{7}' title='\frac{{4}\cdot{l}}{7}' class='latex' />).</p>
<p>The question then is, how do we make those 7 markings on the square? Let us first imagine that we peel off the edge and lay it out along a straight line. If there were some simple way to then divide the peeled out, straight line edge into 7 equal parts, we can visualize rolling the laid out edge back on to the square. Of course, the actual process would involve measuring the widths of each piece using the compass and then laying them back on the square&#8217;s border. At the corners these segments may have to be further broken down into two pieces. How to do that it is relatively intuitive with a compass and I will not go into explaining that. The next two figures illustrate the process of peeling off the edges of the square and laying them onto a straight line, and the process of rolling the laid out edge back on to the square once the 7 equidistant markings have been made.</p>
<p><img class="size-full wp-image-220 alignnone" title="sq_fig2" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/sq_fig21.gif" alt="" width="768" height="179" /></p>
<p><img class="size-full wp-image-221 alignnone" title="sq_fig3" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/sq_fig31.gif" alt="" width="768" height="147" /></p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/sq_fig63.gif"><br />
</a></p>
<p>The question now remains, how do we divide the laid out border into 7  equal pieces. More generally, this question can be posed as, how can we  divide any line segment into n equal segments.</p>
<p><img class="alignleft size-full wp-image-227" title="sq_fig6" src="http://flickeringtubelight.net/blog/wp-content/uploads/2010/05/sq_fig63.gif" alt="" width="376" height="512" />The figure to the left  illustrates the steps. The steps are labeled (a) through (e). In Step  (a), we draw a line using the straight edge at some angle to the line  segment to be divided. This edge is shown in a light color and its  length does not really matter. Then in Step (b) make 7 equidistant markings on the newly drawn line segment using the compass. The length between the markings does not matter. Just pick something that seems to fit in the space. Then, in Step (c), the 7th such marking and the end of the original line segment are joined. In Step (d), using the compass, identify a point corresponding to the 7th marking, on the other side of the base line segment. Connect the ends of the base line segment to that point and complete the paralellogram shown in the figure in Step (d). Using the compass mark out the other 6 markings on the line on the other side of the base line segment. This is shown in Step (e). Join the corresponding intermediate markings using the straight edge. Voila! The line segment we wanted to divide into 7 pieces just got divided into 7 equal pieces.</p>
<p>Now, by retracing the steps laid out in the figures above, you can divide the square into 7 equal regions. This question is also posed as, &#8220;How can you divide a square cake into n equal sized pieces?&#8221;. Now that we know how to divide a line into n equal parts using a straight edge and a compass, we may realize that there is a simpler way to divide up the square cake. Instead of dividing up the whole border into 7 equal-length line segments, why not just divide up one side into 7 equal length segments. Then we can cut the square into 7 long rectangles, in a fashion similar to the one proposed in the original puzzle (see the pdf slides posted at the beginning of this article).</p>
<p>This also brings up another interesting question, although quite off-topic, it may seem. We have been using the phrase straight edge throughout this article. But what is straight? How was the first straight edge made? My guess is that a taut string might have been used to define straightness. But then what is space itself is curved? Does that mean a taut string is also actually curved in accordance with the space it is in? What does it even mean to say that space is curved? Curved with respect to what? What is the underlying measure of straightness, against which the space appears curved? There are probably questions for another disussion. I do not know the answer. I will have to think and read a bunch before it may be clear. It may, of course, never be clear. There is no reason everything should make sense. Nature is not obligated to be understandable by humans, much less one particular human that I call me.</p>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2010/05/the-4-squares-problem-extended/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cool Gate-Level Logic Simulation Tool</title>
		<link>http://flickeringtubelight.net/blog/2009/11/cool-gate-level-logic-simulation-tool/</link>
		<comments>http://flickeringtubelight.net/blog/2009/11/cool-gate-level-logic-simulation-tool/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 15:49:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tidbits]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/2009/11/14/cool-gate-level-logic-simulation-tool/</guid>
		<description><![CDATA[Dr. Mark Hill of University of Wisconsin Madison pointed out the existence of this really cool learning aid to his class Logic Design class in October 2009. He also provides some guidelines about how to use the tool. Give it a shot if you like to play around with AND, OR, NOT gates and build [...]]]></description>
			<content:encoded><![CDATA[<p>Dr. Mark Hill of University of Wisconsin Madison pointed out the existence of this really cool learning aid to his class Logic Design class in October 2009. He also provides some guidelines about how to use the tool. Give it a shot if you like to play around with AND, OR, NOT gates and build logic. You can build &#8220;memory&#8221; structures too, something that can <em>remember</em> state. The following text is from Dr. Hill&#8217;s email. Enjoy.<span id="more-184"></span></p>
<p><span style="color: #000000;">Here is a cool tool for playing with and visualizing simple logic gates:</span></p>
<p><a href="http://joshblog.net/projects/logic-gate-simulator/Logicly.html"><span style="color: #000000;">http://joshblog.net/projects/logic-gate-simulator/Logicly.html</span></a></p>
<p><span style="color: #000000;">Build your own circuit:</span></p>
<p><span style="color: #000000;">(a) Drag over a few gates in the middle.<br />
(b) Drag few switches to the left side as inputs<br />
(c) Drag one or more light bulbs to right as output(s)<br />
(d) Connect items together with wires by clicking on needed endpoints.</span></p>
<p><span style="color: #000000;">Operate it:<br />
(e) Click on switches to toggle inputs between one (blue) and zero (white).<br />
(f) Watch the wires change state &#8212; one (blue) and zero (white) and light bulbs go on (blue) or off (off).</span></p>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2009/11/cool-gate-level-logic-simulation-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mau&#8217;s Question</title>
		<link>http://flickeringtubelight.net/blog/2008/05/maus-question/</link>
		<comments>http://flickeringtubelight.net/blog/2008/05/maus-question/#comments</comments>
		<pubDate>Sat, 24 May 2008 16:42:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tidbits]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/2008/05/24/maus-question/</guid>
		<description><![CDATA[There is a matrix of numbers with n rows and m columns. The matrix consists of integers taking the value 1 through n. That is, at any given cell in the matrix the value is 1 or 2 or 3 or &#8230; or n. We want to find out how many such matrices exist in [...]]]></description>
			<content:encoded><![CDATA[<p>There is a matrix of numbers with n rows and m columns. The matrix consists of integers taking the value 1 through n. That is, at any given cell in the matrix the value is 1 or 2 or 3 or &#8230; or n. We want to find out how many such matrices exist in which you can always find n cells, one per row, that together have all the n unique integers in them.</p>
<p>Here is my approach and my solution to the problem. This solution has not been verified by Mau or anyone else, and there is a chance that I am missing some aspect of rigor required to make the proof watertight and, thus, self-verifying.</p>
<h2>Approach</h2>
<p>The space of all nxm matrices can be divided into a disjoint set of matrices that completely span the space. This disjoint set comprises<br />
- matrices which have no row with all n numbers<br />
- matrices which have exactly one row that contains all n numbers<br />
- matrices which have exactly two rows that contain all the n numbers<br />
&#8230; so on till<br />
- matrices which have exactly n-1 rows that contain all the n numbers<br />
- matrices which have each of the n rows containing all the n numbers</p>
<p>Now we can solve the problem for each subset that makes up the disjoint set that spans the space of mxn matrices, and add up the individual results. Interestingly, working backwards makes more sense to me. So let&#8217;s look at the subset of matrices which have all the n numbers in each of the n nows. There is no candidate matrix here that fails our criterion. All matrices will satisfy the criterion. Let&#8217;s call the set of matrices that satisfy the criterion, the set S and those that fail the criterion the set F. Therefore no matrix in this subset adds to F.</p>
<p>Next, let&#8217;s look at the subset of matrices which have all the n numbers in exactly n-1 rows. The remaining row, whatever be the number or numbers it carries, will cause the matrix to satisfy the criterion. Therefore no matrix in this subset adds to F.</p>
<p>Next, let&#8217;s look at the subset of matrices which have all the n numbers in exactly n-2 rows. The remaining 2 rows, will cause the overall matrix to fail, if they have no more than 1 number in them. That is they remaining two rows must be full of only one number. If a second number exists in either of the two rows, the matrix satisfies our criterion.</p>
<p>And so on.</p>
<p>So, the number of matrices in F is a sum of the following product over all values of i:<br />
(how many ways can we select n-i rows)(how many ways can all n unique numbers show up in each of those selected rows)(how many ways can the remaining i rows contain, at most, i-1 unique numbers)</p>
<h2>Solution</h2>
<p>Basically, out of all possible matrices with n rows and m cols such that each element is an integer between 1 and n (both included), I try to figure out the number of matrices which do NOT satisfy the condition we are after, i.e., for these matrices you CANNOT select n elements, one on each row, such that the n elements are the n unique numbers, 1 through n. Call this set of matrices, which fail the condition, F (for fail). We are trying to find how many elements are in the set F.</p>
<p>The final answer for the number of matrices the satisfy the criteion, therefore, will be n^(n.m) &#8211; |F|, where |F| represents the cardinality of F, that is, the number of elements in set F.</p>
<p>To get to |F|, my line of thinking was:</p>
<p>F =<br />
matrices for which there are, at most, n-1 unique numbers in the n rows<br />
+ matrices for which there are, at most, n-2 unique numbers in n-1 rows and all n numbers in the remaining 1 row<br />
+ matrices for which there are n-3 unique numbers in n-2 rows and all n numbers in the remaining 2 rows + &#8230; etc.</p>
<p>By ensuring that all the n numbers show up in the remaining x rows we are making sure that the matrix that satisfies a given term in the above summation does not satisfy the the previous term, and thus avoids being double counted.</p>
<p>Substituting terms,</p>
<img src='http://s.wordpress.com/latex.php?latex=%7CF%7C%3D%7B%20%5En%7DC_n%7B%20%5En%7DC_%7Bn-1%7D%7B%20n-1%7D%5E%7Bnm%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='|F|={ ^n}C_n{ ^n}C_{n-1}{ n-1}^{nm}' title='|F|={ ^n}C_n{ ^n}C_{n-1}{ n-1}^{nm}' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=%2B%7B%20%5En%7DC_%7Bn-1%7D%7B%20%5En%7DC_%7Bn-2%7D%7B%20%28n-2%29%7D%5E%7B%28n-1%29m%7D%7B%20%28%28m-n%29%5En%5Cfrac%7Bm%21%7D%7B%28m-n%29%21%7D%29%5E1%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='+{ ^n}C_{n-1}{ ^n}C_{n-2}{ (n-2)}^{(n-1)m}{ ((m-n)^n\frac{m!}{(m-n)!})^1}' title='+{ ^n}C_{n-1}{ ^n}C_{n-2}{ (n-2)}^{(n-1)m}{ ((m-n)^n\frac{m!}{(m-n)!})^1}' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=%2B%7B%20%5En%7DC_%7Bn-2%7D%7B%20%5En%7DC_%7Bn-3%7D%7B%20%28n-3%29%7D%5E%7B%28n-2%29m%7D%7B%20%28%28m-n%29%5En%5Cfrac%7Bm%21%7D%7B%28m-n%29%21%7D%29%5E2%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='+{ ^n}C_{n-2}{ ^n}C_{n-3}{ (n-3)}^{(n-2)m}{ ((m-n)^n\frac{m!}{(m-n)!})^2}' title='+{ ^n}C_{n-2}{ ^n}C_{n-3}{ (n-3)}^{(n-2)m}{ ((m-n)^n\frac{m!}{(m-n)!})^2}' class='latex' /> + &#8230;</p>
<p>As a summation, this can be written as</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%7CF%7C%20%3D%5Cdisplaystyle%5Csum_%7Bi%3D0%7D%5E%7Bn-2%7D%7B%20%5En%7DC_%7Bn-i%7D%7B%20%5En%7DC_%7Bn-i-1%7D%7B%20%28n-i-1%29%7D%5E%7B%28n-i%29m%7D%7B%20%28%5Cfrac%7B%28m-n%29%5Enm%21%7D%7B%28m-n%29%21%7D%29%7D%5Ei&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='|F| =\displaystyle\sum_{i=0}^{n-2}{ ^n}C_{n-i}{ ^n}C_{n-i-1}{ (n-i-1)}^{(n-i)m}{ (\frac{(m-n)^nm!}{(m-n)!})}^i' title='|F| =\displaystyle\sum_{i=0}^{n-2}{ ^n}C_{n-i}{ ^n}C_{n-i-1}{ (n-i-1)}^{(n-i)m}{ (\frac{(m-n)^nm!}{(m-n)!})}^i' class='latex' />
<p>Here is how to understand each term in the summation above:<br />
<img src='http://s.wordpress.com/latex.php?latex=%5EnC_%7Bn-i%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='^nC_{n-i}' title='^nC_{n-i}' class='latex' /> is the number ways can you choose n-i rows<br />
<img src='http://s.wordpress.com/latex.php?latex=%5EnC_%7Bn-i-1%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='^nC_{n-i-1}' title='^nC_{n-i-1}' class='latex' />  is the number ways can you choose the n-i-1 numbers that will go into the selected n-i rows<br />
<img src='http://s.wordpress.com/latex.php?latex=%28n-i-1%29%5E%7B%28n-i%29m%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(n-i-1)^{(n-i)m}' title='(n-i-1)^{(n-i)m}' class='latex' /> is the number of ways can those (n-i).m elements in those n-i rows be filled with the chosen (n-i-1) numbers<br />
<img src='http://s.wordpress.com/latex.php?latex=%28%5Cfrac%7B%28m-n%29%5Enm%21%7D%7B%28m-n%29%21%7D%29%5Ei&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(\frac{(m-n)^nm!}{(m-n)!})^i' title='(\frac{(m-n)^nm!}{(m-n)!})^i' class='latex' /> is the number of ways we can guarantee that the remaining i rows each contain all the n elements.</p>
<p><span style="color: #888888;"> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2008/05/maus-question/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A puzzled family</title>
		<link>http://flickeringtubelight.net/blog/2007/04/a-puzzled-family/</link>
		<comments>http://flickeringtubelight.net/blog/2007/04/a-puzzled-family/#comments</comments>
		<pubDate>Mon, 23 Apr 2007 03:38:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tidbits]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/2007/04/22/a-puzzled-family/</guid>
		<description><![CDATA[This year started with several of my family members contributing several puzzles. I decided to compile them here since the puzzles were, firstly, interesting and secondly tell you a little bit about the people who asked them. Anant, my brother, sent the following in an email to me and my family. He said he found [...]]]></description>
			<content:encoded><![CDATA[<p>This year started with several of my family members contributing several puzzles. I decided to compile them here since the puzzles were, firstly, interesting and secondly tell you a little bit about the people who asked them. Anant, my brother, sent the following in an email to me and my family. He said he found it on an IBM puzzler website. He, however, modified it a bit to make it more interesting to us all. Here&#8217;s Anant&#8217;s puzzle.</p>
<h2>Anant&#8217;s Party Puzzle<strong> </strong></h2>
<p>Anil and Kavita attend a party with 3 other couples,including Srini and Shyamala (a couple). During the party everyone shakes hands with a certain number of other people that doesn&#8217;t include oneself and one&#8217;s spouse. At the end of the party Anil asks each person (apart from himself) how many people they shook hands with. He finds that each person answered truthfully and each one gave a different number. Anil did shake hands with Srini. From this information find out<br />
1: Did Kavita shake hands with Srini?<br />
2: Did Kavita shake hands with Shyamala?<br />
Adapted from a puzzle found here (the last but one puzzle June 1998): <a href="http://www.research.ibm.com/ponder/">http://www.research.ibm.com/ponder/</a></p>
<p>Solution:</p>
<p>Anil asks 7 people and gets 7 different handshake counts. The maximum count can be 6, since a person does not shake his own hand or his spouse&#8217;s. The 7 non-negative numbers (there cannot be negative counts) with a maximum of 6 are 0, 1, 2, 3, 4, 5, 6. Whoever has a count of 6 shakes hands with all the other people (other than his or her spouse, of course). Therefore, only that spouse can be the one with the 0 count. If Kavita were the person with the count of 6, no one but Anil could have had the count of 0. But Anil did hear someone else say 0. If Kavita were the person with a count of 0, no one else could have claimed 6. However, someone did. So Kavita does not have a count of 0 either. There is some couple with counts of 0 and 6. If that couple is removed from contention, everyone reduces in count by 1, the 1 coming from their handshake with the person with count 6. Anil and Kavita shook hands with one person in that couple (the one with the count 6). The remaining counts become 0, 1, 2, 3, 4. Whoever has the count of 4, partners the spouse with count of 0, using logic similar to above. Also, this couple cannot be Anil and Kavita. If Kavita had a count of 4, no one could have claimed a count of 0. If Kavita had a count of 0, no one could have claimed a 4. Therefore, the 4-0 pair is not Anil-Kavita. Again, Anil and Kavita shook hands with one person in that couple (the one with the count 4). Removing the 4-0 pair (originally the 5-1 pair) from contention, we have the counts of 0, 1, 2.</p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/partyhandshakes.gif"><img class="alignnone size-full wp-image-611" title="partyhandshakes" src="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/partyhandshakes.gif" alt="" width="720" height="540" /></a><br />
Using similar logic as above, the 2-0 pair is not Anil-Kavita. Removing them (original pair 4-2), leaves Kavita alone with the count of 0. Bumping it back to the original count gives us 3. Kavita and Anil shook hands with one person in each couple, and, Anil and Kavita shook hands with the exact same people. So, to answer the specific questions &#8211; Yes, Kavita shook hands with Srini, and, No, Kavita did not shake hands with Shyamala.</p>
<h2>Raghu&#8217;s Peanuts Puzzle<strong> </strong></h2>
<p>Later, when we visited my cousin and his family in New Jersey, he asked me and Anant a high protein mathematical puzzle laden with peanuts. I will recreate the puzzle from memory here.<br />
There are 5 friends and a pet monkey. They also have a bag of peanuts. The are travelling through a tropical jungle in southern India when they decide to stop for the night in a clearing. They pitch the tent and go to sleep. One of the 5 friend wakes up in the middle of the night, a little hungry. He remembers the peanuts. He steps out quietly, careful not to wake anyone up, with the peanuts bag, divides up the peanuts into 5 even parts. He finds one extra peanut remains after the division. He feeds the remaining peanut to the monkey, eats his share and goes back to sleep. The other 4 friends wake up one after the other also and do the exact same thing as the first guy. Then, morning comes. Everyone wakes up refreshed and, unsurprisingly, a little hungry. They divide up the peanuts in the clearly smaller looking bag. And again just like each of them had found in the night, they find one peanut remaining. They feed that to the monkey, taking the monkey&#8217;s total intake to 6 peanuts, and eat the remaining peanuts. How many peanuts were in the bag when they pitched the tent?</p>
<p>Solution:</p>
<p>Raghu had asked me this puzzle about 4 years ago, when I had visited them in Alpharetta (near Atlanta), Georgia. I am not sure if my then recent exposure to discrete mathematics at Purdue University helped, or, as might be more likely, my mathematical intuition worked better then. I was actually able to solve the puzzle without resorting to a spreadsheet or a computer! This time around I found it harder to imagine up a way to solve it without a computer. I did find the answer with a spreadsheet program, but that was hardly consequential. More than getting the answer, this exercise was, for me, a journey in figuring out how to solve it without a computer. And in doing so I learnt something about what such problems are called and a generic way to solve them. This problem appears in several places in the web with coconuts in place of peanuts. The solution also appears in several places. I will try to recreate my approach.</p>
<p>Say, the initial number of peanuts is N.<br />
When the first guy wakes up he sees N peanuts. When he is done eating there are (4/5)(N-1) peanuts.<br />
When the second guy wakes up he sees (4/5)(N-1) peanuts, which is<br />
(4/5)N &#8211; (4/5).<br />
Similarly, when the third guy wakes up he sees, (4/5)[(4/5)N - (4/5) - 1] peanuts, which is<br />
(4/5)<sup>2</sup>N &#8211; (4/5)<sup>2</sup> &#8211; (4/5)<br />
Extending the pattern, when the fourth guy wakes up he sees,<br />
(4/5)<sup>3</sup>N &#8211; (4/5)<sup>3</sup> &#8211; (4/5)<sup>2</sup> &#8211; (4/5) peanuts<br />
Extending the pattern, when the fifth guy wakes up he sees,<br />
(4/5)<sup>4</sup>N &#8211; (4/5)<sup>4</sup> &#8211; (4/5)<sup>3</sup> &#8211; (4/5)<sup>2</sup> &#8211; (4/5) peanuts<br />
When they all wake up the next morning, they all see,<br />
(4/5)<sup>5</sup>N &#8211; (4/5)<sup>5</sup> &#8211; (4/5)<sup>4</sup> &#8211; (4/5)<sup>3</sup> &#8211; (4/5)<sup>2</sup> &#8211; (4/5) peanuts<br />
This, is again divided evenly amongst the 5, after a peanut is given to the monkey. That implies that the above count of peanuts is precisely 5k + 1, where k is some integer.<br />
The final equation looks like,<br />
(4/5)<sup>5</sup>N &#8211; (4/5)<sup>5</sup> &#8211; (4/5)<sup>4</sup> &#8211; (4/5)<sup>3</sup> &#8211; (4/5)<sup>2</sup> &#8211; (4/5) = 5k + 1</p>
<p>This reduces to,<br />
(1024/3125)N-(1024/3125)-(256/625)-(64/125)-(16/25)-(4/5) = 5k+1<br />
=&gt; (1024/3125)N-(1024/3125)-(256/625)-(64/125)-(16/25)-(4/5)-1 = 5k<br />
=&gt; (1024/3125)(1/5)N-(1024/3125)(1/5)-(256/625)(1/5)-(64/125)(1/5)-(16/25)(1/5)-(4/5)(1/5)-1(1/5) = k<br />
=&gt; (1024/15625)N-(1024/15625)-(1280/15625)-(1600/15625)-(2000/15625)-(2500/15625)-(3125/15625) = k<br />
=&gt; (1024/15625)N-(11529/15625) = k<br />
=&gt; 1024N-11529 = 15625k<br />
=&gt; 1024N-15625k = 11529</p>
<p>Finally, we got the equation we were after. But wait a second, there are two variables(N and k) and only one equation! That is the equation of a line. You choose any value of N and you can always find a k. How are we to solve that for a single solution or a set of solutions?<br />
Aha! Integers. N and k can take only integral values. So, even though this is the equation for a line, we are trying to find out if this line passes through the lattice points. Such equations have a special name &#8211; Diophantine equations. The one at hand, specifically, is a Diophantine equation of the first order, in two variables. These equations have been studied and solved in texts written between 800 BC and 500 BC in India. Aryabhatta and Brahmagupta (around 400AD to 650AD) gave general solutions to such equations and extended the study to higher order Diophantine equations and ones with more variables.<br />
A generic Diophantine equation looks like ax + by = c, where x and y are the variables that must take integer values. a,b,c are integer constants. A equation of this type may have no solutions or infinitely many solutions. An example of an equation with no solutions is<br />
2x + 2y = 5 (No Solution!)<br />
The above equations has no solution because whatever the values of integral x and y, the left hand side is even and right hand side is odd.<br />
A way to think of it is, you can draw a line on a graph paper such that it neatly avoids all the lattice points. I am not sure about this, but intuition tells me that if a line does cross through one lattice point, it will cross through infinitely many. That is, in other words, there are are either no solutions or infinitely many for a given Diophanine equation of the above form.</p>
<p>Now, coming back to the equation at hand, it is easy to see why a spreadsheet is a tempting approach. You vary N from 1 through a big number. You write k in terms of N, and visually inspect if K ever takes an integer value. Though this approach is what I tried at first, it is both ugly, unsatisfactory and unbounded. There might be no way to figure out if there exists no solution!<br />
The solution that follows is based on the approach shown at this BBC webpage about <a href="http://www.bbc.co.uk/dna/h2g2/A964956">Diophantine equations</a>.</p>
<p>1024N-15625k = 11529<br />
Now pay careful attention. The right hand side (11529) is odd. The first term on the left hand side (1024N) will always be even, whatever the value of N. The second term on the left hand side (15625k) will be even if k is even, and odd if k is odd. If k is even, the whole left hand side will be even. But since the right hand side is odd, this can&#8217;t be. Therefore k must be odd. We can, therefore write k is 2a+1. And the equation becomes,<br />
1024N-15625(2a+1) = 11529<br />
1024N-2(15625)a &#8211; 15625 = 11529<br />
1024N-2(15625)a = 27154<br />
Now notice that all the terms have a common factor of 2, which when cancelled out, leaves<br />
512N-15625a = 13577, where k=2a+1<br />
Continuing the above logic, and successively substitution 2b+1 for a, 2c+1 for b etc, when a or b should be odd and 2b for a, 2c for b etc. when a or b should be even, we get the following equations.<br />
256N-15625b = 14601, where a=2b+1<br />
128N-15625c = 15113, where b=2c+1<br />
64N-15625d = 15369, where c=2d+1<br />
32N-15625e = 15497, where d=2e+1<br />
16N-15625f = 15561, where e=2f+1<br />
8N-15625g = 15593, where f=2g+1<br />
4N-15625h = 15609, where g=2h+1<br />
2N-15625i = 15617, where h=2i+1<br />
N-15625j = 15621, where i=2j+1<br />
The final equation gives us,<br />
N = 15621+15625j</p>
<p>The smallest positive solution therefore is N = 15621, when j = 0. This is one valid solution. Substituting N in the original Diophantine equation gives us k = 1023. So the 5 friends could have started with 15621 peanuts and had 1023 peanuts the next morning. Of course, they could have also started with 15625 + 15621 = 31246 peanuts (j=1 case) or even more.<br />
I vaguely remember that this is how I had solved it in Alpharetta, GA, four years ago, without knowing anything about Diophantine equations and Brahmagupta or relying on spreadsheets.</p>
<h2>My father&#8217;s Walkers Puzzle<strong> </strong></h2>
<p>Then, a few days back, my father, who loves his daily hour-long walks sent us this walking related puzzle. Later, when I wanted to confirm my answer, he informed me that he made the problem up but had not been able to solve it yet! The fact that he was able to think this up is by itself impressive considering the solution is not straightforward, yet, involves elegant abstraction. Since he thought this up when walking with his good friend who I call Subbanna Uncle, I will recreate the puzzle with my father, Kishore, and Subbanna Uncle participating in the activity.<br />
ABCD is a rectangular park with a walking trail on all four sides. The rectangle is of dimensions a units by b units.<br />
Two walking enthusiasts, Subbanna and Kishore, start walking around the park&#8217;s trail with same speed, S units per hour.<br />
Subbanna starts at A and goes around the park covering all 4 sides each time repetedly, AD-&gt;DC-&gt;CB-&gt;BA-&gt;AD-&gt;DC&#8230; and so on.<br />
Kishore starts at the same time as Subbanna but starts at B and walks around the park covering 3 sides repeatedly, BC-&gt;CD-&gt;DA then he turns back to trace AD-&gt;DC-&gt;CB, turns back again and so on.<br />
1: How many times do Subbanna and Kishore cross each other while walking for a time period of t hours?<br />
2: How many times do Subbanna and Kishore walk side by side in the same direction?<br />
3: What is the time period before the two walking routines repeat an earlier pattern?</p>
<p>Solution:</p>
<p>The park is a rectangle with sides measuring a units and b units as shown.</p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle1.gif"><img class="alignnone size-full wp-image-613" title="walkerPuzzle1" src="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle1.gif" alt="" width="177" height="139" /></a><br />
The pattern that Subbanna follows is shown with a yellow/orange line and the pattern that Kishore follows is shown with a green line.</p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle2.gif"><img class="alignnone size-full wp-image-614" title="walkerPuzzle2" src="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle2.gif" alt="" width="245" height="185" /></a><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle3.gif"><img class="alignnone size-full wp-image-615" title="walkerPuzzle3" src="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle3.gif" alt="" width="221" height="185" /></a></p>
<p>The beauty of this problem is that it is easier to solve the puzzle by opening up the paths. Both the paths taken by the two walkers are repetitive. What we need is a repetitive representation that would show intersections of the paths accurately, while clearly laying out the paths in time, so that a repetition does not overlap a previous representation. I chose to keep time on the x-axis and label the corners A,B,C,D on the y axis. The speed being constant keeps the path traced by the walkers straight lines on this graph, and also helps assign a scale for the x-axis.</p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle4.gif"><img class="alignnone size-full wp-image-616" title="walkerPuzzle4" src="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle4.gif" alt="" width="641" height="281" /></a><br />
Subbanna&#8217;s pattern repeats every (2b+2a)/S hours, while Kishore&#8217;s repeats every 2(2b+a)/S hours, as is clear from the graph. While Kishore is going in the BC-&gt;CD-&gt;DA direction (downward) he intersects Subbanna&#8217;s path once or twice. He cannot avoid intersecting because the distance between two parallel orange lines is less than the length of Kishore&#8217;s downward path. If Subbanna&#8217;s orange line intersects Kishore&#8217;s upward path (AD-&gt;DC-&gt;CB), that has to be the time they walk together.</p>
<p><a href="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle5.gif"><img class="alignnone size-full wp-image-617" title="walkerPuzzle5" src="http://flickeringtubelight.net/blog/wp-content/uploads/2007/04/walkerPuzzle5.gif" alt="" width="559" height="524" /></a><br />
After time t, the projection of time on to an axis parallel to Kishore&#8217;s downward path, is t*S distance units. This is shown as T is the figure, however, to avoid confusion let us continue to use S*t for that distance. In this time, every orange line (Subbanna&#8217;s one loop) causes an intersection with Kishore, except if they overlap. Put mathematically,<br />
the total number of intersections = total number of orange lines &#8211; number of times orange line and upward green line coincide<br />
total number of orange lines = (t*S &#8211; (2b+a)/2)/(b+a) + 1<br />
&#8220;number of times orange line and upward green line coincide&#8221; is a little more involved. The first time they coincide, (2b+a)/2+n*(b+a)=m*(2b+a), where m and n are integers. This implies,<br />
n*(b+a)=(m-1/2)*(2b+a)<br />
Multiplying by 2 on either side,<br />
2n*(b+a)=(2m-1)*(2b+a)<br />
If (b+a) and (2b+a) are integers,this will happen if 2b+a is even. If 2b+a is odd, this will never happen and Kishore and Subbanna&#8217;s paths never coincide. If (a+b) and (2b+a) are not integers, then I am not sure what the condition is for the paths to not coincide. I assume they will always coincide.<br />
From them on they coincide when k*(b+a)=l*(2b+a), which is every LCM(b+a, 2b+a) units.<br />
Therefore, &#8220;number of times orange line and upward green line coincide&#8221; = (0 or 1)+(S*t)/(LCM(b+a,2b+a))<br />
Here are the final answers:<br />
1: How many times do Subbanna and Kishore cross each other while walking for a time period of t hours?<br />
(t*S &#8211; (2b+a)/2)/(b+a) + 1 &#8211; (0 or 1) + (S*t)/(LCM(b+a,2b+a))<br />
2: How many times do Subbanna and Kishore walk side by side in the same direction?<br />
(0 or 1)+(S*t)/(LCM(b+a,2b+a))<br />
3: What is the time period before the two walking routines repeat an earlier pattern?<br />
The time period is when the original situation repeats. That is Kishore is at B and Subbanna is at A.<br />
LCM(2*(2b+a)/S, (2b+2a)/S)<br />
Note: I have used LCM for Least Common Multiple, and I do not restrict it to integers alone.</p>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2007/04/a-puzzled-family/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I don&#8217;t know. I don&#8217;t know. Now I know. Now I know!</title>
		<link>http://flickeringtubelight.net/blog/2006/09/i-dont-know-i-dont-know-now-i-know-now-i-know/</link>
		<comments>http://flickeringtubelight.net/blog/2006/09/i-dont-know-i-dont-know-now-i-know-now-i-know/#comments</comments>
		<pubDate>Sun, 03 Sep 2006 16:30:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tidbits]]></category>

		<guid isPermaLink="false">http://flickeringtubelight.net/blog/2006/09/03/i-dont-know-i-dont-know-now-i-know-now-i-know/</guid>
		<description><![CDATA[Question
My friend Srikanth, aka Coffee, sent this question to the egroups after hearing the one Anant had asked me.
A reporter meets two famous mathematicians P1 and P2 in a train and tells them that he is going to whisper the sum of two 2-digit numbers into P1&#8217;s ear and their product into P2&#8217;s, and then [...]]]></description>
			<content:encoded><![CDATA[<h2>Question</h2>
<p>My friend Srikanth, aka Coffee, sent this question to the egroups after hearing the one Anant had asked me.</p>
<p>A reporter meets two famous mathematicians P1 and P2 in a train and tells them that he is going to whisper the sum of two 2-digit numbers into P1&#8217;s ear and their product into P2&#8217;s, and then he wants them to guess what those two 2-digit numbers were. After he has whispered the sum and the product to P1 and P2 respectively, the conversation goes as follows:<br />
P1: I don&#8217;t know.<br />
P2: I don&#8217;t know either.<br />
P1: Now I know.<br />
P2: Now I know too.</p>
<p>What are the two numbers?</p>
<h2>Solution</h2>
<p>I ended up writing a program for this one too, although if there are paper-pencil or in-the-head kinds of solutions, I&#8217;d be happy to hear about those.</p>
<p>Lets take the statements one by one, and see how they reveal more and more detail. Notice that here P1 is the person with the SUM and P2 is the persone with the PRODUCT (other way round compared to the one Anant asked me). Also notice that since the range includes only 2-digit numbers, denoting the two numbers as X and Y, both X and Y lie between 10 and 99.</p>
<p><strong>P1 says: I don&#8217;t know.</strong><br />
<strong>Deduction:</strong> Not very surprising. Unless the sums were 20 , 21, 198 or 197, there are multiple ways to add two numbers to get a SUM in the range 20 to 198.</p>
<p><strong>P2 says: I don&#8217;t know either.</strong><br />
<strong>Deduction:</strong> X and Y are not primes, because if they were, then the product could have given away the factors. In fact, to make it more general, the product P = X*Y is such that there is more than one way to factorize it into valid factors (each factor lying between 10 and 99).</p>
<p><strong>P1 says: Now I know.</strong><br />
<strong>Deduction:</strong> P1 has a sum S = X+Y such that of all the ways to add up two legal numbers (between 10 and 99) to get S, there is exactly one pair (which P1 could therefore identify), for which the product has more than one valid factorization. If it were any other way of adding up two numbers to add to S, then P2 would have immediately identified the unique factorization.</p>
<p><strong>P2 says: Now I know too.</strong><br />
<strong>Deduction:</strong> P2 has a product PP = X*Y such that of all the valid (numbers between 10 and 99) ways to factorize it, there is only one pair that adds up to a sum that P1 could have identified. That is, only one factorization of P is such that if the factors were added, that sum could have been reached by only one pair of valid numbers, for the product of which multiple valid factorizations exist.</p>
<p>C Program to solve the same problem (specific to this range, but could be generalized and optimized to save time and space)</p>
<pre><font size="-1">
    #include &lt;stdlib.h&gt;
    #include &lt;stdio.h&gt;

    main(int argc, char** argv)
    {
      unsigned int i,j,k;

      unsigned int histProducts[10000];
      unsigned int X[10000];
      unsigned int Y[10000];
      unsigned int Z[10000];

      for(i=1;i&lt;10000;i++){
        histProducts[i]=0;
        X[i]=0;
        Y[i]=0;
        Z[i]=0;
      }
      for(i=10;i&lt;100;i++){
        for(j=10;j&lt;100;j++){
          if(i&lt;=j){
            k=i*j;
            histProducts[k]++;
            if(histProducts[k]==1) X[k]=i;
            else if (histProducts[k]==2) Y[k]=i;
            else if (histProducts[k]==3) Z[k]=i;
            //else printf("%d has more than 3 ways of factorizing", k);
          }
        }
      }

      unsigned int histNonUniqueProdsOfComponents[200];
      unsigned int A[200];
      unsigned int B[200];
      for(i=1;i&lt;200;i++){
        histNonUniqueProdsOfComponents[i]=0;
        A[i]=0;
        B[i]=0;
      }
      for(i=20;i&lt;197;i++){
        for(j=10;j&lt;=(i&gt;&gt;1);j++){
          if(j&gt;=10 &amp;&amp; j&lt;=99 &amp;&amp; (i-j)&gt;=10 &amp;&amp; (i-j)&lt;=99){
            if(histProducts[j*(i-j)]&gt;1){
              histNonUniqueProdsOfComponents[i]++;
              A[i]=j;
              B[i]=i-j;
            }
          }
        }
      }

      unsigned int foundValidProds;
      for(i=1;i&lt;200;i++){
        if(histNonUniqueProdsOfComponents[i]==1){
          foundValidProds=0;
          k=A[i]*B[i];
          printf("%d,%d SUM=%d PRODUCT=%d\n",A[i],B[i],A[i]+B[i],k);
          printf("For this PRODUCT %d, the following factorizations exist",k);
          if(histProducts[k]==2){
            printf(" %d*%d,",X[k], k/X[k]);
            printf(" %d*%d\n",Y[k], k/Y[k]);
            if(histNonUniqueProdsOfComponents[X[k]+k/X[k]]==1) foundValidProds++;
            if(histNonUniqueProdsOfComponents[Y[k]+k/Y[k]]==1) foundValidProds++;
            if(foundValidProds==1)
              printf("Of these factorizations only 1 could have been identified by the SUM guy--VALID\n\n");
            else if (foundValidProds&gt;1)
              printf("Of these factorizations &gt;1 could have been identified by the SUM guy\n\n");
            else
              printf("Something is wrong with this factorizations\n\n");
          }
          else if(histProducts[k]==3){
            printf(" %d*%d,",X[k], k/X[k]);
            printf(" %d*%d,",Y[k], k/Y[k]);
            printf(" %d*%d\n",Z[k], k/Z[k]);
            if(histNonUniqueProdsOfComponents[X[k]+k/X[k]]==1) foundValidProds++;
            if(histNonUniqueProdsOfComponents[Y[k]+k/Y[k]]==1) foundValidProds++;
            if(histNonUniqueProdsOfComponents[Z[k]+k/Z[k]]==1) foundValidProds++;
            if(foundValidProds==1)
              printf("Of these factorizations only one could have been identified by the SUM guy--VALID\n\n");
            else if (foundValidProds&gt;1)
              printf("And of these factorizations &gt;1 could have been identified by the SUM guy\n\n");
            else
             printf("Something is wrong with this factorizations\n\n");
          }
          else if(histProducts[k]&gt;3){
            printf(" %d*%d,",X[k], k/X[k]);
            printf(" %d*%d,",Y[k], k/Y[k]);
            printf(" %d*%d,",Z[k], k/Z[k]);
            printf(" OTHERS EXIST TOO\n\n");
          }
        }
      }

    }</font></pre>
]]></content:encoded>
			<wfw:commentRss>http://flickeringtubelight.net/blog/2006/09/i-dont-know-i-dont-know-now-i-know-now-i-know/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

