<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Sanity Phailed.me</title>
	
	<link>http://www.phailed.me</link>
	<description>Just another WordPress site.</description>
	<lastBuildDate>Sat, 18 May 2013 02:17:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SanityPhailedme" /><feedburner:info uri="sanityphailedme" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Subtype Ambiguity in Java</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/t3evJJj1l1E/</link>
		<comments>http://www.phailed.me/2013/05/subtype-ambiguity-in-java/#comments</comments>
		<pubDate>Sat, 18 May 2013 02:16:53 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Programming Language Theory]]></category>
		<category><![CDATA[types]]></category>
		<category><![CDATA[universal quantification]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1473</guid>
		<description><![CDATA[Let's take a look at an example of a situation where ambiguity occurs during the derivation of subtyping proofs in Java. In general, it's conjectured that subtyping in Java is undecidable. ]]></description>
				<content:encoded><![CDATA[<p></p><div class='toc tableofcontent'>
   <h2>Table Of Content</h2>
   <p class='contentTable_h3'><a href="#Subtyping_as_Inequalities">1. Subtyping as Inequalities</a></p>
<p class='contentTable_h3'><a href="#Most_Precise_Supertype">2. Most Precise Supertype</a></p>
<p class='contentTable_h3'><a href="#Problems">3. Problems</a></p>
<p class='contentTable_h4'><a href="#Wildcards_and_Bounded_Quantifiers">Wildcards and Bounded Quantifiers</a></p>
<p class='contentTable_h4'><a href="#No_least_upper_bound?">No least upper bound?</a></p>

</div><div class='tableofcontent-end'> </div><p></p>
<pre class="alignleft">
true ? 1 : "Hello"
</pre>
<p>Take a look at the Java expression on the left hand side. Off of the top of your head, can you tell me if it will type check? If so what will be its type?</p>
<p>If you had asked me this question out of the blue, I would have probably said no; I would reason it as follows: this is a Java expression, so it must be assigned a type, meaning that we&#8217;re giving a system of equations saying that the type of <code>1</code> and the type of <code>"Hello"</code> must be equal; this is clearly not the case as one is an Integer and the other a String, so this can&#8217;t possibly type check!</p>
<p>Of course, I&#8217;m actually just suffering from a common case of overlooking the obvious. It turns out that I&#8217;m forgetting about the whole subtyping thing built into Java and that I can actually assign <code>Object o = true ? 1 : "Hello";</code>, because the type <code>Object</code> sits at the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-efd6cdd671b24efd175d7f2e399038bd_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#111;&#112;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> of the type ordering. </p>
<h3 id="Subtyping_as_Inequalities">1. Subtyping as Inequalities</h3>
<p>Since we&#8217;re speaking of subtyping as a type relation anyways, let&#8217;s give it a symbolic name to make it easier for us: we&#8217;ll let <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1ca29400d75c092f1640de22d4f8f81a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#84;" title="Rendered by QuickLaTeX.com" height="11" width="11" style="vertical-align: 0px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0492a51f9722779ad8877c958c86b4b8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;" title="Rendered by QuickLaTeX.com" height="11" width="10" style="vertical-align: 0px;"/> range over types in Java, and we&#8217;ll say</p>
<p class="ql-center-displayed-equation" style="line-height: 13px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0af45fd71f47df320b6f3388e3af468f_l3.png" height="13" width="42" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#83;&#32;&#92;&#108;&#101;&#32;&#84;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>to mean that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0492a51f9722779ad8877c958c86b4b8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;" title="Rendered by QuickLaTeX.com" height="11" width="10" style="vertical-align: 0px;"/> is a subtype of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1ca29400d75c092f1640de22d4f8f81a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#84;" title="Rendered by QuickLaTeX.com" height="11" width="11" style="vertical-align: 0px;"/>. Under one interpretation, we can think of this as saying that if we&#8217;re expecting a <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1ca29400d75c092f1640de22d4f8f81a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#84;" title="Rendered by QuickLaTeX.com" height="11" width="11" style="vertical-align: 0px;"/> somewhere, we should theoretically be allowed to plug in a <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0492a51f9722779ad8877c958c86b4b8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;" title="Rendered by QuickLaTeX.com" height="11" width="10" style="vertical-align: 0px;"/> in its place and not expect weird or undefined behaviors as a result. Another perhaps more practical view is to claim that there exists some function called the coercion function (which we will denote, for the sake of historical consistency, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-6ee5e5d1a6c9fcb89eef179f0ac779cd_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#84;&#104;&#101;&#116;&#97;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/>) that, given some subtype relation <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-19f1c55ce5154113d04b18aa888870ae_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#32;&#92;&#108;&#101;&#32;&#84;" title="Rendered by QuickLaTeX.com" height="13" width="42" style="vertical-align: -2px;"/>, will be able to translate an object of type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0492a51f9722779ad8877c958c86b4b8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;" title="Rendered by QuickLaTeX.com" height="11" width="10" style="vertical-align: 0px;"/> into an object of type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1ca29400d75c092f1640de22d4f8f81a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#84;" title="Rendered by QuickLaTeX.com" height="11" width="11" style="vertical-align: 0px;"/> that behaves &#8220;similarly&#8221;.</p>
<p>Anyways, It&#8217;s obvious that both <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-58c59bde8318a820b1ddc9917b4db743_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#73;&#110;&#116;&#101;&#103;&#101;&#114;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#79;&#98;&#106;&#101;&#99;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="108" style="vertical-align: -3px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7a12716906a3fe8bbf22fafed11f949a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#79;&#98;&#106;&#101;&#99;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="103" style="vertical-align: -3px;"/> (since everything&#8217;s a subtype of Object), so we can draw a subtyping hierarchy as a tree:</p>
<p class="ql-center-picture"><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c06b85d4c49bd7cb49b2d60a884c2151_l3.png" height="76" width="105" class="ql-img-picture quicklatex-auto-format" alt="Rendered by QuickLaTeX.com" title="Rendered by QuickLaTeX.com"/></p>
<p>and we can type check <code>true?1:"Hello" : Object</code>. This seems to suggest that we can typecheck all instances of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-530f6d40b5595df33df8d9fa0ef52e8c_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#98;&#63;&#120;&#58;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="54" style="vertical-align: -4px;"/> to some type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-66a1ecf3cf058afbfbaeac1e0abb17da_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> if we can typecheck <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb7bdfdfe13d8e437dfb90c6def55187_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/> to <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0492a51f9722779ad8877c958c86b4b8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;" title="Rendered by QuickLaTeX.com" height="11" width="10" style="vertical-align: 0px;"/>, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9efc31a0aeb181b56ae54d62e74e24d0_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#121;" title="Rendered by QuickLaTeX.com" height="10" width="8" style="vertical-align: -3px;"/> to <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1ca29400d75c092f1640de22d4f8f81a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#84;" title="Rendered by QuickLaTeX.com" height="11" width="11" style="vertical-align: 0px;"/>, and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d6843dcb723939e984a03f27ae768a7c_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#44;&#84;&#32;&#92;&#108;&#101;&#32;&#82;" title="Rendered by QuickLaTeX.com" height="14" width="61" style="vertical-align: -3px;"/>. In otherwords, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-66a1ecf3cf058afbfbaeac1e0abb17da_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> is an upper bound of the types of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb7bdfdfe13d8e437dfb90c6def55187_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9efc31a0aeb181b56ae54d62e74e24d0_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#121;" title="Rendered by QuickLaTeX.com" height="10" width="8" style="vertical-align: -3px;"/>.</p>
<p>Of course, upon closer inspection, it turns out that both Integer and String share another common supertype: Serializable.</p>
<p class="ql-center-picture"><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-74f05c86ac5725fefd098e080de99cf1_l3.png" height="137" width="105" class="ql-img-picture quicklatex-auto-format" alt="Rendered by QuickLaTeX.com" title="Rendered by QuickLaTeX.com"/></p>
<p>So just as well, we could claim that the ternary expression above extends Serializable. But if we want to &#8220;assign&#8221; a type to an expression, we don&#8217;t just want its supertypes. </p>
<h3 id="Most_Precise_Supertype">2. Most Precise Supertype</h3>
<p>Looking at the type hierarchy above, it&#8217;s clear that the lower a type is on that hierarchy, the more &#8220;precise&#8221; it is. When we say that an expression has a type, we don&#8217;t mean that it is bounded above by some set of super types; we actually mean that its most &#8220;precise&#8221; type is so and so. For example, we could just as well draw the type hierarchy for Integers as</p>
<p class="ql-center-picture"><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5a5d763b6bb44ed89ebebfc741aa7c76_l3.png" height="137" width="76" class="ql-img-picture quicklatex-auto-format" alt="Rendered by QuickLaTeX.com" title="Rendered by QuickLaTeX.com"/></p>
<p>and claim that a <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-965650ff21500f974ae55c679f4bd397_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;" title="Rendered by QuickLaTeX.com" height="12" width="6" style="vertical-align: -1px;"/> is a Serializable; but when I typically talk about the type of the expression <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-965650ff21500f974ae55c679f4bd397_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;" title="Rendered by QuickLaTeX.com" height="12" width="6" style="vertical-align: -1px;"/>, I&#8217;m usually talking about Integer, not Serializable.</p>
<p>From this, it&#8217;s clear that we also want a way to find the most precise (smallest) type of <code>true ? 1 : "Hello"</code> such that it is also an upper bound of both <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-965650ff21500f974ae55c679f4bd397_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;" title="Rendered by QuickLaTeX.com" height="12" width="6" style="vertical-align: -1px;"/> and &#8220;Hello&#8221;; this is called the least upper bound, and we will for historical reasons call this the &#8220;join&#8221; of two types.</p>
<p>Symbolically, if we want to find the most precise upperbound (join) type of two types <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0492a51f9722779ad8877c958c86b4b8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;" title="Rendered by QuickLaTeX.com" height="11" width="10" style="vertical-align: 0px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1ca29400d75c092f1640de22d4f8f81a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#84;" title="Rendered by QuickLaTeX.com" height="11" width="11" style="vertical-align: 0px;"/>, we will denote it as <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-66a1ecf3cf058afbfbaeac1e0abb17da_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> such that</p>
<p class="ql-center-displayed-equation" style="line-height: 11px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-005baf6e4f2845202a93909086f2663e_l3.png" height="11" width="71" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#82;&#32;&#61;&#32;&#83;&#32;&#92;&#115;&#113;&#99;&#117;&#112;&#32;&#84;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>the reason that the least upper bound is usually denoted as a square union symbol is actually somewhat natural: the union of two sets is the least upper bound of those two sets in the partial order <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-863818b5d7a714ba3a60e1c44a5f4aac_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#115;&#117;&#98;&#115;&#101;&#116;&#101;&#113;" title="Rendered by QuickLaTeX.com" height="12" width="10" style="vertical-align: -2px;"/> (set inclusion), convince yourself that this is actually the case.</p>
<p>Note that whenever we join two types, the resulting type is &#8220;less precise&#8221;. We are after all finding an upper bound!</p>
<p>Going back to the problem at hand, the entire point of this exercise is then very simple: we want to find the least upper bound of Integer and String:</p>
<p class="ql-center-displayed-equation" style="line-height: 14px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4a41c11944d50d9fc94c9ad180fb1862_l3.png" height="14" width="101" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#73;&#110;&#116;&#101;&#103;&#101;&#114;&#125;&#32;&#92;&#115;&#113;&#99;&#117;&#112;&#32;&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>We&#8217;ve already seen earlier that both Object and Serializable are upper bounds of both Integer and String, but we also know that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b63fcd5a082b7021f8dfa16e41b3dc32_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#83;&#101;&#114;&#105;&#97;&#108;&#105;&#122;&#97;&#98;&#108;&#101;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#79;&#98;&#106;&#101;&#99;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="136" style="vertical-align: -3px;"/>, so Serializable is a more precise (less) upper bound than Object is, but is Serializable the most precise? </p>
<p>In order to answer this question and find the least upper bound, we&#8217;re going to need the complete subtyping hierarchy. Consulting the Java documentation, we find that Integer is a subtype of Numbers, which are Serializable, and are themselves Comparable with other Integers. Furthermore, Strings are also Serializable and Comparable with other Strings! This gives the slightly more convoluted typing hierarchy:</p>
<p class="ql-center-picture"><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4eede59e2670272bd8789346f6507aeb_l3.png" height="197" width="290" class="ql-img-picture quicklatex-auto-format" alt="Rendered by QuickLaTeX.com" title="Rendered by QuickLaTeX.com"/></p>
<h3 id="Problems">3. Problems</h3>
<p>At first first glance, it doesn&#8217;t seem possible that there&#8217;s a least upper bound: it seems like both Comparable and Serializable are the most precise upper bounds. Furthermore, this isn&#8217;t even necessarily true as Comparable itself might be too imprecise. </p>
<h4 id="Wildcards_and_Bounded_Quantifiers">Wildcards and Bounded Quantifiers</h4>
<p>Consider the constraint</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4d3945adbe4239cdf232690f2843038a_l3.png" height="16" width="220" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#32;&#92;&#115;&#113;&#99;&#117;&#112;&#32;&#92;&#103;&#123;&#73;&#110;&#116;&#101;&#103;&#101;&#114;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>now, we know that</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-890f53cae3d588af5266a8fb7c35b3c4_l3.png" height="16" width="402" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#125;&#44;&#32;&#92;&#103;&#123;&#73;&#110;&#116;&#101;&#103;&#101;&#114;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#92;&#103;&#123;&#73;&#110;&#116;&#101;&#103;&#101;&#114;&#125;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>so we can rewrite this as</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bc473d9f532c8255e2ec06c0966cf4c3_l3.png" height="16" width="316" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#126;&#92;&#103;&#123;&#101;&#120;&#116;&#101;&#110;&#100;&#115;&#125;&#126;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>by plugging in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-01be25831a95c7ee11b71fa41764b896_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="158" style="vertical-align: -4px;"/> into the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0dfe126e6d5ad52c3ca8f297df12d847_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="40" style="vertical-align: -3px;"/> in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c38f7e4a023e92b472c791128b3df1c9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="129" style="vertical-align: -4px;"/>. (Wildcards, amiright?) Similarly, we can say the same about integers, so we get</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5602d36c653046e00aab4f8ce8e685a6_l3.png" height="16" width="378" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#32;&#92;&#115;&#113;&#99;&#117;&#112;&#32;&#92;&#103;&#123;&#73;&#110;&#116;&#101;&#103;&#101;&#114;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#126;&#92;&#103;&#123;&#101;&#120;&#116;&#101;&#110;&#100;&#115;&#125;&#126;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>but we <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5a7dfaa7dba691e3d9df887ebf1173f2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#126;&#92;&#103;&#123;&#101;&#120;&#116;&#101;&#110;&#100;&#115;&#125;&#126;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#125;&#32;&#92;&#108;&#101;&#32;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="374" style="vertical-align: -4px;"/>, so a more precise upper bound of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e50cbfe5b984a1b1f1f544b38dc6f890_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#83;&#116;&#114;&#105;&#110;&#103;&#125;&#92;&#115;&#113;&#99;&#117;&#112;&#32;&#92;&#103;&#123;&#73;&#110;&#116;&#101;&#103;&#101;&#114;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="103" style="vertical-align: -3px;"/> is <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b5d4eab3433954cd4b6186323616ca3e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#126;&#92;&#103;&#123;&#101;&#120;&#116;&#101;&#110;&#100;&#115;&#125;&#126;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="255" style="vertical-align: -4px;"/>. But now, we can construct a sequence</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5d8d89ecb63e412468da9eaebe4fce6e_l3.png" height="16" width="104" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#44;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d5b93b89806c8a83192f3dbc98dfec73_l3.png" height="16" width="263" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#126;&#92;&#103;&#123;&#101;&#120;&#116;&#101;&#110;&#100;&#115;&#125;&#126;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#125;&#44;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-47af617d5de19db9be42efbb1f9f19d6_l3.png" height="16" width="421" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#126;&#92;&#103;&#123;&#101;&#120;&#116;&#101;&#110;&#100;&#115;&#125;&#126;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#126;&#92;&#103;&#123;&#101;&#120;&#116;&#101;&#110;&#100;&#115;&#125;&#126;&#92;&#103;&#123;&#67;&#111;&#109;&#112;&#97;&#114;&#97;&#98;&#108;&#101;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#125;&#125;&#44;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p class="ql-center-displayed-equation" style="line-height: 13px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f8455db2b3fb5204572adc62c2579bfb_l3.png" height="13" width="2" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#118;&#100;&#111;&#116;&#115;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>each of which a more precise approximation than the previous, which undoubtedly converges to the most precise type: and here&#8217;s the kicker, that type cannot be expressed finitely!</p>
<p>So how does Java handle these types? Let&#8217;s try it out. I wanted Java to output the internal type representation, so I need to get a type-mismatch error during compile time. </p>
<p><a href="http://ideone.com/DaYOr2">Comparable Type</a></p>
<p>It seems as if Java is reporting the type of the two as an unbounded quantification: just <code>Comparable&lt;?></code>. This is intentional, Java treats the <code>? extends ...</code> as a constraint (or a system of inequalities) and discards them during type checking and coercion in order to use them later solely for typechecking, so we seemed to have for now solved the problem (So even though <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-2e05ac54602717abc0277158f43179e2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#65;&#92;&#98;&#97;&#123;&#63;&#126;&#92;&#103;&#123;&#101;&#120;&#116;&#101;&#110;&#100;&#115;&#125;&#126;&#92;&#103;&#123;&#65;&#125;&#92;&#98;&#97;&#123;&#63;&#125;&#125;&#32;&#92;&#108;&#101;&#32;&#65;&#92;&#98;&#97;&#123;&#63;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="179" style="vertical-align: -4px;"/>, we&#8217;re going to treat them as if they weren&#8217;t).</p>
<h4 id="No_least_upper_bound?">No least upper bound?</h4>
<p>But we still have another problem, there&#8217;s is no least upper bound in the above hierarchy! Again, let&#8217;s see what Java does:</p>
<p><a href="http://ideone.com/DaYOr2">Intersection Type</a></p>
<p>It turns out that the least upper bound is just the &#8220;intersection&#8221; over the three types, which should then be the LEAST upper-bound of all three.</p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/t3evJJj1l1E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2013/05/subtype-ambiguity-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2013/05/subtype-ambiguity-in-java/</feedburner:origLink></item>
		<item>
		<title>Neat way of counting OCaml objects satisfying certain types</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/jB7DWsEkJx0/</link>
		<comments>http://www.phailed.me/2013/03/neat-way-of-counting-ocaml-objects-satisfying-certain-types/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 02:15:01 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[OCaml]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1385</guid>
		<description><![CDATA[We use a very natural semantic translation from OCaml styled types (or really any almost algebraic types) to the count of the instances of those types and do some cool stuff with this translation.]]></description>
				<content:encoded><![CDATA[<p>Full Disclosure: this isn&#8217;t mine. I got the idea from <a href="http://www.youtube.com/watch?v=YScIPA8RbVE">http://www.youtube.com/watch?v=YScIPA8RbVE</a> and the book Analytic Combinatorics from Robert Sedgewick and Philippe Flajolet. I just thought the entire concept is really really neat.</p>
<p></p><div class='toc tableofcontent'>
   <h2>Table Of Content</h2>
   <p class='contentTable_h3'><a href="#Types_in_">1. Types in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fa0054c531509f74e411525aa7de9e15_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#123;&#79;&#67;&#97;&#109;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="54" style="vertical-align: -1px;"/></a></p>
<p class='contentTable_h3'><a href="#Counting_instances">2. Counting instances</a></p>
<p class='contentTable_h4'><a href="#One_or_unit">One or unit</a></p>
<p class='contentTable_h4'><a href="#Two_or_bool">Two or bool</a></p>
<p class='contentTable_h4'><a href="#Three">Three</a></p>
<p class='contentTable_h4'><a href="#Four">Four</a></p>
<p class='contentTable_h4'><a href="#Eight">Eight</a></p>
<p class='contentTable_h3'><a href="#The_Translation">3. The Translation</a></p>
<p class='contentTable_h4'><a href="#Translational_Equivalence">Translational Equivalence</a></p>
<p class='contentTable_h3'><a href="#Examples">4. Examples</a></p>
<p class='contentTable_h4'><a href="#Associativity">Associativity</a></p>
<p class='contentTable_h4'><a href="#Distributivity">Distributivity</a></p>
<p class='contentTable_h4'><a href="#Parameterized_Types_(Advanced,_skip_if_you_want)">Parameterized Types (Advanced, skip if you want)</a></p>
<p class='contentTable_h4'><a href="#Lists_&#8211;_the_easier_way">Lists &#8211; the easier way</a></p>
<p class='contentTable_h4'><a href="#Unheaded_List_&#8211;_unsolvable">Unheaded List &#8211; unsolvable</a></p>
<p class='contentTable_h4'><a href="#Binary_Trees">Binary Trees</a></p>

</div><div class='tableofcontent-end'> </div><p></p>
<p>If you&#8217;re like me, you spend your flight pondering the deepest and darkest corners of human knowledge, like</p>
<ol>
<li>was the cashier flirting with me? (she wasn&#8217;t)</li>
<li>which one is better, the integral or the derivative? (definitely the derivative)</li>
<li>are we there yet? (no.) </li>
<li>are airlines the mortal enemies of tall people? (they are)</li>
</ol>
<p>Of course, after a day of mentally exhausting travel, I&#8217;d like to sit back, relax, and ask myself how, given a specific type declaration in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fa0054c531509f74e411525aa7de9e15_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#123;&#79;&#67;&#97;&#109;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="54" style="vertical-align: -1px;"/>, I can figure out the number of all possible instances of that type.</p>
<p>For example, there is just one instance of the type <tt>unit</tt> (kind of funny because its name is unit) corresponding to the object <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-929b94578eb1e891d41ff4b121537e23_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="10" style="vertical-align: -4px;"/> in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fa0054c531509f74e411525aa7de9e15_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#123;&#79;&#67;&#97;&#109;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="54" style="vertical-align: -1px;"/>. There are two distinct instances of the type <tt>bool</tt> corresponding to the set <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-72224c17b1b51426fd22a65e8083b296_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#82;&#101;&#99;&#123;&#92;&#84;&#114;&#117;&#101;&#44;&#92;&#70;&#97;&#108;&#115;&#101;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="83" style="vertical-align: -4px;"/>, and about <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7ba45a1a6b917d05dd91f7d53cf132bd_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#50;&#94;&#123;&#51;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="20" style="vertical-align: 0px;"/> distinct instances of the type <tt>int</tt>.</p>
<h3 id="Types_in_">1. Types in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fa0054c531509f74e411525aa7de9e15_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#123;&#79;&#67;&#97;&#109;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="54" style="vertical-align: -1px;"/></h3>
<p>Now, before we go on any further, let&#8217;s first take a look at the syntax of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fa0054c531509f74e411525aa7de9e15_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#123;&#79;&#67;&#97;&#109;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="54" style="vertical-align: -1px;"/> types.<br />
<center><br />
<code><br />
type suit = Diamond | Club | Heart | Spade<br />
</code><br />
</center></p>
<p>this type declaration says that we want to create a new type whose instances are either labeled Diamond, Club, Heart, or Spade. The labels are capitalized to mean that they can serve as constructors of the type. So if you type in Diamond into the OCaml, it&#8217;ll construct an object of type suit corresponding to the Diamond label. Note that Diamond isn&#8217;t itself a type here.</p>
<p>It&#8217;s quite obvious that there are 4 distinct instances of the type suit that we can construct, namely <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-56fdfdecaac3729754ce48ccf73bdd83_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#82;&#101;&#99;&#123;&#92;&#103;&#123;&#68;&#105;&#97;&#109;&#111;&#110;&#100;&#125;&#44;&#92;&#103;&#123;&#67;&#108;&#117;&#98;&#125;&#44;&#92;&#103;&#123;&#72;&#101;&#97;&#114;&#116;&#125;&#44;&#92;&#103;&#123;&#83;&#112;&#97;&#100;&#101;&#125;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="199" style="vertical-align: -4px;"/>. </p>
<p>We can also give each type constructor some extra stuff. For example, if we want types corresponding to the individual cards rather than suits, we can write something like<br />
<center><br />
<code><br />
type card = Diamond of int | Club of int | Heart of int | Spade of int<br />
</code><br />
</center></p>
<p>so that we can construct an instance of the card Jack of Clubs as <tt>Club 11</tt>. Here, there are <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-2b77704a114ee0f1f94ef10b101e9d7a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#52;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#50;&#94;&#123;&#51;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="47" style="vertical-align: -1px;"/> different instances of the type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3e53dcde2c0ed5a9c67b0a1d4becb4c3_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#99;&#97;&#114;&#100;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="26" style="vertical-align: 0px;"/> (we&#8217;re only familiar with 52 of these). Alternatively, we can also write each card as a pair of a suit and an integer.<br />
<center><br />
<code><br />
type card = Card of (suit * int)<br />
</code><br />
</center></p>
<p>here, the notation <tt>suit * int</tt> stands for types whose objects are pairs, the first element of which is an instance of a suit and the second an integer; for example, <tt>Card (Club, 11)</tt> would be the jack of clubs.</p>
<p>One really interesting thing to observe here is that the two different ways of writing the card type above should be equivalent. In each, we are specifying a suit and also a value. Therefore, if there are <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-2b77704a114ee0f1f94ef10b101e9d7a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#52;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#50;&#94;&#123;&#51;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="47" style="vertical-align: -1px;"/> distinct instances of the first type, there should also be <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-2b77704a114ee0f1f94ef10b101e9d7a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#52;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#50;&#94;&#123;&#51;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="47" style="vertical-align: -1px;"/> instances of the second type, and it turns out, there are.</p>
<p>Furthermore, if we want to &#8220;parameterize&#8221; the types to be more generalized, we can do so by introducing type variables (variables that corresponds to types) as <tt>'x</tt> that starts with a single apostrophe. So for example, if we want to build a linked list of whatever type we want, we could do something like<br />
<center><br />
<code><br />
type 'x list = Null | Cons ('x * 'x list)<br />
</code><br />
</center></p>
<p>where the list <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-453d3ac7d0494c71605572de4eeccb15_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#91;&#49;&#44;&#50;&#44;&#51;&#93;" title="Rendered by QuickLaTeX.com" height="16" width="44" style="vertical-align: -4px;"/> of type <tt>int list</tt> (so we make the substitution <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f06999a1986618fbfd18e48e4f504aab_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#39;&#120;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#92;&#103;&#123;&#105;&#110;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="55" style="vertical-align: -1px;"/>) is constructed from <tt>Cons(1, Cons(2, Cons(3, Null)))</tt>.</p>
<p>A binary tree can be build up like<br />
<center><br />
<code><br />
type 'x tree = Leaf | Node of ('x tree * 'x * 'x tree)<br />
</code><br />
</center></p>
<p>where the tree</p>
<p class="ql-center-picture"><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f15cae707f538769c6ad73f3600c4078_l3.png" height="133" width="98" class="ql-img-picture quicklatex-auto-format" alt="Rendered by QuickLaTeX.com" title="Rendered by QuickLaTeX.com"/></p>
<p>has type <tt>int tree</tt> (so we make the substitution <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f06999a1986618fbfd18e48e4f504aab_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#39;&#120;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#92;&#103;&#123;&#105;&#110;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="55" style="vertical-align: -1px;"/>) is constructed from</p>
<pre>
Node(
    Node(Leaf, 2, Leaf),
  1,
    Node(
        Node(Leaf, 4, Leaf),
      3,
        Node(Leaf, 5, Leaf)
)
</pre>
<h3 id="Counting_instances">2. Counting instances</h3>
<h4 id="One_or_unit">One or unit</h4>
<p>Now, we get to the interesting part. As discussed previously, we have already established that there&#8217;s only one object of the <tt>unit</tt> type (just <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-929b94578eb1e891d41ff4b121537e23_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="10" style="vertical-align: -4px;"/>) and two (True and False) of the boolean type. Of course, there&#8217;s also only one object of the type<br />
<center><br />
<code><br />
type one = One<br />
</code><br />
</center></p>
<p>and in fact, we can rename the constructor to anything (assuming that we don&#8217;t care about it being valid ocaml code) including the unit object <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-929b94578eb1e891d41ff4b121537e23_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="10" style="vertical-align: -4px;"/>, so it turns out that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-929b94578eb1e891d41ff4b121537e23_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="10" style="vertical-align: -4px;"/> is equivalent to all types with a single constructor and equivalence isn&#8217;t effected under renaming of the constructor (well, there are certain rules to this renaming/substitution, and we&#8217;ll call this property <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8e61018d29d96adeb89e8b882d25b953_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#97;&#108;&#112;&#104;&#97;" title="Rendered by QuickLaTeX.com" height="7" width="10" style="vertical-align: 0px;"/> equivalence). But is this the only property that preserves the count of the number of instances? Well, no, as it turns out, the following all only have one element.<br />
<center><br />
<code><br />
type one' = One' of unit<br />
type one'' = One'' of one'<br />
...<br />
</code><br />
</center></p>
<p>this is intuitive, if we have only one possible object for the argument of the constructor, and we only have that one constructor, then we can only construct one object for that type. In fact, from now on, we will say that an argument-less type construct <tt>C</tt> is just a syntax sugar for <tt>C of unit</tt> because doing so will not change the number of instances for that type.</p>
<h4 id="Two_or_bool">Two or bool</h4>
<p>We&#8217;ve also established that there are two instances of booleans, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-2f6a1970d6e7bdf4251d0e0ccc2ab829_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#116;&#114;&#117;&#101;&#125;" title="Rendered by QuickLaTeX.com" height="9" width="26" style="vertical-align: 0px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-13bc618afc7ebe88f48c0e548c324585_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#102;&#97;&#108;&#115;&#101;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="29" style="vertical-align: 0px;"/>. In type parlance, this would be<br />
<center><br />
<code><br />
type bool = True | False<br />
</code><br />
</center></p>
<p>but remember earlier that we said if we give a type constructor not expecting any argument the unit argument, the type&#8217;s size is preserved. Therefore, we can rewrite the above as<br />
<center><br />
<code><br />
type bool = True of unit | False of unit<br />
</code><br />
</center></p>
<p>and since renaming things doesn&#8217;t affect the size of the set of objects satisfying this type, this is also equivalent to<br />
<center><br />
<code><br />
type two = One of unit | Two of unit<br />
</code><br />
</center></p>
<p>Neat. Let&#8217;s count up one more.</p>
<h4 id="Three">Three</h4>
<p>There&#8217;s no native type in \f{OCaml} that only contains three instances, but it&#8217;s not too hard to guess how we&#8217;re going to construct this.<br />
<center><br />
<code><br />
type three = One of unit | Two of unit | Three of unit<br />
</code><br />
</center></p>
<p>Here, we can either have <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d37593de251aed0fe90954ca6c0ac47f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#123;&#79;&#110;&#101;&#125;&#40;&#41;&#44;&#92;&#102;&#123;&#84;&#119;&#111;&#125;&#40;&#41;&#44;" title="Rendered by QuickLaTeX.com" height="16" width="100" style="vertical-align: -4px;"/> or <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f5c1b116e561fd37fde97afda2a09198_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#123;&#84;&#104;&#114;&#101;&#101;&#125;&#40;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="60" style="vertical-align: -4px;"/> as instances of the type <tt>three</tt>. This gives a natural meaning to the notion of &#8220;or&#8221;. If I have types <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3b847538d72cf29f89280df6e002096f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;" title="Rendered by QuickLaTeX.com" height="7" width="8" style="vertical-align: 0px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-461af449b51dbd474bcbf1275fff7621_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#98;" title="Rendered by QuickLaTeX.com" height="11" width="7" style="vertical-align: 0px;"/>, then the type</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a7ee9d65c6ea6142615dbea539207f47_l3.png" height="16" width="155" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#116;&#121;&#112;&#101;&#125;&#126;&#99;&#32;&#61;&#32;&#92;&#103;&#123;&#65;&#32;&#111;&#102;&#32;&#125;&#97;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#66;&#32;&#111;&#102;&#32;&#125;&#32;&#98;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>can either be one the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb9289bc2121338aeab50383634e21d0_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#65;&#126;&#97;" title="Rendered by QuickLaTeX.com" height="11" width="25" style="vertical-align: 0px;"/> or one of the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a2a1d73e985930cb5ff32349d7eed539_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#66;&#126;&#98;" title="Rendered by QuickLaTeX.com" height="11" width="25" style="vertical-align: 0px;"/>, but since the two cases are necessarily distinct (because the label <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8ff66a52818b38eedcfc9d28ff3f0e67_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#65;&#32;&#92;&#110;&#101;&#32;&#66;" title="Rendered by QuickLaTeX.com" height="16" width="45" style="vertical-align: -4px;"/>), then if there are <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d34eb323dc0512289b275ca6169f8014_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;&#95;&#97;" title="Rendered by QuickLaTeX.com" height="9" width="16" style="vertical-align: -2px;"/> objects of type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3b847538d72cf29f89280df6e002096f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;" title="Rendered by QuickLaTeX.com" height="7" width="8" style="vertical-align: 0px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-2a074204788f1572847588373f8a2dec_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;&#95;&#98;" title="Rendered by QuickLaTeX.com" height="10" width="15" style="vertical-align: -3px;"/> objects of type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-461af449b51dbd474bcbf1275fff7621_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#98;" title="Rendered by QuickLaTeX.com" height="11" width="7" style="vertical-align: 0px;"/>, there must be <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3045303e4129dc04f8d3f5dcfb12a054_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;&#95;&#97;&#32;&#43;&#32;&#110;&#95;&#98;" title="Rendered by QuickLaTeX.com" height="13" width="51" style="vertical-align: -3px;"/> objects of type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ce75c738ecd523cd8341bb252d8f4ce1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#99;&#32;&#61;&#32;&#97;&#32;&#92;&#109;&#105;&#100;&#32;&#98;" title="Rendered by QuickLaTeX.com" height="16" width="56" style="vertical-align: -4px;"/>.</p>
<p>It&#8217;s no coincidence either that the type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ce75c738ecd523cd8341bb252d8f4ce1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#99;&#32;&#61;&#32;&#97;&#32;&#92;&#109;&#105;&#100;&#32;&#98;" title="Rendered by QuickLaTeX.com" height="16" width="56" style="vertical-align: -4px;"/> is called a sum type between <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3b847538d72cf29f89280df6e002096f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;" title="Rendered by QuickLaTeX.com" height="7" width="8" style="vertical-align: 0px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-461af449b51dbd474bcbf1275fff7621_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#98;" title="Rendered by QuickLaTeX.com" height="11" width="7" style="vertical-align: 0px;"/> (albeit for different reasons). Now that we&#8217;re warming to the notion that we can use these types almost as if we did in highschool algebra, let&#8217;s make some simplifications:</p>
<p>Since we do not ever care about what the labels themselves are, only that they are distinct, we can entirely leave out the labels for the type constructors. Therefore, we can write suit (<tt>type suit = Diamond of unit | Club of unit | ...</tt>) as</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fbe0ed91de60b7dce399756a441536a0_l3.png" height="16" width="186" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#115;&#117;&#105;&#116;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>and the card type as either</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bd291f2645def4d294328ca0f501104d_l3.png" height="16" width="158" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#99;&#97;&#114;&#100;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#105;&#110;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#105;&#110;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#105;&#110;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#105;&#110;&#116;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>or as</p>
<p class="ql-center-displayed-equation" style="line-height: 11px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-86d9b582d026432fa84e0de3861af05b_l3.png" height="11" width="113" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#99;&#97;&#114;&#100;&#39;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#115;&#117;&#105;&#116;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#103;&#123;&#105;&#110;&#116;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>where the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c10266747d8c938dd0096a24d9075a26_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#105;&#109;&#101;&#115;" title="Rendered by QuickLaTeX.com" height="8" width="8" style="vertical-align: 0px;"/> means the objects are of a pair type (with both a first and a second element). Note that we can also substitute suit directly in this type as in the second declaration of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e8d3abe0a326df17fefe76134a1d19b6_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#99;&#97;&#114;&#100;&#39;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="30" style="vertical-align: 0px;"/>:</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1cf75abce3403141e4e09e2bbb1b8acb_l3.png" height="16" width="243" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#99;&#97;&#114;&#100;&#39;&#125;&#32;&#61;&#32;&#92;&#112;&#97;&#123;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#103;&#123;&#105;&#110;&#116;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>it&#8217;s no coincidence that there are also <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-87f0372ba7cfb867d1b511868bc8307b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#49;&#32;&#43;&#32;&#49;&#32;&#43;&#32;&#49;&#32;&#43;&#32;&#49;&#41;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#50;&#94;&#123;&#51;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="18" width="139" style="vertical-align: -4px;"/> objects of type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e8d3abe0a326df17fefe76134a1d19b6_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#99;&#97;&#114;&#100;&#39;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="30" style="vertical-align: 0px;"/>, but it&#8217;s also obvious that the two types are not <b>equal</b> syntactically. That is, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9a8b7c8e5c880bcc4369707a84bfefac_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#99;&#97;&#114;&#100;&#39;&#125;&#32;&#92;&#110;&#101;&#32;&#92;&#103;&#123;&#99;&#97;&#114;&#100;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="79" style="vertical-align: -4px;"/>.</p>
<p>Of course, it&#8217;s useful to construct another equivalence relation whereby type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3b847538d72cf29f89280df6e002096f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;" title="Rendered by QuickLaTeX.com" height="7" width="8" style="vertical-align: 0px;"/> is <b>translationally equivalent</b> to type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-461af449b51dbd474bcbf1275fff7621_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#98;" title="Rendered by QuickLaTeX.com" height="11" width="7" style="vertical-align: 0px;"/> if both have the same number of type objects. In that case, we&#8217;ll say <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1a1878d357feb917836a82095de6c3fa_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#32;&#92;&#99;&#105;&#114;&#99;&#101;&#113;&#32;&#98;" title="Rendered by QuickLaTeX.com" height="11" width="36" style="vertical-align: 0px;"/>. As you probably have already guessed, we&#8217;re going to define some kind of a translation between these <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fa0054c531509f74e411525aa7de9e15_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#123;&#79;&#67;&#97;&#109;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="54" style="vertical-align: -1px;"/> types into numbers <b>denoting</b> the number of objects of that type. We&#8217;ll go into detail more, but needless to say, we would translate <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-6253a3a73161742023308e6af7f5fcc7_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#32;&#92;&#109;&#105;&#100;&#32;&#98;" title="Rendered by QuickLaTeX.com" height="16" width="28" style="vertical-align: -4px;"/> as <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c8d280a750ffa7d5dd4f5f68ee9b66f6_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#32;&#43;&#32;&#98;" title="Rendered by QuickLaTeX.com" height="12" width="34" style="vertical-align: -1px;"/>.</p>
<h4 id="Four">Four</h4>
<p>Okay, at this point, we kind of already know what we are after. But first, I want to establish some basic laws seen in school algebra.</p>
<p>Recall that </p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ea0e15b156333a2723b46d70dfdced64_l3.png" height="16" width="232" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#102;&#111;&#117;&#114;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#115;&#117;&#105;&#116;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>and that</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-2a065d500a8771ec2fa25dabf96b37a8_l3.png" height="16" width="158" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#116;&#119;&#111;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#98;&#111;&#111;&#108;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>Now, obviously,</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-92d3e57b9807dda845311c834d42e6ff_l3.png" height="16" width="107" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#103;&#123;&#102;&#111;&#117;&#114;&#125;&#32;&#92;&#99;&#105;&#114;&#99;&#101;&#113;&#32;&#92;&#103;&#123;&#116;&#119;&#111;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#103;&#123;&#116;&#119;&#111;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>but let&#8217;s look at something else. Suppose we have a pair type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b5f2e66c40d0fd3c1a756cb503d5794b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#99;" title="Rendered by QuickLaTeX.com" height="7" width="7" style="vertical-align: 0px;"/> such that</p>
<p class="ql-center-displayed-equation" style="line-height: 9px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-33cd4bd28fa486cb046c1e2be5039911_l3.png" height="9" width="93" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#99;&#32;&#61;&#32;&#92;&#103;&#123;&#116;&#119;&#111;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#103;&#123;&#116;&#119;&#111;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>now, there are again four instances of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b5f2e66c40d0fd3c1a756cb503d5794b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#99;" title="Rendered by QuickLaTeX.com" height="7" width="7" style="vertical-align: 0px;"/>, they are</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f9c983dfea90823fcbe17bf769a3e03b_l3.png" height="16" width="173" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#82;&#101;&#99;&#123;&#40;&#49;&#44;&#49;&#41;&#44;&#40;&#49;&#44;&#50;&#41;&#44;&#40;&#50;&#44;&#49;&#41;&#44;&#40;&#50;&#44;&#50;&#41;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>so it seems as if <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0c6157cabcbe9586f378135320e1a5f5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#116;&#119;&#111;&#125;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#103;&#123;&#116;&#119;&#111;&#125;&#32;&#92;&#99;&#105;&#114;&#99;&#101;&#113;&#32;&#92;&#103;&#123;&#102;&#111;&#117;&#114;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="113" style="vertical-align: 0px;"/> as well. In fact it&#8217;s not hard to show that product types correspond to multiplication in the same that cartesian products corresponds to multiplication of the cardinality. (In fact, this question reduces to the cardinality of sets case). </p>
<h4 id="Eight">Eight</h4>
<p>Just to get to the point, how many functions are there for which the domain is of size <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-13c9e17167ca07cc3ed437ff2c9b9427_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#51;" title="Rendered by QuickLaTeX.com" height="11" width="8" style="vertical-align: 0px;"/> and the codomain is of size <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b4e694c25395f6a24271c6000d2b11c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#50;" title="Rendered by QuickLaTeX.com" height="11" width="7" style="vertical-align: 0px;"/>? For example, suppose that I have the type </p>
<p class="ql-center-displayed-equation" style="line-height: 12px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-60f5a97c95786868e814ce4deafc33b5_l3.png" height="12" width="108" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#99;&#32;&#61;&#32;&#92;&#103;&#123;&#116;&#104;&#114;&#101;&#101;&#125;&#32;&#92;&#116;&#111;&#32;&#92;&#103;&#123;&#116;&#119;&#111;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-40ccfb9c19a2ba4992ae4adaa512ef59_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#116;&#111;&#32;&#92;&#99;&#100;&#111;&#116;" title="Rendered by QuickLaTeX.com" height="9" width="31" style="vertical-align: -1px;"/> is taken to mean a function that maps a type with three elements to a type with two. Well, in general, suppose I have a function <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3dcbb0f1005af5361a9a96e4ab9a3d52_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#65;&#32;&#92;&#116;&#111;&#32;&#66;" title="Rendered by QuickLaTeX.com" height="12" width="48" style="vertical-align: -1px;"/>, then it turns out that there are <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-09b27473dcfc6ffb5e64b735831895ca_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#124;&#66;&#124;&#94;&#123;&#124;&#65;&#124;&#125;" title="Rendered by QuickLaTeX.com" height="19" width="34" style="vertical-align: -4px;"/> such functions: reduce this problem to counting in base <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-505d4893a28d79a627a2c0fd6bf355fa_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#124;&#66;&#124;" title="Rendered by QuickLaTeX.com" height="16" width="19" style="vertical-align: -4px;"/>.</p>
<p>Suppose I have <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-dd5a0513622a0b803d395dd955b709de_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#124;&#65;&#124;" title="Rendered by QuickLaTeX.com" height="16" width="18" style="vertical-align: -4px;"/> elements in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-683d80b272150d2b5729e434550252f2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#65;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> that need to be mapped into <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-26c6cad4c1f8b8030e3a97d25ab0e480_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#66;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/>. Suppose both <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-683d80b272150d2b5729e434550252f2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#65;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-26c6cad4c1f8b8030e3a97d25ab0e480_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#66;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> are finite and are order into the sequences <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5fdb2cc82edb0beb6bba6627e0254986_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#95;&#49;&#44;&#32;&#97;&#95;&#50;&#44;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#44;&#32;&#97;&#95;&#123;&#124;&#65;&#124;&#125;" title="Rendered by QuickLaTeX.com" height="13" width="96" style="vertical-align: -6px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3867987c013fc5bfd59ea33d7f1c9120_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#98;&#95;&#49;&#44;&#32;&#98;&#95;&#50;&#44;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#44;&#32;&#98;&#95;&#123;&#124;&#66;&#124;&#125;&#32;&#92;&#105;&#110;&#32;&#66;" title="Rendered by QuickLaTeX.com" height="17" width="126" style="vertical-align: -6px;"/> respectively, then I can encode one such function</p>
<p class="ql-center-displayed-equation" style="line-height: 20px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5ff7ec6269b30b51954f96f7c5fee03f_l3.png" height="20" width="326" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#102;&#95;&#48;&#32;&#58;&#32;&#65;&#32;&#92;&#116;&#111;&#32;&#66;&#32;&#61;&#32;&#92;&#82;&#101;&#99;&#123;&#97;&#95;&#48;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#98;&#95;&#48;&#44;&#32;&#97;&#95;&#49;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#98;&#95;&#48;&#44;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#44;&#32;&#97;&#95;&#123;&#124;&#65;&#124;&#125;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#98;&#95;&#48;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>and a second function</p>
<p class="ql-center-displayed-equation" style="line-height: 20px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-03ae07344bd74b7d665ef1741fe862d3_l3.png" height="20" width="352" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#102;&#95;&#49;&#32;&#58;&#32;&#65;&#32;&#92;&#116;&#111;&#32;&#66;&#32;&#61;&#32;&#92;&#82;&#101;&#99;&#123;&#97;&#95;&#48;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#98;&#95;&#48;&#44;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#44;&#32;&#97;&#95;&#123;&#124;&#65;&#124;&#45;&#49;&#125;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#98;&#95;&#48;&#44;&#32;&#97;&#95;&#123;&#124;&#65;&#124;&#125;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#98;&#95;&#49;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>but since we don&#8217;t really want to clutter up the notation with all of the braces, the subscripts, and everything, we could just encode each function as a stream of digits where the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0acd245360372a05af0eb2fc3e137baa_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#100;&#95;&#116;&#104;" title="Rendered by QuickLaTeX.com" height="13" width="22" style="vertical-align: -2px;"/> digit = <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e25a983cd96d14229395e4640986596f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;" title="Rendered by QuickLaTeX.com" height="11" width="8" style="vertical-align: 0px;"/> corresponds to which <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5c21e352d89dbd6ac181d4fe737b254d_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#98;&#95;&#107;" title="Rendered by QuickLaTeX.com" height="14" width="14" style="vertical-align: -3px;"/> the element <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-23d1c04a4727fd5fbaf5118ae8818f74_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#95;&#100;" title="Rendered by QuickLaTeX.com" height="10" width="15" style="vertical-align: -3px;"/> maps to. Then, we can just write</p>
<p class="ql-center-displayed-equation" style="line-height: 141px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f480c1decd53f39a98846bfbe1cff292_l3.png" height="141" width="170" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#102;&#95;&#48;&#32;&#38;&#61;&#32;&#48;&#48;&#92;&#99;&#100;&#111;&#116;&#115;&#48;&#48;&#32;&#92;&#92; &#102;&#95;&#49;&#32;&#38;&#61;&#32;&#48;&#48;&#92;&#99;&#100;&#111;&#116;&#115;&#48;&#49;&#32;&#92;&#92; &#102;&#95;&#50;&#32;&#38;&#61;&#32;&#48;&#48;&#92;&#99;&#100;&#111;&#116;&#115;&#48;&#50;&#32;&#92;&#92; &#102;&#95;&#123;&#124;&#66;&#124;&#45;&#49;&#124;&#125;&#32;&#38;&#61;&#32;&#48;&#48;&#92;&#99;&#100;&#111;&#116;&#115;&#48;&#40;&#124;&#66;&#124;&#45;&#49;&#41;&#32;&#92;&#92; &#102;&#95;&#123;&#124;&#66;&#124;&#125;&#32;&#38;&#61;&#32;&#48;&#48;&#92;&#99;&#100;&#111;&#116;&#115;&#49;&#48;&#32;&#92;&#92; &#38;&#92;&#118;&#100;&#111;&#116;&#115; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>but this is the same as counting up to <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bd45e8b8a714664c8f54cd9a77f1eaf7_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#124;&#66;&#124;&#94;&#123;&#124;&#65;&#124;&#125;&#45;&#49;" title="Rendered by QuickLaTeX.com" height="19" width="63" style="vertical-align: -4px;"/> in base <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-505d4893a28d79a627a2c0fd6bf355fa_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#124;&#66;&#124;" title="Rendered by QuickLaTeX.com" height="16" width="19" style="vertical-align: -4px;"/>.</p>
<p>Anyways, from this argument, we would expect <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1f7efcbc02cb3d65fdd9db10d5dd35a5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#99;&#32;&#61;&#32;&#92;&#103;&#123;&#116;&#104;&#114;&#101;&#101;&#125;&#32;&#92;&#116;&#111;&#32;&#92;&#103;&#123;&#116;&#119;&#111;&#125;" title="Rendered by QuickLaTeX.com" height="12" width="108" style="vertical-align: -1px;"/> to have <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-aefe38e5168819205898d2380aae9c11_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#56;" title="Rendered by QuickLaTeX.com" height="11" width="8" style="vertical-align: 0px;"/> distinct objects, and hence <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-63c54a7b6e136f01533f3d9489e168f9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#99;&#32;&#92;&#99;&#105;&#114;&#99;&#101;&#113;&#32;&#92;&#103;&#123;&#101;&#105;&#103;&#104;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="61" style="vertical-align: -3px;"/>.</p>
<h3 id="The_Translation">3. The Translation</h3>
<p>Let&#8217;s now define a translation between a simplified type declaration and a number denoting the total number of objects with that type declaration. We&#8217;ll write this relation <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-6513b12c51f982b7dc1f7d530131a617_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#99;&#100;&#111;&#116;&#125;&#58;&#32;&#92;&#103;&#123;&#116;&#121;&#112;&#101;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#69;" title="Rendered by QuickLaTeX.com" height="16" width="87" style="vertical-align: -4px;"/>. For now, pretend that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4dddd60401cb52b3b8a8574310d19fb1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#69;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> is the naturals <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e5ab585a3ecc947179a580d1bc3d55f7_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#66;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="10" style="vertical-align: 0px;"/>, but this will cause some subtle issues later on because we might not be able to translate certain types (like the list) directly into <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4bfcc5863f49b8551410ac72eb53b044_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#78;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="11" style="vertical-align: 0px;"/>. Furthermore, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d140b184d66ef442b90b2b32603e4496_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#99;&#100;&#111;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="13" style="vertical-align: -4px;"/> is almost a function, but as discussed a few seconds ago, if we let <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4dddd60401cb52b3b8a8574310d19fb1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#69;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> be the naturals, it will not be able to translate certain types, so at best, it is a partial function. In that case, we will use the syntax <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-438ac98bf26edfa088f6b2bd75a8c696_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#99;&#125;&#32;&#61;&#32;&#110;" title="Rendered by QuickLaTeX.com" height="16" width="47" style="vertical-align: -4px;"/> to mean that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-348a10b4b70a22d612ceae2f01ddb263_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#99;&#44;&#110;&#41;&#32;&#92;&#105;&#110;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#99;&#100;&#111;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="68" style="vertical-align: -4px;"/>.</p>
<p>To define this translation, let&#8217;s do it &#8220;recursively&#8221;. The validity of such a technique is beyond my scope, but convince yourself that because the right hand side is always translating smaller and smaller pieces, then eventually, the translation of any arbitrary type will terminate. Here, I will use <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-24d54020db72317ba1f427ad765ccf64_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#97;&#117;" title="Rendered by QuickLaTeX.com" height="7" width="8" style="vertical-align: 0px;"/> to mean some type expression; that is, we will use it as a metavariable over the domain of types. Assume the same precedence level of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9780e789ca752bd764a73cbf1be32582_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#109;&#105;&#100;&#44;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#44;&#32;&#92;&#116;&#111;" title="Rendered by QuickLaTeX.com" height="16" width="44" style="vertical-align: -4px;"/> as <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-96aeaed966dd7780e46633e0b063f002_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#43;&#44;&#92;&#116;&#105;&#109;&#101;&#115;&#44;" title="Rendered by QuickLaTeX.com" height="13" width="35" style="vertical-align: -3px;"/> and power in school algebra.</p>
<p class="ql-center-displayed-equation" style="line-height: 115px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5127c66cb4267f229dd442b04026a617_l3.png" height="115" width="188" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#125;&#32;&#38;&#61;&#32;&#49;&#32;&#92;&#92; &#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#32;&#38;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#32;&#92;&#92; &#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#32;&#38;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#32;&#92;&#92; &#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#92;&#116;&#111;&#32;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#32;&#38;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#94;&#123;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#125;&#32;&#92;&#92; &#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#126;&#92;&#103;&#123;&#116;&#121;&#112;&#101;&#125;&#125;&#32;&#38;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#116;&#121;&#112;&#101;&#125;&#92;&#82;&#101;&#99;&#123;&#39;&#120;&#32;&#92;&#109;&#97;&#112;&#115;&#116;&#111;&#32;&#92;&#116;&#97;&#117;&#125;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Next, we define a notion of translational equivalence.</p>
<h4 id="Translational_Equivalence">Translational Equivalence</h4>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1af373877d31492199bddda54e2de755_l3.png" height="16" width="166" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#92;&#99;&#105;&#114;&#99;&#101;&#113;&#32;&#92;&#116;&#97;&#117;&#95;&#50;&#32;&#92;&#105;&#102;&#102;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#32;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>note that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-10ac48735a5b6b75d295c24ed93c52c0_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#99;&#105;&#114;&#99;&#101;&#113;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 2px;"/> is a weaker notion of syntactic equality of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-821b7566f70055102ca3a7976e9c0b80_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#61;" title="Rendered by QuickLaTeX.com" height="4" width="12" style="vertical-align: 2px;"/>, therefore, if <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-361c39f2115fe1e71cfc9ca74c9cdfc7_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#61;&#32;&#92;&#116;&#97;&#117;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="10" width="47" style="vertical-align: -3px;"/>, then so too must <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b13858cff82d63b699e3616178eb6e63_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#92;&#99;&#105;&#114;&#99;&#101;&#113;&#32;&#92;&#116;&#97;&#117;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="14" width="47" style="vertical-align: -3px;"/> owing to the fact that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d140b184d66ef442b90b2b32603e4496_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#99;&#100;&#111;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="13" style="vertical-align: -4px;"/> is a partial function. Furthermore, because of the construction of the sequence</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-cf2c2e324808191ce7498a6c83f48006_l3.png" height="16" width="247" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#82;&#101;&#99;&#123;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#44;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#109;&#105;&#100;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#44;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#109;&#105;&#100;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#109;&#105;&#100;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#44;&#92;&#99;&#100;&#111;&#116;&#115;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>then <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d140b184d66ef442b90b2b32603e4496_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#99;&#100;&#111;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="13" style="vertical-align: -4px;"/> is obviously onto <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4dddd60401cb52b3b8a8574310d19fb1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#69;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/>. However, because we need to have this notion of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-10ac48735a5b6b75d295c24ed93c52c0_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#99;&#105;&#114;&#99;&#101;&#113;" title="Rendered by QuickLaTeX.com" height="9" width="12" style="vertical-align: 2px;"/>, it&#8217;s also very obvious that two different type expressions could have the same number of instances and hence <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d140b184d66ef442b90b2b32603e4496_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#99;&#100;&#111;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="13" style="vertical-align: -4px;"/> is not one-one.</p>
<h3 id="Examples">4. Examples</h3>
<p>We&#8217;re going to take some extraordinary risks here (because we&#8217;re not mathematicians) and assume that this translation is correct (there are in fact many problems). Let&#8217;s do something with this new translation of ours</p>
<h4 id="Associativity">Associativity</h4>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-2fda926b7ccb4f6be802c92d745b4b8d_l3.png" height="16" width="308" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#32;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#32;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#32;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<h4 id="Distributivity">Distributivity</h4>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fde4a490f801917842a9f34d227b92ba_l3.png" height="16" width="510" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#40;&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#116;&#97;&#117;&#95;&#50;&#41;&#92;&#116;&#105;&#109;&#101;&#115;&#92;&#116;&#97;&#117;&#95;&#51;&#125;&#32;&#61;&#32;&#40;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#41;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#51;&#125;&#32;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#125;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#51;&#125;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#50;&#125;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#51;&#125;&#32;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#116;&#97;&#117;&#95;&#49;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#97;&#117;&#95;&#51;&#32;&#92;&#109;&#105;&#100;&#32;&#92;&#116;&#97;&#117;&#95;&#50;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#97;&#117;&#95;&#51;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>in fact, under translational equality, we can manipulate types algebraically as if in school algebra. More amazingly, that means that we can encode everything the same exact way. Therefore, if we wanted to pass around an object of type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c2c8ccb8b0803ff70802168fa11a5d81_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#101;&#105;&#103;&#104;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="33" style="vertical-align: -3px;"/>, then we can instead pass around an object of type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e7073270f710caa56ff84c037339431a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#116;&#104;&#114;&#101;&#101;&#125;&#32;&#92;&#116;&#111;&#32;&#92;&#103;&#123;&#98;&#111;&#111;&#108;&#125;" title="Rendered by QuickLaTeX.com" height="12" width="85" style="vertical-align: -1px;"/> instead!</p>
<h4 id="Parameterized_Types_(Advanced,_skip_if_you_want)">Parameterized Types (Advanced, skip if you want)</h4>
<p>Suppose we wanted to translate the list type above:</p>
<p class="ql-center-displayed-equation" style="line-height: 18px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1f6f974db0cc16a2f7de42e16c7c142e_l3.png" height="18" width="46" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#126;&#92;&#103;&#123;&#108;&#105;&#115;&#116;&#125;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>unfortunately, we don&#8217;t have a definition of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-18c0e1007112b6af96a314673086aa2a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#108;&#105;&#115;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="19" style="vertical-align: 0px;"/>. Rather, we merely have an equation that is expected to be satisfied in order for an object to be considered an instance of the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-18c0e1007112b6af96a314673086aa2a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#108;&#105;&#115;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="19" style="vertical-align: 0px;"/> type. This equation is</p>
<p class="ql-center-displayed-equation" style="line-height: 18px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-90167750a970b53114f7ecbab724bb8d_l3.png" height="18" width="166" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#39;&#120;&#32;&#126;&#32;&#92;&#103;&#123;&#108;&#105;&#115;&#116;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#39;&#120;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#39;&#120;&#126;&#92;&#103;&#123;&#108;&#105;&#115;&#116;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>it turns out that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7e101c35faa9d986910deb21e553c1a2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#39;&#120;&#126;&#92;&#103;&#123;&#108;&#105;&#115;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="13" width="38" style="vertical-align: 0px;"/> is the least fixed point of the function <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-676cd9fbdf520fab2a8de4814cd46752_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;&#40;&#92;&#116;&#97;&#117;&#41;&#32;&#61;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#109;&#105;&#100;&#32;&#39;&#120;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#97;&#117;" title="Rendered by QuickLaTeX.com" height="17" width="132" style="vertical-align: -4px;"/>. This is going a bit beyond the scope of this post, but that least fixed point can be computed on the ordering of immediate sub-type expression which turns the sequence <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3ef08d85344b9022ecbeeac0685b8b43_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;&#94;&#110;&#40;&#92;&#103;&#123;&#118;&#111;&#105;&#100;&#125;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="58" style="vertical-align: -4px;"/> into a complete partial order (complete because all subsets contain a least upper bound). Therefore, by the fixed point theorem, that least upper bound is the mysterious expression (where <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3a3f0ead318dbdf24f4996617615aa41_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#98;&#105;&#103;&#115;&#113;&#99;&#117;&#112;" title="Rendered by QuickLaTeX.com" height="17" width="13" style="vertical-align: -4px;"/> means the least upper bound)</p>
<p class="ql-center-displayed-equation" style="line-height: 33px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-6442529c409f3bad2c663824d1e8f797_l3.png" height="33" width="156" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#82;&#94;&#42;&#40;&#92;&#103;&#123;&#118;&#111;&#105;&#100;&#125;&#41;&#32;&#61;&#32;&#92;&#98;&#105;&#103;&#115;&#113;&#99;&#117;&#112;&#95;&#110;&#32;&#82;&#94;&#110;&#40;&#92;&#103;&#123;&#118;&#111;&#105;&#100;&#125;&#41;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>now, the translation function is &#8220;continuous&#8221; in the sense that it preserves least upper bounds on the CPO <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4dddd60401cb52b3b8a8574310d19fb1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#69;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/>. (Of course, this is why we can&#8217;t have <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4dddd60401cb52b3b8a8574310d19fb1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#69;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> = <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4ced9b10c775ae94370b4e7a8ebd81f3_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#90;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="10" style="vertical-align: 0px;"/>), but loosely speaking, the operations can be substituted as</p>
<p class="ql-center-displayed-equation" style="line-height: 22px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f7f8147096dcf9676ccc0597871c626d_l3.png" height="22" width="153" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#98;&#105;&#103;&#115;&#113;&#99;&#117;&#112;&#125;&#32;&#92;&#116;&#114;&#105;&#97;&#110;&#103;&#108;&#101;&#113;&#32;&#92;&#109;&#97;&#120;&#44;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#118;&#111;&#105;&#100;&#125;&#125;&#32;&#61;&#32;&#48;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>therefore,</p>
<p class="ql-center-displayed-equation" style="line-height: 125px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-73351c0344709a0c0d1ef6f9c99dc55b_l3.png" height="125" width="503" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#126;&#92;&#103;&#123;&#108;&#105;&#115;&#116;&#125;&#125;&#32;&#38;&#61;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#98;&#105;&#103;&#115;&#113;&#99;&#117;&#112;&#95;&#110;&#32;&#82;&#94;&#110;&#40;&#92;&#103;&#123;&#118;&#111;&#105;&#100;&#125;&#41;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#109;&#97;&#120;&#92;&#82;&#101;&#99;&#123;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#118;&#111;&#105;&#100;&#125;&#44;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#109;&#105;&#100;&#32;&#39;&#120;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#103;&#123;&#118;&#111;&#105;&#100;&#125;&#125;&#44;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#109;&#105;&#100;&#32;&#39;&#120;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#40;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#92;&#109;&#105;&#100;&#32;&#39;&#120;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#103;&#123;&#118;&#111;&#105;&#100;&#125;&#41;&#125;&#44;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#109;&#97;&#120;&#92;&#82;&#101;&#99;&#123;&#48;&#44;&#32;&#49;&#44;&#32;&#49;&#43;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#44;&#32;&#49;&#43;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#43;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#94;&#50;&#44;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#115;&#117;&#109;&#95;&#107;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#94;&#110; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>unfortunately, if <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-db1d5548c1c8f06cc799493ae0698405_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#39;&#120;&#32;&#92;&#110;&#111;&#116;&#92;&#99;&#105;&#114;&#99;&#101;&#113;&#32;&#92;&#103;&#123;&#118;&#111;&#105;&#100;&#125;" title="Rendered by QuickLaTeX.com" height="17" width="60" style="vertical-align: -4px;"/>, the above sum diverges to the top element in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4dddd60401cb52b3b8a8574310d19fb1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#69;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/>, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-efd6cdd671b24efd175d7f2e399038bd_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#111;&#112;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/>.</p>
<p>However, an interesting question arises that this type of analysis can readily answer: how many instances of the list type are translationally equivalent to the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ac360276039a23ef5aa6155959c5d4c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/>-tuple. In this case, it turns out that for whatever base-type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-cccdb60bea3ccf67ac8b759c18c3d19e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#39;&#120;" title="Rendered by QuickLaTeX.com" height="13" width="13" style="vertical-align: 0px;"/>, there are exactly <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ff1730e87be784b98739b72a3c019b9c_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#94;&#110;" title="Rendered by QuickLaTeX.com" height="17" width="30" style="vertical-align: -4px;"/> lists.</p>
<p>Of course, there&#8217;s a slightly easier hack which comes from the above derivation directly (namely because the translation preserves monotonicity, verify this!).</p>
<h4 id="Lists_&#8211;_the_easier_way">Lists &#8211; the easier way</h4>
<p>Why don&#8217;t we just translate the equation directly?</p>
<p>We&#8217;ll get</p>
<p class="ql-center-displayed-equation" style="line-height: 162px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-166f505ce91c3c2302b266b6cffcec20_l3.png" height="162" width="399" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#108;&#125;&#32;&#38;&#61;&#32;&#49;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#108;&#125;&#32;&#92;&#92; &#92;&#105;&#110;&#116;&#101;&#114;&#116;&#101;&#120;&#116;&#123;&#115;&#117;&#98;&#115;&#116;&#105;&#116;&#117;&#116;&#105;&#110;&#103;&#32;&#105;&#110;&#32;&#36;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#108;&#125;&#32;&#61;&#32;&#49;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#108;&#125;&#36;&#32;&#105;&#110;&#116;&#111;&#32;&#116;&#104;&#101;&#32;&#114;&#105;&#103;&#104;&#116;&#32;&#104;&#97;&#110;&#100;&#32;&#115;&#105;&#100;&#101;&#125; &#38;&#61;&#32;&#49;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#40;&#49;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#108;&#125;&#41;&#32;&#92;&#92; &#38;&#92;&#118;&#100;&#111;&#116;&#115;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#115;&#117;&#109;&#95;&#110;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#94;&#110; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>In fact, we could even get this by solving the equation and finding its generating function.</p>
<p class="ql-center-displayed-equation" style="line-height: 77px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a6e03167abf176b56c6d8df58b167bf5_l3.png" height="77" width="94" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#108;&#125;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#49;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#115;&#117;&#109;&#95;&#110;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#94;&#110; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Neat. However, this brings up a good question. Can all such equations be solved? Unfortunately, no.</p>
<h4 id="Unheaded_List_&#8211;_unsolvable">Unheaded List &#8211; unsolvable</h4>
<p>Let&#8217;s define a type</p>
<p class="ql-center-displayed-equation" style="line-height: 18px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e827ca780f6426ccd2a04215493e4065_l3.png" height="18" width="114" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#39;&#120;&#32;&#126;&#32;&#92;&#103;&#123;&#117;&#125;&#32;&#61;&#32;&#117;&#110;&#105;&#116;&#32;&#92;&#109;&#105;&#100;&#32;&#39;&#120;&#32;&#126;&#32;&#92;&#103;&#123;&#117;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>if we translate it, we get</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-38af15c6a21e29e07e33e9e212df86ae_l3.png" height="16" width="86" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#117;&#125;&#125;&#32;&#61;&#32;&#49;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#117;&#125;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>now, if our codomain of the translation is just <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4bfcc5863f49b8551410ac72eb53b044_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#78;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="11" style="vertical-align: 0px;"/>, then we would be forced to abandon hope. However, what we really did was we packed that codomain to include <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-efd6cdd671b24efd175d7f2e399038bd_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#111;&#112;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/> that you can think of as <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d284c7bef33a6edd6b39038b020c31d3_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#105;&#110;&#102;&#116;&#121;" title="Rendered by QuickLaTeX.com" height="7" width="14" style="vertical-align: 0px;"/>. What this can be interpreted as is that no matter what type variable <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-cccdb60bea3ccf67ac8b759c18c3d19e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#39;&#120;" title="Rendered by QuickLaTeX.com" height="13" width="13" style="vertical-align: 0px;"/> becomes, type <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-991e21a71e0019a05d87f1e19f2c6a4e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#117;&#125;" title="Rendered by QuickLaTeX.com" height="7" width="6" style="vertical-align: 0px;"/> is going to diverge.</p>
<p>However, using the above trick, we still get the expansion</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3c855e128f177a542ad9b158885b9a4b_l3.png" height="16" width="137" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#117;&#125;&#125;&#32;&#61;&#32;&#49;&#32;&#43;&#32;&#49;&#32;&#43;&#32;&#49;&#32;&#43;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>which says that all instances of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-991e21a71e0019a05d87f1e19f2c6a4e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#117;&#125;" title="Rendered by QuickLaTeX.com" height="7" width="6" style="vertical-align: 0px;"/> are translationally equivalent to <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d212f42c3e3ddaa97aa419833982876c_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="25" style="vertical-align: 0px;"/>.</p>
<h4 id="Binary_Trees">Binary Trees</h4>
<p>Let</p>
<p class="ql-center-displayed-equation" style="line-height: 18px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bbe240f94569e6d2134227ac3a5084cc_l3.png" height="18" width="192" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#39;&#120;&#32;&#126;&#32;&#92;&#103;&#123;&#116;&#125;&#32;&#61;&#32;&#92;&#103;&#123;&#117;&#110;&#105;&#116;&#125;&#32;&#92;&#109;&#105;&#100;&#32;&#40;&#39;&#120;&#32;&#126;&#32;&#92;&#103;&#123;&#116;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#39;&#120;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#39;&#120;&#32;&#126;&#32;&#92;&#103;&#123;&#116;&#125;&#41;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>which under translation gives</p>
<p class="ql-center-displayed-equation" style="line-height: 33px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9c1c83e5a9227433336211e23fa6d992_l3.png" height="33" width="212" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#116;&#125;&#125;&#32;&#61;&#32;&#49;&#32;&#43;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#92;&#103;&#123;&#116;&#125;&#125;&#94;&#50;&#32;&#61;&#32;&#92;&#115;&#117;&#109;&#95;&#110;&#32;&#67;&#95;&#110;&#32;&#92;&#116;&#114;&#97;&#110;&#115;&#123;&#125;&#123;&#39;&#120;&#125;&#94;&#110;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>where <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-915b40e78c9dfe908d8242972f5dcfe2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#67;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="13" width="18" style="vertical-align: -2px;"/> corresponds to the catalan numbers (i.e., we&#8217;re generating the sequence that count the number of binary trees translationally equivalent to the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ac360276039a23ef5aa6155959c5d4c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/>-tuple, which is the number of binary trees with <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ac360276039a23ef5aa6155959c5d4c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/> nodes).</p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/jB7DWsEkJx0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2013/03/neat-way-of-counting-ocaml-objects-satisfying-certain-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2013/03/neat-way-of-counting-ocaml-objects-satisfying-certain-types/</feedburner:origLink></item>
		<item>
		<title>Fixing floating point cancellation I</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/f7Ed_ey6bNA/</link>
		<comments>http://www.phailed.me/2013/01/fixing-floating-point-cancellation-i/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 06:42:10 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Numerical Analysis]]></category>
		<category><![CDATA[floating point]]></category>
		<category><![CDATA[numerical analysis]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1334</guid>
		<description><![CDATA[How can you compute [latex]\sqrt{x^2+1}-x[/latex] to 14 digits of accuracy within the domain [latex]&#124;x&#124; < 10^8[/latex]?]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.phailed.me/2013/01/fixing-floating-point-cancellation-i/nonsmooth1/" rel="attachment wp-att-1338"><img src="http://www.phailed.me/wp-content/uploads/2013/01/nonsmooth1.jpg" alt="The graph of f(x) is not smooth around 1e7" width="500" class="aligncenter size-full wp-image-1338" /></a><br />
This sounds like an easy problem, but it turns out that the solution isn&#8217;t so simple. If we plot <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bc56ae18f14e0e379f1798654e674922_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#102;&#40;&#120;&#41;&#32;&#61;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#45;&#120;" title="Rendered by QuickLaTeX.com" height="18" width="135" style="vertical-align: -4px;"/>, you&#8217;ll see that its graph is fairly smooth early on, but once <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb7bdfdfe13d8e437dfb90c6def55187_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/> approaches <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b8aa45f215cd25e9cf53410fd22eeaa2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#55;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="21" style="vertical-align: -1px;"/>, it is no longer smooth.</p>
<h3 id="Uh_Oh">1. Uh Oh</h3>
<p>This is puzzling, since it&#8217;s fairly obvious that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ba6b78f0dc5fa4214fd7d3ba4d53866a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#102;&#40;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="29" style="vertical-align: -4px;"/> is smooth everywhere; we can only conclude that floating point roundoff is to blame, and seeing the error manifest already on just an order of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f818bc5ea794bd950463a1cc69a19c9a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#56;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="30" style="vertical-align: -1px;"/> means that this equation itself isn&#8217;t enough to solve our problem. In fact, using arbitrary precision floating point arithmetic, we see that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ba6b78f0dc5fa4214fd7d3ba4d53866a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#102;&#40;&#120;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="29" style="vertical-align: -4px;"/> is indeed smooth within this region, so we know who the culprit is.</p>
<p><a href="http://www.phailed.me/2013/01/fixing-floating-point-cancellation-i/smooth1/" rel="attachment wp-att-1337"><img src="http://www.phailed.me/wp-content/uploads/2013/01/smooth1.jpg" alt="smooth1" width="500" class="alignright size-full wp-image-1337" /></a></p>
<p>We&#8217;re plagued by roundoff because <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-aee848d7564667d70e659150295d21ca_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="55" style="vertical-align: -2px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb7bdfdfe13d8e437dfb90c6def55187_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/> are extremely close together, so the IEEE standard guarantees that their subtraction will be flawless. Well, if this subtraction doesn&#8217;t incur any error whatsoever, why is there round-off? While the subtraction itself is error-free, the same cannot be said of the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-aee848d7564667d70e659150295d21ca_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="55" style="vertical-align: -2px;"/>. A crude bound analysis on the relative error of the form</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-224e7d6aa8ed9460257596a5d49b2caf_l3.png" height="16" width="370" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#92;&#116;&#101;&#120;&#116;&#115;&#102;&#123;&#101;&#120;&#112;&#114;&#125;&#95;&#49;&#32;&#92;&#99;&#105;&#114;&#99;&#32;&#92;&#116;&#101;&#120;&#116;&#115;&#102;&#123;&#101;&#120;&#112;&#114;&#125;&#95;&#50;&#41;&#32;&#61;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#92;&#116;&#101;&#120;&#116;&#115;&#102;&#123;&#101;&#120;&#112;&#114;&#125;&#95;&#49;&#41;&#32;&#92;&#99;&#105;&#114;&#99;&#32;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#92;&#116;&#101;&#120;&#116;&#115;&#102;&#123;&#101;&#120;&#112;&#114;&#125;&#95;&#50;&#41;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#40;&#49;&#32;&#43;&#32;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#99;&#105;&#114;&#99;&#125;&#41;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>and</p>
<p class="ql-center-displayed-equation" style="line-height: 16px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a71018caad5b0f6ce79ee4454acf94cc_l3.png" height="16" width="188" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#92;&#116;&#101;&#120;&#116;&#115;&#102;&#123;&#110;&#117;&#109;&#125;&#41;&#32;&#61;&#32;&#92;&#116;&#101;&#120;&#116;&#115;&#102;&#123;&#110;&#117;&#109;&#125;&#40;&#49;&#32;&#43;&#32;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#110;&#117;&#109;&#125;&#41;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>where the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-48aa0085da18ca93436be63ab75c6636_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="27" style="vertical-align: -1px;"/> function says whatever is in its argument will be evaluated under floating point arithmetic, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-aa45a2ed556266e63e085617d4dd3e4e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#99;&#105;&#114;&#99;" title="Rendered by QuickLaTeX.com" height="6" width="6" style="vertical-align: 1px;"/> represents one of the arithmetic operations or standard transcendental functions, and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-efbac5f9e3b961d61c92aac351bce6c3_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#99;&#100;&#111;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="12" width="10" style="vertical-align: -1px;"/> represents the relative error associated with an operation or with the representation of a number. Let&#8217;s look at the example in the problem. We&#8217;re going to assume that the subtraction gives no error, or that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-244b8179524965c2c655a2facd95c0a6_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#109;&#105;&#110;&#117;&#115;&#125;&#32;&#61;&#32;&#48;" title="Rendered by QuickLaTeX.com" height="13" width="71" style="vertical-align: -2px;"/>. Furthermore, let&#8217;s just for the sake of simplicity assume that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb7bdfdfe13d8e437dfb90c6def55187_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/> is perfectly represented (so that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-11f5788333e8fe96c4bdac3f12814d9d_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#120;&#32;&#61;&#32;&#48;" title="Rendered by QuickLaTeX.com" height="13" width="43" style="vertical-align: -2px;"/> as well, and since integers will never overflow, we have <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fc66ff16d2258624a058609afa930129_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#120;&#94;&#50;&#41;" title="Rendered by QuickLaTeX.com" height="18" width="54" style="vertical-align: -4px;"/> is perfectly computed as well)</p>
<p class="ql-center-displayed-equation" style="line-height: 334px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-35db2d47ed113100601783edf1bd604d_l3.png" height="334" width="494" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#45;&#120;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#38;&#61;&#32;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#45;&#32;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#120;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#120;&#94;&#50;&#43;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#125;&#40;&#49;&#43;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;&#41;&#32;&#45;&#32;&#120;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#120;&#94;&#50;&#41;&#43;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#49;&#41;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#40;&#49;&#43;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#43;&#41;&#125;&#40;&#49;&#43;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;&#41;&#32;&#45;&#32;&#120;&#32;&#92;&#92; &#38;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#120;&#94;&#50;&#41;&#43;&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#40;&#49;&#41;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#49;&#43;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#43;&#125;&#123;&#50;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#40;&#49;&#43;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;&#41;&#32;&#45;&#32;&#120;&#32;&#92;&#92; &#38;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#49;&#43;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#43;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#45;&#32;&#120;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#32;&#43;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#43;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#92;&#108;&#101;&#102;&#116;&#40;&#49;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#43;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#92;&#92; &#38;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#92;&#116;&#101;&#120;&#116;&#115;&#102;&#123;&#114;&#101;&#108;&#97;&#116;&#105;&#118;&#101;&#32;&#101;&#114;&#114;&#111;&#114;&#32;&#105;&#115;&#32;&#98;&#111;&#117;&#110;&#100;&#101;&#100;&#32;&#98;&#121;&#32;&#125;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#43;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>This analysis is intriguing: it tells us that at the very worst, we can expect our relative error of the entire computation to be bounded by <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-98f2aa79eb6e847a8a60508a994689f2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#43;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#125;" title="Rendered by QuickLaTeX.com" height="35" width="94" style="vertical-align: -9px;"/> where each of the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-efbac5f9e3b961d61c92aac351bce6c3_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#99;&#100;&#111;&#116;&#125;" title="Rendered by QuickLaTeX.com" height="12" width="10" style="vertical-align: -1px;"/> term is bounded above by <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-64d55d93c2b27fcf9129f4237c603482_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;&#95;&#123;&#109;&#97;&#99;&#104;&#125;" title="Rendered by QuickLaTeX.com" height="10" width="35" style="vertical-align: -3px;"/>, so the entire <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3343ee702682018cfbb4e4d4d97c65f1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#43;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#100;&#101;&#108;&#116;&#97;&#95;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#125;&#125;" title="Rendered by QuickLaTeX.com" height="24" width="53" style="vertical-align: -8px;"/> is bounded to an order of magnitude of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c6cc415204f48b0599c3432c82f19f0a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#49;&#54;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="36" style="vertical-align: -1px;"/>. This spells out why the error gets blown up at around <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-13ab90534ed1ab9d7b87a334bc4f8d85_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#61;&#49;&#48;&#94;&#55;" title="Rendered by QuickLaTeX.com" height="15" width="52" style="vertical-align: -1px;"/>. Our relative error is basically <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-dc4e94655bd5276abe7008e85b6a6d22_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#125;" title="Rendered by QuickLaTeX.com" height="26" width="63" style="vertical-align: -9px;"/>, and the absolute error is then just <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e21d29b547214ebae2231133b5a87f59_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#61;&#32;&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#120;" title="Rendered by QuickLaTeX.com" height="29" width="307" style="vertical-align: -11px;"/>, where when <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3f3a34e9197a20767e462d68197a7415_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#32;&#92;&#116;&#111;&#32;&#49;&#48;&#94;&#55;" title="Rendered by QuickLaTeX.com" height="15" width="55" style="vertical-align: -1px;"/>, the absolute error is around <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8539e8fd18fc0f20c8b41bd56cafc9fb_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#49;&#54;&#125;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#49;&#48;&#94;&#55;&#32;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#49;&#48;&#94;&#123;&#45;&#57;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="130" style="vertical-align: -1px;"/>, which is definitely not good enough.</p>
<p>Hold on, the original relative error of the computation <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a59b74fe4dd90f05dac0d67aa0becd23_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="55" style="vertical-align: -2px;"/> only incurred a relative error of just <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c6cc415204f48b0599c3432c82f19f0a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#49;&#54;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="36" style="vertical-align: -1px;"/>, why did the final error get blown up by that many orders of magnitude? (if you do the calculation, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8b523135ea484084ef4074ea225b42da_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;&#32;&#45;&#32;&#120;&#32;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#120;&#125;" title="Rendered by QuickLaTeX.com" height="19" width="118" style="vertical-align: -5px;"/>)? Here&#8217;s a more intuitive way of seeing this: when we computed <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a59b74fe4dd90f05dac0d67aa0becd23_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="55" style="vertical-align: -2px;"/>, we got a small <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b1311022503eb03844f42b9953d6a6d0_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;" title="Rendered by QuickLaTeX.com" height="7" width="6" style="vertical-align: 0px;"/> amount of relative error on a large number. However, this amounts to <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c3cd20bbbf159c3119f1c9dd77e65a83_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;&#32;&#120;" title="Rendered by QuickLaTeX.com" height="7" width="15" style="vertical-align: 0px;"/> amount of absolute error. When we subtracted off the rest of the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb7bdfdfe13d8e437dfb90c6def55187_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/>, we&#8217;re still left with an absolute error of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c3cd20bbbf159c3119f1c9dd77e65a83_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;&#32;&#120;" title="Rendered by QuickLaTeX.com" height="7" width="15" style="vertical-align: 0px;"/>, but this is the error on a much smaller number (<img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-18b3d0d4d6cf28eaef7a3194630f05af_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#120;&#125;" title="Rendered by QuickLaTeX.com" height="19" width="7" style="vertical-align: -5px;"/>), so the original absolute error now becomes a rather large amount of relative error.</p>
<h3 id="The_Fix?">2. The Fix?</h3>
<p>Intuition plays a large role here since finding workarounds to floating point issues is pretty much a dark art. Here, the subtraction is actively amplifying our error, so what if we find some equivalent form of this expression that doesn&#8217;t subtract two large but close numbers? Through simple algebra, we see that by multiplying the conjugate we get</p>
<p class="ql-center-displayed-equation" style="line-height: 124px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7bd2d6d953f8b5117653c2d1d2c6cba5_l3.png" height="124" width="299" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#45;&#120;&#32;&#38;&#61;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#45;&#120;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#43;&#120;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#43;&#120;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#49;&#32;&#45;&#32;&#120;&#94;&#50;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#43;&#120;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#120;&#94;&#50;&#43;&#49;&#125;&#43;&#120;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Is this form better? Let&#8217;s try it out.</p>
<p><a href="http://www.phailed.me/2013/01/fixing-floating-point-cancellation-i/corrected1/" rel="attachment wp-att-1368"><img src="http://www.phailed.me/wp-content/uploads/2013/01/corrected1.jpg" alt="corrected1" width="460" class="aligncenter size-full wp-image-1368" /></a></p>
<p><a href="http://www.phailed.me/2013/01/fixing-floating-point-cancellation-i/errorcorrected1/" rel="attachment wp-att-1336"><img src="http://www.phailed.me/wp-content/uploads/2013/01/errorcorrected1.jpg" alt="errorcorrected1" width="460" class="aligncenter size-full wp-image-1336" /></a></p>
<p>In this case, getting rid of the subtraction got our method&#8217;s error down to just <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9387cf0ba8a2c674fb718f477e9070b8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#50;&#48;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="36" style="vertical-align: -1px;"/>, which is much better than what we&#8217;re looking for.</p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/f7Ed_ey6bNA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2013/01/fixing-floating-point-cancellation-i/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2013/01/fixing-floating-point-cancellation-i/</feedburner:origLink></item>
		<item>
		<title>Floating point quirks</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/OLp8l6D1xs8/</link>
		<comments>http://www.phailed.me/2013/01/floating-point-quirks/#comments</comments>
		<pubDate>Thu, 17 Jan 2013 08:51:49 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Numerical Analysis]]></category>
		<category><![CDATA[floating point]]></category>
		<category><![CDATA[numerical analysis]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1265</guid>
		<description><![CDATA[In this post, we'll explore a scenario where the non-<del>commutativity</del>associativity of floating point arithmetic can lead us into trouble.

Let [latex]a_k = \frac{1}{k(k+1)}[/latex] and [latex]S_n = \sum_{k=1}^n a_k[/latex]. Write a computer program to compute this sum.]]></description>
				<content:encoded><![CDATA[<p></p><div class='toc tableofcontent'>
   <h2>Table Of Content</h2>
   <p class='contentTable_h3'><a href="#A_closed_form_equation_for_">1. A closed form equation for <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bae94ce2be824421a49548bd6dd94814_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="13" width="17" style="vertical-align: -2px;"/></a></p>
<p class='contentTable_h3'><a href="#Uh_oh">2. Uh oh</a></p>
<p class='contentTable_h3'><a href="#An_explanation">3. An explanation</a></p>

</div><div class='tableofcontent-end'> </div><p></p>
<h3 id="A_closed_form_equation_for_">1. A closed form equation for <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bae94ce2be824421a49548bd6dd94814_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="13" width="17" style="vertical-align: -2px;"/></h3>
<pre class="alignleft">
function S = S(n)
    S = 1 - 1/(1+n);
end
</pre>
<p>It&#8217;s a really simple problem, and if you do a little bit of algebra, you can make the following simplification </p>
<p class="ql-center-displayed-equation" style="line-height: 44px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4f2b09d2a9f0d7791a78200f1c48a3f1_l3.png" height="44" width="350" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#83;&#95;&#110;&#32;&#61;&#32;&#92;&#115;&#117;&#109;&#95;&#107;&#94;&#110;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#107;&#40;&#107;&#43;&#49;&#41;&#125;&#32;&#61;&#32;&#92;&#115;&#117;&#109;&#95;&#107;&#94;&#110;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#107;&#43;&#49;&#32;&#45;&#32;&#107;&#125;&#123;&#107;&#40;&#107;&#43;&#49;&#41;&#125;&#32;&#61;&#32;&#92;&#115;&#117;&#109;&#95;&#107;&#94;&#110;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#107;&#125;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#107;&#43;&#49;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>From this, it follows immediately that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7675484fb1a47767508d9341ab1bf267_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#95;&#110;&#32;&#61;&#32;&#49;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#51;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#51;&#125;&#32;&#45;&#32;&#92;&#100;&#111;&#116;&#115;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#110;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#110;&#125;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#110;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="20" width="301" style="vertical-align: -6px;"/>, or <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-86157da811c69aed21c1d1a34b9c076b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#95;&#110;&#32;&#61;&#32;&#49;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#110;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="20" width="90" style="vertical-align: -6px;"/>. Great, now that we have a closed form expression for <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bae94ce2be824421a49548bd6dd94814_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="13" width="17" style="vertical-align: -2px;"/>, what else do we need to do? Of course, just to make sure that my derivation is sound, I wrote out the full sum program anyways. (Note: this behavior will only happen when you use single precision floating point storage)</p>
<pre class="alignright">
n = 1e6;
S = 0;
for k=1:n
    S = single(double(S) + 1/(k*(k+1)));
end
(1 - 1/(n+1)) - S
</pre>
<p>After computing <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bae94ce2be824421a49548bd6dd94814_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="13" width="17" style="vertical-align: -2px;"/> for a few small values and comparing them to the value of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f4868ea399a278e11667a58a4a468992_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#110;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="20" width="51" style="vertical-align: -6px;"/>, I found that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-91c93c969afee400cfda4cf08f3719eb_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#39;" title="Rendered by QuickLaTeX.com" height="13" width="14" style="vertical-align: 0px;"/> seems to compute the same value as my expression; but for large values of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ac360276039a23ef5aa6155959c5d4c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/>, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a22fda801bfa3ad998dd44b03fa7d8dc_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#39;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="17" width="17" style="vertical-align: -4px;"/> rapidly gets farther and farther away from the value computed by <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bae94ce2be824421a49548bd6dd94814_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="13" width="17" style="vertical-align: -2px;"/>. I just attributed this to roundoff error, afterall, this is roundoff. I concluded that the more expensive summation isn&#8217;t a good solution at all and thought that was the end of it.</p>
<h3 id="Uh_oh">2. Uh oh</h3>
<p>Later that day, I showed my friend this question and he told me that while he agrees that the closed form formula is indeed better, he sees no significant loss of accuracy in his implementation. For <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ac360276039a23ef5aa6155959c5d4c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/> equals to a million, his solution only has <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f818bc5ea794bd950463a1cc69a19c9a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#56;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="30" style="vertical-align: -1px;"/> amount of error (on par with <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-64d55d93c2b27fcf9129f4237c603482_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#101;&#112;&#115;&#105;&#108;&#111;&#110;&#95;&#123;&#109;&#97;&#99;&#104;&#125;" title="Rendered by QuickLaTeX.com" height="10" width="35" style="vertical-align: -3px;"/> for single precision) using only single precision storage types.</p>
<p>&#8220;What? No, that&#8217;s not possible, I already tried it on mine and I got an error of around <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ecc85ab6c2ccf7aade771366c6d22594_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#52;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="30" style="vertical-align: -1px;"/>&#8221;<br />
&#8220;Well, try it yourself&#8221;</p>
<p>So I ran his code in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a70e46432159482e10848bc4dd9294fc_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#77;&#97;&#116;&#108;&#97;&#98;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="60" style="vertical-align: -1px;"/>. At first I saw no difference in our two implementations, but then it hit me; &#8220;he&#8217;s computing the series backwards&#8221;</p>
<pre class="aligncenter">
n = 1e6;
S = 0;
for k=n:-1:1
    S = single(double(S) + 1/(k*(k+1)));
end
(1 - 1/(n+1)) - S
</pre>
<p>and sure enough, I get the same error he does. What the hell is going on?</p>
<h3 id="An_explanation">3. An explanation</h3>
<p>It turns out that the problem stems from how roundoff works under certain rounding mode for addition. First, the IEEE guarantees that addition for floating point numbers that are within <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7afb920b7c0a03eb65c2ff021a32b2d5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="19" width="7" style="vertical-align: -5px;"/> of each other will be <em>perfectly</em> computed. </p>
<p>Now, a single precision floating point number can store about 8 digits accurately, therefore, adding 1 to <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a88e39327538064193944e74e9488584_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#49;&#48;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="36" style="vertical-align: -1px;"/> will only return 1 since the number <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b1f8cc0e608bf09f4d7f633901941309_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#43;&#49;&#48;&#94;&#123;&#45;&#49;&#48;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="63" style="vertical-align: -1px;"/> will take more than 8 digits to store and hence will truncate the lower few digits. In general, you can assume that if two numbers differ by 8 orders of magnitude, then adding them will have no effect.</p>
<p>Now, when we compute the series in the forward direction, what we&#8217;re really doing is computing an approximation <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5818fcb3b99ecaf5b79b21cd2aa3db7a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#104;&#97;&#116;&#32;&#83;&#95;&#110;&#32;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#83;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="17" width="55" style="vertical-align: -2px;"/> such that.</p>
<p class="ql-center-displayed-equation" style="line-height: 243px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5c2d3c0de1d74cfc9c7ecd5b92f4590f_l3.png" height="243" width="150" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#104;&#97;&#116;&#32;&#83;&#95;&#48;&#32;&#38;&#61;&#32;&#48;&#32;&#92;&#92; &#92;&#104;&#97;&#116;&#32;&#83;&#95;&#49;&#32;&#38;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#104;&#97;&#116;&#32;&#83;&#95;&#48;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#92;&#92; &#92;&#104;&#97;&#116;&#32;&#83;&#95;&#50;&#32;&#38;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#104;&#97;&#116;&#32;&#83;&#95;&#49;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#54;&#125;&#32;&#92;&#92; &#92;&#104;&#97;&#116;&#32;&#83;&#95;&#51;&#32;&#38;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#104;&#97;&#116;&#32;&#83;&#95;&#50;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#49;&#50;&#125;&#32;&#92;&#92; &#92;&#104;&#97;&#116;&#32;&#83;&#95;&#52;&#32;&#38;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#104;&#97;&#116;&#32;&#83;&#95;&#51;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#48;&#125;&#32;&#92;&#92; &#38;&#92;&#118;&#100;&#111;&#116;&#115;&#32;&#92;&#92; &#92;&#104;&#97;&#116;&#32;&#83;&#95;&#110;&#32;&#38;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#92;&#104;&#97;&#116;&#32;&#83;&#95;&#123;&#110;&#45;&#49;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#110;&#40;&#110;&#43;&#49;&#41;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>As we&#8217;ve already shown, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9bca6ddc1aa20a044a998c105f76218b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#104;&#97;&#116;&#32;&#83;&#95;&#107;&#32;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#83;&#95;&#107;&#32;&#61;&#32;&#49;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#107;&#43;&#49;&#125;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#40;&#107;&#45;&#49;&#41;&#40;&#107;&#43;&#49;&#41;&#125;&#123;&#107;&#40;&#107;&#43;&#49;&#41;&#125;" title="Rendered by QuickLaTeX.com" height="26" width="214" style="vertical-align: -9px;"/>, so at each iteration, we&#8217;re making the floating point computation <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-cc060ec6a9067c003db2a7b5e9a1d527_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#70;&#108;&#116;&#125;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#107;&#94;&#50;&#32;&#45;&#32;&#49;&#125;&#123;&#107;&#40;&#107;&#43;&#49;&#41;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#107;&#40;&#107;&#43;&#49;&#41;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;" title="Rendered by QuickLaTeX.com" height="29" width="148" style="vertical-align: -11px;"/>. Relatively speaking, for large values of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e25a983cd96d14229395e4640986596f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;" title="Rendered by QuickLaTeX.com" height="11" width="8" style="vertical-align: 0px;"/> the expression <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b89f988193f62e7c54115bd994cd2401_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;&#94;&#50;&#32;&#45;&#32;&#49;" title="Rendered by QuickLaTeX.com" height="15" width="41" style="vertical-align: -1px;"/> tends towards just <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-39ea1ce49c9feebeab19114d073fa3b9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;&#94;&#50;" title="Rendered by QuickLaTeX.com" height="14" width="15" style="vertical-align: 0px;"/>; futhermore, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-39ea1ce49c9feebeab19114d073fa3b9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;&#94;&#50;" title="Rendered by QuickLaTeX.com" height="14" width="15" style="vertical-align: 0px;"/> will become more than 8 orders of magnitude away from 1 when <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e25a983cd96d14229395e4640986596f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;" title="Rendered by QuickLaTeX.com" height="11" width="8" style="vertical-align: 0px;"/> is merely 10-thousand (however round off will be noticeable much earlier) therefore, for the last 999000 operations, our method is effectively doing nothing. You can actually verify this in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a70e46432159482e10848bc4dd9294fc_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#116;&#101;&#120;&#116;&#115;&#99;&#123;&#77;&#97;&#116;&#108;&#97;&#98;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="60" style="vertical-align: -1px;"/> by seeing that both <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3c763b9be4c66f5f2740aae7936c7d56_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#40;&#49;&#101;&#52;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="44" style="vertical-align: -4px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-eb4d7f9630718f067dec3f1b0c726ddc_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#40;&#49;&#101;&#54;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="44" style="vertical-align: -4px;"/> output the same long-formatted float when the true answer is about <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ecc85ab6c2ccf7aade771366c6d22594_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#45;&#52;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="30" style="vertical-align: -1px;"/> away.</p>
<p>Okay, so how does doing this summation in reverse help in any way or form? Well, suppose that each iteration of the reverse method produces a number <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a32fa3a7e7f0ba6687cc4414fe3574bb_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;&#95;&#107;" title="Rendered by QuickLaTeX.com" height="14" width="19" style="vertical-align: -3px;"/> at step <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e25a983cd96d14229395e4640986596f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;" title="Rendered by QuickLaTeX.com" height="11" width="8" style="vertical-align: 0px;"/>, then it&#8217;s obvious that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f6ecf25854b00b4745b345c7d049e872_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;&#95;&#107;&#32;&#61;&#32;&#83;&#95;&#110;&#32;&#45;&#32;&#83;&#95;&#123;&#110;&#45;&#107;&#45;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="125" style="vertical-align: -4px;"/>; furthermore, for large enough value of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ac360276039a23ef5aa6155959c5d4c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/>, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c48ec6daad5b51ecf639adf9aa714cb5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#83;&#95;&#110;&#32;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#49;" title="Rendered by QuickLaTeX.com" height="13" width="45" style="vertical-align: -2px;"/>, so we can just have <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-6f919bd84f10cefaf483e3a6ee33008a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;&#95;&#107;&#32;&#61;&#32;&#49;&#32;&#45;&#32;&#83;&#95;&#123;&#110;&#45;&#107;&#45;&#49;&#125;&#32;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#49;&#32;&#45;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#49;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#110;&#45;&#107;&#45;&#49;&#43;&#49;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#110;&#45;&#107;&#125;" title="Rendered by QuickLaTeX.com" height="29" width="313" style="vertical-align: -11px;"/>. The inductive definition also states that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4f984c26aac47b4c8030cb66227de8f1_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;&#95;&#107;&#32;&#61;&#32;&#82;&#95;&#123;&#107;&#45;&#49;&#125;&#32;&#43;&#32;&#97;&#95;&#123;&#110;&#45;&#107;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="140" style="vertical-align: -4px;"/> <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-20009c8393fcb1fa236b3e298b35e329_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#61;&#32;&#82;&#95;&#123;&#107;&#45;&#49;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#40;&#110;&#45;&#107;&#43;&#49;&#41;&#94;&#50;&#32;&#43;&#32;&#40;&#110;&#45;&#107;&#43;&#49;&#41;&#125;" title="Rendered by QuickLaTeX.com" height="23" width="184" style="vertical-align: -9px;"/>. Now, there&#8217;s something intriguing about this expression: <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d9c7fa41c7ba3565bcb8bee408b1cb76_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#110;&#45;&#107;&#43;&#49;&#41;&#94;&#50;&#32;&#43;&#32;&#40;&#110;&#45;&#107;&#43;&#49;&#41;&#32;&#92;&#97;&#112;&#112;&#114;&#111;&#120;&#32;&#40;&#110;&#45;&#107;&#43;&#49;&#41;&#94;&#50;" title="Rendered by QuickLaTeX.com" height="18" width="280" style="vertical-align: -4px;"/> so that the relative difference between <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0c5c165782bb54945bd94f7aa2d2e67b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#82;&#95;&#123;&#107;&#45;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="33" style="vertical-align: -4px;"/> and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-6690387a36d7cb82d96846ef9f7019ae_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#95;&#123;&#110;&#45;&#107;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="47" style="vertical-align: -4px;"/> is around <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-14928c6500fee03a7d66157dc717d417_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#110;&#45;&#107;&#43;&#49;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="74" style="vertical-align: -4px;"/> which is <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-089ead0630d222e317ee0771c6c69a7c_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#79;&#40;&#110;&#45;&#107;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="60" style="vertical-align: -4px;"/> and can never exceed <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-cbf9604dc19648b43da2778ceada8f3c_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#48;&#94;&#123;&#56;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="21" style="vertical-align: -1px;"/> for <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-951f3029f495f484bcbc5e2fa2d5a0d3_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;&#32;&#60;&#32;&#110;&#32;&#60;&#32;&#49;&#48;&#94;&#123;&#54;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="82" style="vertical-align: -1px;"/> (so the roundoff is at the worst in the beginning, but that&#8217;s also where this difference formula make assumptions that no longer hold, namely that the linear factor dominates the quadratic factor in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9fafaee858166e4ea6fefa20b8238578_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#110;&#45;&#107;&#43;&#49;&#41;&#94;&#50;&#32;&#43;&#32;&#40;&#110;&#45;&#107;&#43;&#49;&#41;" title="Rendered by QuickLaTeX.com" height="18" width="176" style="vertical-align: -4px;"/>, so the relative magnitude between the two terms isn&#8217;t really that big of a deal. Anyways, the roundoff will progressively become better and better as <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e25a983cd96d14229395e4640986596f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#107;" title="Rendered by QuickLaTeX.com" height="11" width="8" style="vertical-align: 0px;"/> grows). Therefore, rather than having a significant vast majority of the computations do nothing, every step now counts. This is largely the reason why summing the series backwards gives less roundoff overall than doing the &#8220;same&#8221; set of operations in the other direction. This is one case where the &#8220;non-associativity&#8221; of arithmetic in floating point will give you trouble.</p>
<p><center><br />
neat &nbsp; : )<br />
</center></p>
<p>Next: <a href="http://www.phailed.me/2013/01/fixing-floating-point-cancellation-i/" title="Fixing floating point cancellation I" target="_blank">How to fix floating point error</a></p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/OLp8l6D1xs8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2013/01/floating-point-quirks/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2013/01/floating-point-quirks/</feedburner:origLink></item>
		<item>
		<title>Solving first order PDEs with Characteristics</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/u69au60WJAw/</link>
		<comments>http://www.phailed.me/2012/11/solving-first-order-pdes-with-characteristics/#comments</comments>
		<pubDate>Mon, 26 Nov 2012 02:48:13 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Reading Diary]]></category>
		<category><![CDATA[numerical analysis]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1253</guid>
		<description><![CDATA[Use the method of characteristics to solve the PDE system
[latex]
$$\begin{cases}
u_x + xu_y = 0 \\
u(0,y) = f(y)
\end{cases}$$
[/latex]]]></description>
				<content:encoded><![CDATA[<p>We begin by parameterizing <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5ad014483a42e012b68453a4fbd539ea_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#117;&#44;&#120;&#44;&#121;" title="Rendered by QuickLaTeX.com" height="10" width="40" style="vertical-align: -3px;"/> as functions of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c2c2a035ee5da9fd86f4970918fbf3c2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#116;" title="Rendered by QuickLaTeX.com" height="10" width="6" style="vertical-align: 0px;"/> such that</p>
<p class="ql-center-displayed-equation" style="line-height: 101px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-14f6c57667fdd510df8a73aa60131587_l3.png" height="101" width="370" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#100;&#102;&#114;&#97;&#99;&#123;&#100;&#125;&#123;&#100;&#116;&#125;&#32;&#117;&#40;&#120;&#44;&#121;&#41;&#32;&#38;&#61;&#32;&#117;&#95;&#120;&#32;&#120;&#39;&#32;&#43;&#32;&#117;&#95;&#121;&#32;&#121;&#39;&#32;&#92;&#92; &#92;&#105;&#110;&#116;&#101;&#114;&#116;&#101;&#120;&#116;&#123;&#111;&#98;&#115;&#101;&#114;&#118;&#101;&#32;&#116;&#104;&#97;&#116;&#32;&#105;&#102;&#32;&#119;&#101;&#32;&#36;&#120;&#39;&#32;&#61;&#32;&#49;&#36;&#32;&#97;&#110;&#100;&#32;&#36;&#121;&#39;&#32;&#61;&#32;&#120;&#36;&#32;&#103;&#105;&#118;&#101;&#115;&#32;&#117;&#115;&#32;&#116;&#104;&#101;&#32;&#80;&#68;&#69;&#125; &#38;&#61;&#32;&#117;&#95;&#120;&#32;&#43;&#32;&#120;&#32;&#117;&#95;&#121;&#32;&#61;&#32;&#48; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>This gives the system of ODE </p>
<p class="ql-center-displayed-equation" style="line-height: 112px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-01f5e003f6de08de6648b8320a270b6a_l3.png" height="112" width="127" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#99;&#97;&#115;&#101;&#115;&#125; &#120;&#39;&#32;&#61;&#32;&#49;&#32;&#92;&#92; &#121;&#39;&#32;&#61;&#32;&#120;&#32;&#92;&#92; &#120;&#40;&#48;&#41;&#32;&#61;&#32;&#48;&#32;&#92;&#92; &#121;&#40;&#48;&#41;&#32;&#61;&#32;&#121;&#95;&#48;&#32;&#92;&#92; &#117;&#40;&#120;&#44;&#121;&#41;&#32;&#61;&#32;&#102;&#40;&#121;&#40;&#48;&#41;&#41;&#32;&#92;&#92; &#92;&#101;&#110;&#100;&#123;&#99;&#97;&#115;&#101;&#115;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>Unfortunately, we don&#8217;t know what <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3f46841eafff5b29ab23e7856c24702e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#121;&#95;&#48;" title="Rendered by QuickLaTeX.com" height="10" width="14" style="vertical-align: -3px;"/> is; but we do have the parameterization parameter <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c2c2a035ee5da9fd86f4970918fbf3c2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#116;" title="Rendered by QuickLaTeX.com" height="10" width="6" style="vertical-align: 0px;"/>, so we can solve the system backwards in time. </p>
<p class="ql-center-displayed-equation" style="line-height: 88px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-44754a509eee7a8565ea50ebf5948ee9_l3.png" height="88" width="73" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#118;&#39;&#32;&#38;&#61;&#32;&#45;&#49;&#32;&#92;&#92; &#119;&#39;&#32;&#38;&#61;&#32;&#45;&#118;&#32;&#92;&#92; &#118;&#40;&#48;&#41;&#32;&#38;&#61;&#32;&#120;&#32;&#92;&#92; &#119;&#40;&#48;&#41;&#32;&#38;&#61;&#32;&#121; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>which is equivalent to the second order ODE</p>
<p class="ql-center-displayed-equation" style="line-height: 15px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a9547f6d9b978d19101acb761b762293_l3.png" height="15" width="75" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#119;&#39;&#39;&#32;&#45;&#32;&#49;&#32;&#61;&#32;&#48;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>which has the solution</p>
<p class="ql-center-displayed-equation" style="line-height: 105px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-11567ae9f4a745c89b95d79842f0bafe_l3.png" height="105" width="138" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#119;&#40;&#116;&#41;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#116;&#94;&#50;&#125;&#123;&#50;&#125;&#32;&#45;&#32;&#99;&#95;&#49;&#32;&#116;&#32;&#43;&#32;&#99;&#95;&#48;&#32;&#92;&#92; &#118;&#40;&#116;&#41;&#32;&#38;&#61;&#32;&#45;&#116;&#32;&#43;&#32;&#99;&#95;&#49;&#32;&#92;&#92; &#118;&#40;&#48;&#41;&#32;&#38;&#61;&#32;&#99;&#95;&#49;&#32;&#61;&#32;&#120;&#32;&#92;&#92; &#119;&#40;&#48;&#41;&#32;&#38;&#61;&#32;&#99;&#95;&#48;&#32;&#61;&#32;&#121; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Now, we know that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-638dc45fdf18009992919454c8d3d60b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#48;&#32;&#61;&#32;&#48;" title="Rendered by QuickLaTeX.com" height="13" width="44" style="vertical-align: -2px;"/>, so we want to find the time <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c2c2a035ee5da9fd86f4970918fbf3c2_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#116;" title="Rendered by QuickLaTeX.com" height="10" width="6" style="vertical-align: 0px;"/> such that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d302d1cb97357754b6e11fbb4e6d15a8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#118;&#40;&#116;&#41;&#32;&#61;&#32;&#48;" title="Rendered by QuickLaTeX.com" height="16" width="55" style="vertical-align: -4px;"/>, or <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c298bc9bd52ddf47e14b7c1c696bdc0d_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#32;&#45;&#32;&#116;&#32;&#61;&#32;&#48;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#116;&#32;&#61;&#32;&#120;" title="Rendered by QuickLaTeX.com" height="12" width="140" style="vertical-align: -1px;"/>, then </p>
<p class="ql-center-displayed-equation" style="line-height: 35px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e8f4e28a8b2fe43f6098b943ba013bcb_l3.png" height="35" width="169" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#121;&#95;&#48;&#32;&#61;&#32;&#119;&#40;&#120;&#41;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#94;&#50;&#125;&#123;&#50;&#125;&#32;&#45;&#32;&#120;&#94;&#50;&#32;&#43;&#32;&#121;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>and <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-61d48f88f7f8a185c619413a2bef4362_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#117;&#40;&#120;&#44;&#121;&#41;&#32;&#61;&#32;&#102;&#92;&#112;&#97;&#123;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#94;&#50;&#125;&#123;&#50;&#125;&#32;&#45;&#32;&#120;&#94;&#50;&#32;&#43;&#32;&#121;&#125;&#32;&#61;&#32;&#102;&#92;&#112;&#97;&#123;&#121;&#45;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#94;&#50;&#125;&#123;&#50;&#125;&#125;" title="Rendered by QuickLaTeX.com" height="29" width="267" style="vertical-align: -11px;"/></p>
<p>Let&#8217;s quickly verify that this is indeed the solution</p>
<p class="ql-center-displayed-equation" style="line-height: 157px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e207c7fe6deb7b5a64478a1dc925750b_l3.png" height="157" width="263" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#117;&#95;&#120;&#32;&#43;&#32;&#120;&#117;&#95;&#121;&#32;&#38;&#61;&#32;&#92;&#100;&#102;&#114;&#97;&#99;&#123;&#100;&#91;&#121;&#45;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#94;&#50;&#125;&#123;&#50;&#125;&#93;&#125;&#123;&#100;&#120;&#125;&#102;&#39;&#32;&#43;&#32;&#120;&#92;&#100;&#102;&#114;&#97;&#99;&#123;&#100;&#91;&#121;&#45;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#94;&#50;&#125;&#123;&#50;&#125;&#93;&#125;&#123;&#100;&#121;&#125;&#102;&#39;&#32;&#92;&#92; &#38;&#61;&#32;&#45;&#120;&#102;&#39;&#32;&#43;&#32;&#120;&#102;&#39;&#32;&#92;&#92; &#38;&#61;&#32;&#48;&#32;&#92;&#92; &#117;&#40;&#48;&#44;&#121;&#41;&#32;&#38;&#61;&#32;&#102;&#92;&#112;&#97;&#123;&#121;&#45;&#92;&#102;&#114;&#97;&#99;&#123;&#48;&#94;&#50;&#125;&#123;&#50;&#125;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#102;&#40;&#121;&#41; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Since this is fully linear, the solution is unique and the characteristics intersect.</p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/u69au60WJAw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2012/11/solving-first-order-pdes-with-characteristics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2012/11/solving-first-order-pdes-with-characteristics/</feedburner:origLink></item>
		<item>
		<title>Power Reduction in Congruences</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/hsqdlHila-c/</link>
		<comments>http://www.phailed.me/2012/08/power-reduction-in-congruences/#comments</comments>
		<pubDate>Wed, 15 Aug 2012 16:42:04 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Math Problems]]></category>
		<category><![CDATA[104 problems]]></category>
		<category><![CDATA[number theory]]></category>
		<category><![CDATA[titu]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1144</guid>
		<description><![CDATA[Suppose you have integers a,b that are relatively prime to m such that

[latex]$$
a^x \equiv b^x \mod m \hspace{4mm}\mbox{ and }\hspace{4mm} a^y \equiv b^y \mod m
$$[/latex]

then

[latex]$$
a^{\gcd(x,y)} \equiv b^{\gcd(x,y)} \mod m
$$[/latex]]]></description>
				<content:encoded><![CDATA[<p></p><div class='toc tableofcontent'>
   <h2>Table Of Content</h2>
   <p class='contentTable_h3'><a href="#Lemma:_">1. Lemma: <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fcdd8519fd59c5830ec8598f6356d1d5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#99;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#99;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#97;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#32;&#92;&#109;&#111;&#100;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#109;&#125;&#123;&#92;&#103;&#99;&#100;&#40;&#99;&#44;&#109;&#41;&#125;" title="Rendered by QuickLaTeX.com" height="21" width="281" style="vertical-align: -9px;"/></a></p>
<p class='contentTable_h3'><a href="#Show_that_">2. Show that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7771e4065a236dedd5ac44860b71d138_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#94;&#123;&#40;&#120;&#44;&#121;&#41;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#94;&#123;&#40;&#120;&#44;&#121;&#41;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;" title="Rendered by QuickLaTeX.com" height="15" width="149" style="vertical-align: 0px;"/></a></p>
<p class='contentTable_h4'><a href="#Alternatively">Alternatively</a></p>

</div><div class='tableofcontent-end'> </div><p></p>
<p>We first prove a useful lemma in working with algebraic manipulations in modular arithmetic.</p>
<h3 id="Lemma:_">1. Lemma: <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fcdd8519fd59c5830ec8598f6356d1d5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#99;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#99;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#97;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#32;&#92;&#109;&#111;&#100;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#109;&#125;&#123;&#92;&#103;&#99;&#100;&#40;&#99;&#44;&#109;&#41;&#125;" title="Rendered by QuickLaTeX.com" height="21" width="281" style="vertical-align: -9px;"/></h3>
<p>Here, we take the traditional definition that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8ad4763cdf035f8448cbd6cce634e0ea_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#99;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#99;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#92;&#105;&#102;&#102;&#32;&#109;&#124;&#40;&#97;&#99;&#45;&#98;&#99;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="232" style="vertical-align: -4px;"/>.</p>
<p class="ql-center-displayed-equation" style="line-height: 76px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-dbc11ca4aab7d3c1418bfcc3b0ff3a31_l3.png" height="76" width="474" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#97;&#99;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#99;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#38;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#109;&#124;&#40;&#97;&#99;&#45;&#98;&#99;&#41;&#32;&#92;&#92; &#38;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#109;&#124;&#99;&#40;&#97;&#45;&#98;&#41;&#32;&#92;&#92; &#92;&#105;&#110;&#116;&#101;&#114;&#116;&#101;&#120;&#116;&#123;&#105;&#102;&#32;&#36;&#40;&#109;&#44;&#99;&#41;&#61;&#49;&#36;&#44;&#32;&#116;&#104;&#101;&#110;&#32;&#36;&#109;&#124;&#40;&#97;&#45;&#98;&#41;&#36;&#44;&#32;&#98;&#117;&#116;&#32;&#105;&#102;&#32;&#36;&#40;&#109;&#44;&#99;&#41;&#61;&#100;&#32;&#92;&#110;&#101;&#32;&#49;&#36;&#44;&#32;&#116;&#104;&#101;&#110;&#32;&#36;&#92;&#102;&#114;&#97;&#99;&#123;&#109;&#125;&#123;&#100;&#125;&#124;&#40;&#97;&#45;&#98;&#41;&#36;&#46;&#32;&#92;&#98;&#108;&#97;&#99;&#107;&#115;&#113;&#117;&#97;&#114;&#101;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<h3 id="Show_that_">2. Show that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7771e4065a236dedd5ac44860b71d138_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#94;&#123;&#40;&#120;&#44;&#121;&#41;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#94;&#123;&#40;&#120;&#44;&#121;&#41;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;" title="Rendered by QuickLaTeX.com" height="15" width="149" style="vertical-align: 0px;"/></h3>
<p>By construction of the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-be35197935438fe9c3d507e5a5e58d4d_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#99;&#100;&#40;&#120;&#44;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="59" style="vertical-align: -4px;"/>, we know that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-04e29741293eda90ef30f95cb7bac735_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#103;&#99;&#100;&#40;&#120;&#44;&#121;&#41;&#32;&#61;&#32;&#117;&#120;&#45;&#118;&#121;" title="Rendered by QuickLaTeX.com" height="16" width="133" style="vertical-align: -4px;"/>. It follow that</p>
<p class="ql-center-displayed-equation" style="line-height: 85px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9b6bdabde2f63bd7f11feb1b3b7ea963_l3.png" height="85" width="273" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#97;&#94;&#123;&#117;&#120;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#38;&#61;&#32;&#40;&#97;&#94;&#120;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#41;&#94;&#117;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#92;&#92; &#38;&#61;&#32;&#40;&#98;&#94;&#50;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#41;&#94;&#117;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#92;&#92; &#38;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#97;&#94;&#123;&#117;&#120;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#94;&#123;&#117;&#120;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#92;&#92; &#38;&#32;&#97;&#94;&#123;&#118;&#121;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#94;&#123;&#118;&#121;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>The last two lines of the above gives another congruence expression:</p>
<p class="ql-center-displayed-equation" style="line-height: 12px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-957b71eb2002c26aa2db7414d77ea8e3_l3.png" height="12" width="171" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#97;&#94;&#123;&#117;&#120;&#125;&#98;&#94;&#123;&#118;&#121;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#97;&#94;&#123;&#118;&#121;&#125;&#98;&#94;&#123;&#117;&#120;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>Suppose that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-6db4d0486bb0340689668d425a54f1ca_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#118;&#121;&#32;&#60;&#32;&#117;&#120;" title="Rendered by QuickLaTeX.com" height="13" width="55" style="vertical-align: -3px;"/> as <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fcdcb0d92a70eadd8c6e2824044fa350_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#120;&#44;&#121;&#41;&#32;&#61;&#32;&#117;&#120;&#45;&#118;&#121;" title="Rendered by QuickLaTeX.com" height="16" width="109" style="vertical-align: -4px;"/> must be positive. Because <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c2004494465e157f8e047f47ddb5ee30_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#44;&#98;" title="Rendered by QuickLaTeX.com" height="14" width="22" style="vertical-align: -3px;"/> are both relatively prime to <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-10b1632902b9c2e110a72e529a5fad8a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#109;" title="Rendered by QuickLaTeX.com" height="7" width="14" style="vertical-align: 0px;"/>, then by the above lemma, we know that</p>
<p class="ql-center-displayed-equation" style="line-height: 37px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8da9bdab031a56bc4e9c53e22297c456_l3.png" height="37" width="485" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#97;&#94;&#123;&#117;&#120;&#125;&#98;&#94;&#123;&#118;&#121;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#97;&#94;&#123;&#118;&#121;&#125;&#98;&#94;&#123;&#117;&#120;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#97;&#94;&#123;&#117;&#120;&#125;&#98;&#94;&#123;&#118;&#121;&#125;&#125;&#123;&#98;&#94;&#123;&#118;&#121;&#125;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#97;&#94;&#123;&#118;&#121;&#125;&#98;&#94;&#123;&#117;&#120;&#125;&#125;&#123;&#98;&#94;&#123;&#118;&#121;&#125;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#109;&#125;&#123;&#92;&#103;&#99;&#100;&#40;&#109;&#44;&#98;&#94;&#123;&#118;&#121;&#125;&#41;&#61;&#49;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>Likewise, we can divide <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-547405106a8e7fa6d3d7561c466b2aed_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#94;&#123;&#118;&#121;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="21" style="vertical-align: 0px;"/> out from both sides</p>
<p class="ql-center-displayed-equation" style="line-height: 33px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-17bc339ac32c41c0d0ca95cb02a1042a_l3.png" height="33" width="396" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#97;&#94;&#123;&#117;&#120;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#97;&#94;&#123;&#118;&#121;&#125;&#98;&#94;&#123;&#117;&#120;&#45;&#118;&#121;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#97;&#94;&#123;&#117;&#120;&#125;&#125;&#123;&#97;&#94;&#123;&#118;&#121;&#125;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#97;&#94;&#123;&#118;&#121;&#125;&#98;&#94;&#123;&#117;&#120;&#45;&#118;&#121;&#125;&#125;&#123;&#97;&#94;&#123;&#118;&#121;&#125;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>this gives us our final congruence equivalence</p>
<p class="ql-center-displayed-equation" style="line-height: 12px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f691d1f5e92579dbfe10165b200522b9_l3.png" height="12" width="174" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#97;&#94;&#123;&#117;&#120;&#45;&#118;&#121;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#94;&#123;&#117;&#120;&#45;&#118;&#121;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>Because, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-35974516477cfdfbab112f7e55741b7e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#117;&#120;&#45;&#118;&#121;&#61;&#92;&#103;&#99;&#100;&#40;&#120;&#44;&#121;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="133" style="vertical-align: -4px;"/>, the above simplifies down to <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-638eb24e0321f39e104bda3118c1194e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#94;&#123;&#92;&#103;&#99;&#100;&#40;&#120;&#44;&#121;&#41;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#94;&#123;&#92;&#103;&#99;&#100;&#40;&#120;&#44;&#121;&#41;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;" title="Rendered by QuickLaTeX.com" height="15" width="185" style="vertical-align: 0px;"/>. <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e1850f4f75f78514aff6f5243df9b2e9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#98;&#108;&#97;&#99;&#107;&#115;&#113;&#117;&#97;&#114;&#101;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/></p>
<h4 id="Alternatively">Alternatively</h4>
<p>The same logic above can be used to justify that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f6a633febb86b1ed915bfd54b5141a73_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#94;&#123;&#124;&#120;&#45;&#121;&#124;&#125;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#98;&#94;&#123;&#124;&#120;&#45;&#121;&#124;&#125;&#32;&#92;&#109;&#111;&#100;&#32;&#109;" title="Rendered by QuickLaTeX.com" height="15" width="155" style="vertical-align: 0px;"/>, therefore, you can also show inductively, on the steps of the euclidean algorithm, that it preserves the properties of congruence mod m.</p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/hsqdlHila-c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2012/08/power-reduction-in-congruences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2012/08/power-reduction-in-congruences/</feedburner:origLink></item>
		<item>
		<title>Even Pascals</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/z4D38N6xxUI/</link>
		<comments>http://www.phailed.me/2012/08/even-pascals/#comments</comments>
		<pubDate>Tue, 14 Aug 2012 18:23:50 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Math Problems]]></category>
		<category><![CDATA[algebra]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[number theory]]></category>
		<category><![CDATA[titu]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1125</guid>
		<description><![CDATA[Let [latex]a=4k-1[/latex], where k is an integer. Prove that for any positive integer n the number

[latex]
$$
s_n = 1 - {n \choose 2}a + {n \choose 4}a^2 - {n \choose 6}a^3 + \cdots
$$
[/latex]

is divisible by [latex]2^{n-1}[/latex].]]></description>
				<content:encoded><![CDATA[<p></p><div class='toc tableofcontent'>
   <h2>Table Of Content</h2>
   <p class='contentTable_h3'><a href="#Find_a_closed_form_expression_of_">1. Find a closed form expression of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ab2d012337e5323f8849b6695d968f14_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="14" style="vertical-align: -2px;"/></a></p>
<p class='contentTable_h3'><a href="#Find_a_recurrence_relation_for_">2. Find a recurrence relation for <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ab2d012337e5323f8849b6695d968f14_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="14" style="vertical-align: -2px;"/></a></p>
<p class='contentTable_h3'><a href="#Show_that_">3. Show that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8f3b90d4688f72c71a1c1a681c5a4652_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#50;&#94;&#123;&#110;&#45;&#49;&#125;&#124;&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="18" width="49" style="vertical-align: -4px;"/></a></p>

</div><div class='tableofcontent-end'> </div><p></p>
<h3 id="Find_a_closed_form_expression_of_">1. Find a closed form expression of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ab2d012337e5323f8849b6695d968f14_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="14" style="vertical-align: -2px;"/></h3>
<p>We start with the construction of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-aea54ba5652a568299c0a69b9d530057_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#97;&#43;&#98;&#41;&#94;&#110;" title="Rendered by QuickLaTeX.com" height="16" width="52" style="vertical-align: -4px;"/>.</p>
<p class="ql-center-displayed-equation" style="line-height: 44px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-90a04e61800684c263a04420792e9a34_l3.png" height="44" width="178" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#40;&#97;&#43;&#98;&#41;&#94;&#110;&#32;&#61;&#32;&#92;&#115;&#117;&#109;&#95;&#123;&#107;&#61;&#48;&#125;&#94;&#123;&#110;&#125;&#32;&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#107;&#125;&#32;&#97;&#94;&#123;&#110;&#45;&#107;&#125;&#98;&#94;&#107;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>Since the first term of our series is a one, and the terms alternate in sign on odd powers, we should only consider polynomials <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a9ff3fe541697db67b7e914f240f724e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#49;&#45;&#120;&#41;&#94;&#110;" title="Rendered by QuickLaTeX.com" height="16" width="54" style="vertical-align: -4px;"/></p>
<p class="ql-center-displayed-equation" style="line-height: 38px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-38a6c9b7453e35c93e912e8aad46530b_l3.png" height="38" width="247" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#40;&#49;&#45;&#120;&#41;&#94;&#110;&#32;&#38;&#61;&#32;&#49;&#32;&#45;&#32;&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#49;&#125;&#120;&#32;&#43;&#32;&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#50;&#125;&#120;&#94;&#50;&#32;&#45;&#32;&#92;&#99;&#100;&#111;&#116;&#115; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Okay, but we still can&#8217;t completely remove the odd terms from the combinations. However, we see that if we were to add in another polynomial of the same degree, we can match up the terms so that the coefficients on the odd <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-0716d8c2f057b1c132c7296ba8b4e863_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#50;&#107;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="20" width="38" style="vertical-align: -6px;"/> are canceled. That is, we find the pair <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-598ad0a58a3487a484e36594f1ac001b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#44;&#121;" title="Rendered by QuickLaTeX.com" height="10" width="24" style="vertical-align: -3px;"/> such that</p>
<p class="ql-center-displayed-equation" style="line-height: 146px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f2fce925653de1d7f7f59b3533b6eca6_l3.png" height="146" width="560" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#40;&#49;&#45;&#120;&#41;&#94;&#110;&#32;&#43;&#32;&#40;&#49;&#43;&#121;&#41;&#94;&#110;&#32;&#38;&#61;&#32;&#40;&#49;&#43;&#49;&#41;&#32;&#43;&#32;&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#49;&#125;&#40;&#121;&#45;&#120;&#41;&#32;&#43;&#32;&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#50;&#125;&#40;&#121;&#94;&#50;&#32;&#43;&#32;&#120;&#94;&#50;&#41;&#32;&#43;&#32;&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#51;&#125;&#40;&#121;&#94;&#51;&#32;&#45;&#32;&#120;&#94;&#51;&#41;&#32;&#43;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#32;&#92;&#92; &#92;&#105;&#110;&#116;&#101;&#114;&#116;&#101;&#120;&#116;&#123;&#84;&#104;&#101;&#114;&#101;&#102;&#111;&#114;&#101;&#44;&#32;&#105;&#102;&#32;&#36;&#121;&#45;&#120;&#61;&#48;&#44;&#121;&#94;&#51;&#45;&#120;&#94;&#51;&#61;&#48;&#44;&#92;&#99;&#100;&#111;&#116;&#115;&#36;&#44;&#32;&#116;&#104;&#101;&#110;&#32;&#119;&#101;&#32;&#99;&#97;&#110;&#32;&#99;&#97;&#110;&#99;&#101;&#108;&#32;&#111;&#117;&#116;&#32;&#97;&#108;&#108;&#32;&#116;&#104;&#101;&#32;&#111;&#100;&#100;&#32;&#116;&#101;&#114;&#109;&#115;&#46;&#32;&#32;&#76;&#101;&#116;&#39;&#115;&#32;&#115;&#101;&#116;&#32;&#120;&#32;&#61;&#32;&#121;&#32;&#102;&#111;&#114;&#32;&#110;&#111;&#119;&#125; &#38;&#61;&#32;&#50;&#32;&#32;&#43;&#50;&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#50;&#125;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#94;&#50;&#32;&#43;&#32;&#120;&#94;&#50;&#125;&#123;&#50;&#125;&#32;&#43;&#50;&#123;&#110;&#32;&#92;&#99;&#104;&#111;&#111;&#115;&#101;&#32;&#52;&#125;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#94;&#52;&#32;&#43;&#32;&#120;&#94;&#52;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#99;&#100;&#111;&#116;&#115;&#32; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>In order to get <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ab2d012337e5323f8849b6695d968f14_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="14" style="vertical-align: -2px;"/>, we need to set</p>
<p class="ql-center-displayed-equation" style="line-height: 101px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-5364c6e1ae4afc3b744edd808c7c704c_l3.png" height="101" width="151" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#120;&#94;&#50;&#32;&#38;&#61;&#32;&#45;&#97;&#32;&#92;&#92; &#120;&#94;&#52;&#32;&#38;&#61;&#32;&#97;&#94;&#50;&#32;&#92;&#92; &#38;&#92;&#118;&#100;&#111;&#116;&#115;&#32;&#92;&#92; &#38;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#121;&#32;&#61;&#32;&#120;&#32;&#61;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#45;&#97;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>From this, we get the closed form expression of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-aff0662185151cc9a05b2cf95429f7bf_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#115;&#95;&#110;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#40;&#49;&#32;&#43;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#94;&#110;&#32;&#43;&#32;&#40;&#49;&#32;&#45;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#94;&#110;&#125;&#123;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="22" width="154" style="vertical-align: -5px;"/>. <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e1850f4f75f78514aff6f5243df9b2e9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#98;&#108;&#97;&#99;&#107;&#115;&#113;&#117;&#97;&#114;&#101;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/></p>
<h3 id="Find_a_recurrence_relation_for_">2. Find a recurrence relation for <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ab2d012337e5323f8849b6695d968f14_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="14" style="vertical-align: -2px;"/></h3>
<p>This may seem counter-intuitive, but the problem looks like one that can be solved via induction on <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ac360276039a23ef5aa6155959c5d4c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/>, which is much easier to do on a linear recurrence.</p>
<p>Recall from earlier and differential equation that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3752c2bbf559dbcbc75f64ea4bd2a19b_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#102;&#114;&#97;&#99;&#123;&#40;&#49;&#32;&#43;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#94;&#110;&#32;&#43;&#32;&#40;&#49;&#32;&#45;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#94;&#110;&#125;&#123;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="22" width="116" style="vertical-align: -5px;"/> is of the form of a linear recurrence with characteristic polynomial whose roots are <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ca6e65fa3f9c108eac735869c31bdd5d_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#49;&#32;&#92;&#112;&#109;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;" title="Rendered by QuickLaTeX.com" height="16" width="53" style="vertical-align: -4px;"/>. Let&#8217;s construct this polynomial in order to find the recurrence.</p>
<p class="ql-center-displayed-equation" style="line-height: 92px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1475aa9212f3366f429b3023ddaee14d_l3.png" height="92" width="267" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#112;&#95;&#115;&#40;&#120;&#41;&#32;&#38;&#61;&#32;&#40;&#120;&#32;&#45;&#32;&#40;&#49;&#32;&#43;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#41;&#40;&#120;&#32;&#45;&#32;&#40;&#49;&#32;&#45;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#40;&#40;&#120;&#45;&#49;&#41;&#32;&#43;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#40;&#40;&#120;&#45;&#49;&#41;&#32;&#45;&#32;&#105;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#40;&#120;&#45;&#49;&#41;&#94;&#50;&#32;&#43;&#32;&#40;&#92;&#115;&#113;&#114;&#116;&#32;&#97;&#41;&#94;&#50;&#32;&#92;&#92; &#38;&#61;&#32;&#120;&#94;&#50;&#32;&#45;&#32;&#50;&#120;&#32;&#43;&#32;&#40;&#97;&#43;&#49;&#41; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Recall that the characteristic polynomial of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-622a27f41bed0fece6344a05cd9a712f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#115;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#61;&#32;&#98;&#115;&#95;&#110;&#32;&#43;&#32;&#97;&#115;&#95;&#123;&#110;&#45;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="130" style="vertical-align: -3px;"/> is <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-528185b7aa5ec59fcb6faf304a6e5dc8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#112;&#95;&#115;&#40;&#120;&#41;&#32;&#61;&#32;&#120;&#94;&#50;&#32;&#45;&#32;&#98;&#120;&#32;&#45;&#32;&#97;" title="Rendered by QuickLaTeX.com" height="18" width="134" style="vertical-align: -4px;"/>, therefore, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b2f1b8bf0e8ce9d21ed24af3bde5e275_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#94;&#50;&#32;&#45;&#32;&#50;&#120;&#32;&#43;&#32;&#40;&#97;&#43;&#49;&#41;" title="Rendered by QuickLaTeX.com" height="18" width="117" style="vertical-align: -4px;"/> is the characteristic polynomial associated with</p>
<p class="ql-center-displayed-equation" style="line-height: 32px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c4539ea9fcbf2223490fc08722ea7eaa_l3.png" height="32" width="364" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#115;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#61;&#32;&#50;&#115;&#95;&#110;&#32;&#45;&#32;&#40;&#97;&#43;&#49;&#41;&#115;&#95;&#123;&#110;&#45;&#49;&#125;&#32;&#92;&#104;&#115;&#112;&#97;&#99;&#101;&#123;&#52;&#109;&#109;&#125;&#92;&#109;&#98;&#111;&#120;&#123;&#119;&#105;&#116;&#104;&#32;&#125;&#115;&#95;&#49;&#61;&#49;&#44;&#115;&#95;&#50;&#61;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#45;&#97;&#125;&#123;&#50;&#125;&#92;&#32;&#92;&#98;&#108;&#97;&#99;&#107;&#115;&#113;&#117;&#97;&#114;&#101;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<h3 id="Show_that_">3. Show that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8f3b90d4688f72c71a1c1a681c5a4652_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#50;&#94;&#123;&#110;&#45;&#49;&#125;&#124;&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="18" width="49" style="vertical-align: -4px;"/></h3>
<p>As brought up previously, we will prove this by induction on <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ac360276039a23ef5aa6155959c5d4c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#110;" title="Rendered by QuickLaTeX.com" height="7" width="9" style="vertical-align: 0px;"/>. Let <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-42199683db3e5c7ae38802476bed9980_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#80;&#95;&#110;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#50;&#94;&#123;&#110;&#45;&#49;&#125;&#124;&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="18" width="88" style="vertical-align: -4px;"/>, we will show that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d6928af037fe57a17455f8c60e160ecd_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#80;&#95;&#123;&#110;&#45;&#49;&#125;&#44;&#80;&#95;&#110;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#80;&#95;&#123;&#110;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="14" width="133" style="vertical-align: -3px;"/></p>
<p class="ql-center-displayed-equation" style="line-height: 136px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-05cc579ed545e6ef6e00da7b8fcb5111_l3.png" height="136" width="260" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#115;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#38;&#61;&#32;&#50;&#115;&#95;&#110;&#32;&#45;&#32;&#40;&#97;&#43;&#49;&#41;&#115;&#95;&#123;&#110;&#45;&#49;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#50;&#40;&#99;&#50;&#94;&#123;&#110;&#45;&#49;&#125;&#41;&#32;&#45;&#32;&#40;&#52;&#107;&#45;&#49;&#43;&#49;&#41;&#40;&#98;&#50;&#94;&#123;&#110;&#45;&#50;&#125;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#99;&#50;&#94;&#110;&#32;&#45;&#32;&#98;&#107;&#50;&#94;&#110;&#32;&#92;&#92; &#38;&#61;&#32;&#40;&#99;&#45;&#98;&#107;&#41;&#50;&#94;&#110;&#32;&#92;&#92; &#38;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#50;&#94;&#110;&#124;&#115;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#92;&#92; &#38;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#80;&#95;&#123;&#110;&#43;&#49;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>This concludes our proof that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-8f3b90d4688f72c71a1c1a681c5a4652_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#50;&#94;&#123;&#110;&#45;&#49;&#125;&#124;&#115;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="18" width="49" style="vertical-align: -4px;"/>. <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e1850f4f75f78514aff6f5243df9b2e9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#98;&#108;&#97;&#99;&#107;&#115;&#113;&#117;&#97;&#114;&#101;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/></p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/z4D38N6xxUI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2012/08/even-pascals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2012/08/even-pascals/</feedburner:origLink></item>
		<item>
		<title>Sequences in Sequences</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/DTUOo1XiA1M/</link>
		<comments>http://www.phailed.me/2012/08/sequences-in-sequences/#comments</comments>
		<pubDate>Tue, 14 Aug 2012 16:43:51 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Math Problems]]></category>
		<category><![CDATA[algebra]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[titu]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1113</guid>
		<description><![CDATA[Define the sequence [latex](a_n)_n[/latex] recursively by [latex]a_1 = 1[/latex] and
[latex]
$$
a_{n+1} = \frac{1 + 4a_n + \sqrt{1+24a_n}}{16} ,\hspace{4mm} \mbox{for $n \ge 1$.}
$$
[/latex]

Find an explicit formula for [latex]a_n[/latex] in terms of n.]]></description>
				<content:encoded><![CDATA[<p>Since this recurrence isn&#8217;t linear in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-b183cc187201a89221e106cae7db3446_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="15" style="vertical-align: -2px;"/>, we define a subsequence to get rid of that square root in the hopes that the resulting sequence can be expressed as a linear recurrence.</p>
<p class="ql-center-displayed-equation" style="line-height: 389px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4045b364dc00cfc3c43078f77ddfb214_l3.png" height="389" width="400" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#109;&#98;&#111;&#120;&#123;&#76;&#101;&#116;&#32;&#125;&#98;&#95;&#110;&#32;&#38;&#61;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#49;&#43;&#50;&#52;&#97;&#95;&#110;&#125;&#32;&#92;&#92; &#98;&#95;&#123;&#110;&#43;&#49;&#125;&#94;&#50;&#32;&#38;&#61;&#32;&#49;&#43;&#50;&#52;&#97;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#49;&#32;&#43;&#32;&#50;&#52;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#32;&#43;&#32;&#52;&#97;&#95;&#110;&#32;&#43;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#49;&#43;&#50;&#52;&#97;&#95;&#110;&#125;&#125;&#123;&#49;&#54;&#125;&#32;&#92;&#92; &#92;&#105;&#110;&#116;&#101;&#114;&#116;&#101;&#120;&#116;&#123;&#78;&#111;&#116;&#105;&#99;&#101;&#32;&#116;&#104;&#97;&#116;&#32;&#36;&#97;&#95;&#110;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#110;&#94;&#50;&#45;&#49;&#125;&#123;&#50;&#52;&#125;&#36;&#44;&#32;&#119;&#101;&#32;&#99;&#97;&#110;&#32;&#110;&#111;&#119;&#32;&#119;&#114;&#105;&#116;&#101;&#32;&#36;&#97;&#95;&#110;&#36;&#32;&#105;&#110;&#32;&#116;&#101;&#114;&#109;&#115;&#32;&#111;&#102;&#32;&#36;&#98;&#95;&#110;&#94;&#50;&#36;&#125; &#38;&#61;&#32;&#49;&#32;&#43;&#32;&#50;&#52;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#32;&#43;&#32;&#52;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#110;&#94;&#50;&#45;&#49;&#125;&#123;&#50;&#52;&#125;&#32;&#43;&#32;&#98;&#95;&#110;&#125;&#123;&#49;&#54;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#49;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#125;&#123;&#50;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#32;&#49;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#110;&#94;&#50;&#45;&#49;&#125;&#123;&#54;&#125;&#32;&#43;&#32;&#98;&#95;&#110;&#32;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#49;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#110;&#94;&#50;&#125;&#123;&#52;&#125;&#32;&#45;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#52;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#98;&#95;&#110;&#125;&#123;&#50;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#52;&#43;&#54;&#45;&#49;&#43;&#98;&#95;&#110;&#94;&#50;&#32;&#43;&#54;&#98;&#95;&#110;&#125;&#123;&#52;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#110;&#43;&#51;&#125;&#123;&#50;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#94;&#50;&#32;&#92;&#92; &#98;&#95;&#110;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#110;&#43;&#51;&#125;&#123;&#50;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>We now construct a closed form expression for <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-c5494ecdd392a7fa432f16efab7571bd_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#98;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="13" width="14" style="vertical-align: -2px;"/></p>
<p class="ql-center-displayed-equation" style="line-height: 274px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3a6342c0656d85bd7b38a6a5fdf771b0_l3.png" height="274" width="182" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#98;&#95;&#49;&#32;&#38;&#61;&#32;&#53;&#32;&#92;&#92; &#98;&#95;&#50;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#49;&#125;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#125;&#123;&#50;&#125;&#32;&#92;&#92; &#98;&#95;&#51;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#49;&#125;&#123;&#52;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#125;&#123;&#52;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#125;&#123;&#50;&#125;&#32;&#92;&#92; &#38;&#32;&#92;&#118;&#100;&#111;&#116;&#115;&#32;&#92;&#92; &#98;&#95;&#107;&#32;&#38;&#61;&#32;&#98;&#95;&#49;&#32;&#50;&#94;&#123;&#49;&#45;&#107;&#125;&#32;&#43;&#32;&#51;&#32;&#92;&#115;&#117;&#109;&#95;&#123;&#105;&#61;&#49;&#125;&#94;&#123;&#107;&#45;&#49;&#125;&#50;&#94;&#123;&#45;&#105;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#98;&#95;&#49;&#32;&#50;&#94;&#123;&#49;&#45;&#107;&#125;&#32;&#43;&#32;&#51;&#92;&#108;&#101;&#102;&#116;&#40;&#49;&#32;&#45;&#32;&#50;&#94;&#123;&#49;&#45;&#107;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#51;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#95;&#49;&#32;&#45;&#32;&#51;&#125;&#123;&#50;&#94;&#123;&#107;&#45;&#49;&#125;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#51;&#32;&#43;&#32;&#50;&#94;&#123;&#45;&#107;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Therefore, we see by construction that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-dee152a8d9f9634c2235e1c6548314f0_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;&#95;&#110;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#108;&#101;&#102;&#116;&#40;&#51;&#32;&#43;&#32;&#50;&#94;&#123;&#45;&#107;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#45;&#49;&#125;&#123;&#50;&#53;&#125;" title="Rendered by QuickLaTeX.com" height="26" width="103" style="vertical-align: -5px;"/>. <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e1850f4f75f78514aff6f5243df9b2e9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#98;&#108;&#97;&#99;&#107;&#115;&#113;&#117;&#97;&#114;&#101;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/></p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/DTUOo1XiA1M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2012/08/sequences-in-sequences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2012/08/sequences-in-sequences/</feedburner:origLink></item>
		<item>
		<title>More Linear Recurrences</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/RphQ9mMMcT0/</link>
		<comments>http://www.phailed.me/2012/08/more-linear-recurrences/#comments</comments>
		<pubDate>Tue, 14 Aug 2012 05:55:31 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Math Problems]]></category>
		<category><![CDATA[algebra]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[titu]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1104</guid>
		<description><![CDATA[Let [latex](x_n )_n = 0[/latex] be defined by the recurrence relation [latex]x_{n + 1} = ax_n + bx_{n - 1}[/latex], with [latex]x_0 = 0[/latex]. Show that the expression [latex]x^2_n - x_{n - 1} x_{n + 1}[/latex] depends only on b and [latex]x_1[/latex], but not on a.]]></description>
				<content:encoded><![CDATA[<p>In order to do this problem, we will first prove a few trivial properties of its system first.</p>
<h4 id="_is_linear_in_"><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-42c5cb56def22c41a32ad435305175ce_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="16" style="vertical-align: -2px;"/> is linear in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d35468119f8e0f55fe9a58eb4a348d00_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="10" width="15" style="vertical-align: -3px;"/></h4>
<p>We show this inductively on the naturals. Suppose <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-06cabb60f3ffcdf41032c203cb7262ba_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#80;&#95;&#110;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#120;&#95;&#110;&#32;&#61;&#32;&#99;&#95;&#110;&#32;&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="14" width="106" style="vertical-align: -3px;"/>, then, we show <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d75a35337c1c0c8384254fc0d3f16431_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#80;&#95;&#123;&#107;&#45;&#50;&#125;&#44;&#80;&#95;&#123;&#107;&#45;&#49;&#125;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#80;&#95;&#107;" title="Rendered by QuickLaTeX.com" height="15" width="132" style="vertical-align: -4px;"/></p>
<p class="ql-center-displayed-equation" style="line-height: 110px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-a9cdcb534d18ace8dc118f73fa23813a_l3.png" height="110" width="307" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#120;&#95;&#123;&#107;&#43;&#49;&#125;&#32;&#38;&#61;&#32;&#97;&#120;&#95;&#107;&#32;&#43;&#32;&#98;&#120;&#95;&#123;&#107;&#45;&#49;&#125;&#32;&#38;&#32;&#80;&#95;&#123;&#107;&#45;&#49;&#125;&#44;&#80;&#95;&#107;&#32;&#92;&#92; &#38;&#61;&#32;&#99;&#95;&#107;&#32;&#120;&#95;&#49;&#32;&#43;&#32;&#99;&#95;&#123;&#107;&#45;&#49;&#125;&#32;&#120;&#95;&#49;&#32;&#92;&#92; &#38;&#61;&#32;&#40;&#99;&#95;&#107;&#32;&#43;&#32;&#99;&#95;&#123;&#107;&#45;&#49;&#125;&#41;&#32;&#120;&#95;&#49;&#32;&#92;&#92; &#38;&#61;&#32;&#99;&#95;&#123;&#107;&#43;&#49;&#125;&#32;&#120;&#95;&#49;&#32;&#92;&#92; &#38;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#80;&#95;&#123;&#107;&#43;&#49;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>This concludes our proof that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7464842769b1c38e3b4dd5e04cb17614_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;&#32;&#61;&#32;&#99;&#95;&#110;&#32;&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="10" width="68" style="vertical-align: -3px;"/> for some number <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-beae7515ea040a3fe4dfff234c7692d4_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#99;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="14" style="vertical-align: -2px;"/>, and is hence linear in <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d35468119f8e0f55fe9a58eb4a348d00_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="10" width="15" style="vertical-align: -3px;"/>. <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7c135016bc59ec003542db0d90c72774_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#98;&#108;&#97;&#99;&#107;&#98;&#111;&#120;" title="Rendered by QuickLaTeX.com" height="1" width="1" style="vertical-align: 0px;"/></p>
<p>Therefore <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-9d926274d58aebbca5f6af9800bf6f7d_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#120;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#61;&#32;&#67;&#32;&#120;&#95;&#49;&#94;&#50;" title="Rendered by QuickLaTeX.com" height="19" width="149" style="vertical-align: -5px;"/>, and without loss of generality, we can replace <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d35468119f8e0f55fe9a58eb4a348d00_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#49;" title="Rendered by QuickLaTeX.com" height="10" width="15" style="vertical-align: -3px;"/> with any arbitrary number. We will pick <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-11b54f275d4564cce3e9e59159f26ac5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#49;&#32;&#61;&#32;&#49;" title="Rendered by QuickLaTeX.com" height="14" width="43" style="vertical-align: -3px;"/> for the sake of simplicity.</p>
<h4 id="Guess_and_check">Guess and check</h4>
<p>Let&#8217;s generate a few numbers for <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-42c5cb56def22c41a32ad435305175ce_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;" title="Rendered by QuickLaTeX.com" height="9" width="16" style="vertical-align: -2px;"/> with <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-11b54f275d4564cce3e9e59159f26ac5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#49;&#32;&#61;&#32;&#49;" title="Rendered by QuickLaTeX.com" height="14" width="43" style="vertical-align: -3px;"/></p>
<p class="ql-center-displayed-equation" style="line-height: 145px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ed302136c8f1b73c844acdf4aaf5f606_l3.png" height="145" width="330" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#91;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#116;&#97;&#98;&#117;&#108;&#97;&#114;&#125;&#123;&#99;&#32;&#124;&#32;&#99;&#32;&#124;&#32;&#99;&#125; &#110;&#32;&#38;&#32;&#120;&#95;&#110;&#32;&#38;&#32;&#120;&#95;&#110;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#120;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#92;&#92;&#32;&#92;&#104;&#108;&#105;&#110;&#101; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#92;&#118;&#97;&#114;&#110;&#111;&#116;&#104;&#105;&#110;&#103;&#92;&#92; &#49;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#49;&#92;&#92; &#50;&#32;&#38;&#32;&#97;&#32;&#38;&#32;&#97;&#94;&#50;&#32;&#45;&#32;&#97;&#94;&#50;&#32;&#45;&#32;&#98;&#32;&#61;&#32;&#45;&#98;&#92;&#92; &#51;&#32;&#38;&#32;&#97;&#94;&#50;&#32;&#43;&#32;&#98;&#32;&#38;&#32;&#97;&#94;&#52;&#32;&#43;&#32;&#50;&#97;&#94;&#50;&#98;&#32;&#43;&#32;&#98;&#94;&#50;&#32;&#45;&#32;&#97;&#94;&#52;&#32;&#45;&#32;&#50;&#97;&#94;&#50;&#98;&#32;&#61;&#32;&#98;&#94;&#50;&#92;&#92; &#52;&#32;&#38;&#32;&#97;&#94;&#51;&#32;&#43;&#32;&#50;&#97;&#98;&#32;&#38;&#32;&#45;&#98;&#94;&#51;&#32;&#92;&#92; &#92;&#118;&#100;&#111;&#116;&#115;&#32;&#38;&#32;&#92;&#118;&#100;&#111;&#116;&#115;&#32;&#38;&#32;&#92;&#118;&#100;&#111;&#116;&#115; &#92;&#101;&#110;&#100;&#123;&#116;&#97;&#98;&#117;&#108;&#97;&#114;&#125;&#92;&#93;" title="Rendered by QuickLaTeX.com"/></p>
<p>This naturally suggests that </p>
<p class="ql-center-displayed-equation" style="line-height: 19px;"><span class="ql-right-eqno"> (1) </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3dc64da68a7d2541e5f38c5609c3bce3_l3.png" height="19" width="160" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#120;&#95;&#110;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#120;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#61;&#32;&#40;&#45;&#98;&#41;&#94;&#110; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<h4 id="Show_that_">Show that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb8400297dbb66ecde92aa80da018a56_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#120;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#61;&#32;&#40;&#45;&#98;&#41;&#94;&#110;" title="Rendered by QuickLaTeX.com" height="18" width="160" style="vertical-align: -4px;"/></h4>
<p>We will prove this via induction on the naturals. Let <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fda530c7d3e169901c2fb2f8f85c06f4_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#80;&#95;&#110;&#32;&#92;&#101;&#113;&#117;&#105;&#118;&#32;&#120;&#95;&#110;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#120;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#61;&#32;&#40;&#45;&#98;&#41;&#94;&#110;" title="Rendered by QuickLaTeX.com" height="18" width="199" style="vertical-align: -4px;"/>, then from the table above, it is obvious that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4a03ad56be7aac5536f458b1fe2d34ed_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#80;&#95;&#49;&#44;&#80;&#95;&#50;" title="Rendered by QuickLaTeX.com" height="14" width="40" style="vertical-align: -3px;"/> holds. We will now show that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-56fac1c63dbb3aeab2f3a84e6cb6c5dc_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#80;&#95;&#107;&#32;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#80;&#95;&#123;&#107;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="15" width="91" style="vertical-align: -4px;"/>. Informally, we will expand the <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f1577be64e4ada0a25f8152e0c0ac25a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#123;&#107;&#43;&#50;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="31" style="vertical-align: -4px;"/> term within the first order recursive expansion of <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-f17b9ec1c5b9cd71e1d38407fd4e9e9c_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#123;&#107;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="11" width="31" style="vertical-align: -4px;"/> along with the equivalent construct <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-bc72049794ee9517383d09aece2002db_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#107;&#94;&#50;&#32;&#61;&#32;&#40;&#45;&#98;&#41;&#94;&#107;&#32;&#43;&#32;&#120;&#95;&#123;&#107;&#45;&#49;&#125;&#120;&#95;&#123;&#107;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="19" width="157" style="vertical-align: -5px;"/>. The body of the induction is as follows:</p>
<p class="ql-center-displayed-equation" style="line-height: 230px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-4417142539d2fe94c31ab344c6322fca_l3.png" height="230" width="401" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#120;&#95;&#123;&#107;&#43;&#49;&#125;&#32;&#38;&#61;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#107;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#32;&#92;&#92; &#38;&#61;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#107;&#40;&#98;&#120;&#95;&#107;&#32;&#43;&#32;&#97;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#94;&#50;&#32;&#45;&#32;&#98;&#120;&#95;&#107;&#94;&#50;&#32;&#45;&#32;&#97;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#120;&#95;&#107;&#32;&#92;&#92; &#38;&#61;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#94;&#50;&#32;&#45;&#32;&#98;&#92;&#108;&#101;&#102;&#116;&#40;&#40;&#45;&#98;&#41;&#94;&#107;&#32;&#43;&#32;&#120;&#95;&#123;&#107;&#45;&#49;&#125;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#32;&#45;&#32;&#97;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#120;&#95;&#107;&#32;&#38;&#32;&#80;&#95;&#107;&#32;&#92;&#92; &#38;&#61;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#94;&#50;&#32;&#43;&#32;&#40;&#45;&#98;&#41;&#94;&#123;&#107;&#43;&#49;&#125;&#32;&#45;&#32;&#98;&#120;&#95;&#123;&#107;&#45;&#49;&#125;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#32;&#45;&#32;&#97;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#120;&#95;&#107;&#32;&#92;&#92; &#38;&#61;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#94;&#50;&#32;&#43;&#32;&#40;&#45;&#98;&#41;&#94;&#123;&#107;&#43;&#49;&#125;&#32;&#45;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#40;&#98;&#120;&#95;&#123;&#107;&#45;&#49;&#125;&#32;&#43;&#32;&#97;&#120;&#95;&#123;&#107;&#125;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#94;&#50;&#32;&#43;&#32;&#40;&#45;&#98;&#41;&#94;&#123;&#107;&#43;&#49;&#125;&#32;&#45;&#32;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#40;&#120;&#95;&#123;&#107;&#43;&#49;&#125;&#41;&#32;&#92;&#92; &#38;&#61;&#32;&#40;&#45;&#98;&#41;&#94;&#123;&#107;&#43;&#49;&#125;&#32;&#92;&#92; &#38;&#92;&#105;&#109;&#112;&#108;&#105;&#101;&#115;&#32;&#80;&#95;&#123;&#107;&#43;&#49;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>This concludes our proof that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-fb8400297dbb66ecde92aa80da018a56_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#120;&#95;&#123;&#110;&#43;&#49;&#125;&#32;&#61;&#32;&#40;&#45;&#98;&#41;&#94;&#110;" title="Rendered by QuickLaTeX.com" height="18" width="160" style="vertical-align: -4px;"/> and the proof that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-7ebeea3e735d4d8385e545417e8c68f3_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;&#94;&#50;&#32;&#45;&#32;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#120;&#95;&#123;&#110;&#43;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="18" width="100" style="vertical-align: -4px;"/> does not depend on <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-3b847538d72cf29f89280df6e002096f_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#97;" title="Rendered by QuickLaTeX.com" height="7" width="8" style="vertical-align: 0px;"/>. <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e1850f4f75f78514aff6f5243df9b2e9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#98;&#108;&#97;&#99;&#107;&#115;&#113;&#117;&#97;&#114;&#101;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/></p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/RphQ9mMMcT0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2012/08/more-linear-recurrences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2012/08/more-linear-recurrences/</feedburner:origLink></item>
		<item>
		<title>Almost Linear</title>
		<link>http://feedproxy.google.com/~r/SanityPhailedme/~3/rW377bCDLKI/</link>
		<comments>http://www.phailed.me/2012/08/almost-linear/#comments</comments>
		<pubDate>Tue, 14 Aug 2012 03:32:42 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Math Problems]]></category>
		<category><![CDATA[algebra]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[titu]]></category>

		<guid isPermaLink="false">http://www.phailed.me/?p=1089</guid>
		<description><![CDATA[Find the general term of the sequence given by [latex]x_0 = 3, x_1 = 4[/latex], and 

[latex]$$(n + 1 )(n + 2 )x_n = 4 (n + 1 )(n + 3 )x_{n - 1} - 4 (n + 2 )(n + 3 )x_{n - 2}$$[/latex]]]></description>
				<content:encoded><![CDATA[<p>We want to formulate this problem as <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-ec6aef6429ba18cfad14bc773ac700ef_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;&#32;&#61;&#32;&#102;&#40;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#44;&#32;&#120;&#95;&#123;&#110;&#45;&#50;&#125;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="130" style="vertical-align: -4px;"/> instead, so the natural thing to do is to divide both sides by <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-6117ddf88d05f164faf788a8c834c1c8_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#40;&#110;&#43;&#49;&#41;&#40;&#110;&#43;&#50;&#41;" title="Rendered by QuickLaTeX.com" height="16" width="95" style="vertical-align: -4px;"/></p>
<p class="ql-center-displayed-equation" style="line-height: 457px;"><span class="ql-right-eqno"> &nbsp; </span><span class="ql-left-eqno"> &nbsp; </span><img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-1772c9727131c8437d037d3b87b43c5f_l3.png" height="457" width="513" class="ql-img-displayed-equation quicklatex-auto-format" alt="&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#120;&#95;&#123;&#110;&#125;&#32;&#38;&#61;&#32;&#52;&#92;&#102;&#114;&#97;&#99;&#123;&#110;&#43;&#51;&#125;&#123;&#110;&#43;&#50;&#125;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#32;&#45;&#32;&#52;&#92;&#102;&#114;&#97;&#99;&#123;&#110;&#43;&#51;&#125;&#123;&#110;&#43;&#49;&#125;&#120;&#95;&#123;&#110;&#45;&#50;&#125;&#32;&#92;&#92; &#92;&#102;&#114;&#97;&#99;&#123;&#120;&#95;&#123;&#110;&#125;&#125;&#123;&#110;&#43;&#51;&#125;&#32;&#38;&#61;&#32;&#52;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#95;&#123;&#110;&#45;&#49;&#125;&#125;&#123;&#120;&#43;&#50;&#125;&#32;&#45;&#32;&#52;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#95;&#123;&#110;&#45;&#50;&#125;&#125;&#123;&#110;&#43;&#49;&#125;&#32;&#92;&#92; &#92;&#105;&#110;&#116;&#101;&#114;&#116;&#101;&#120;&#116;&#123;&#83;&#105;&#110;&#99;&#101;&#32;&#119;&#101;&#32;&#115;&#101;&#101;&#32;&#97;&#32;&#109;&#111;&#110;&#111;&#116;&#111;&#110;&#105;&#99;&#32;&#112;&#97;&#116;&#116;&#101;&#114;&#110;&#44;&#32;&#119;&#101;&#32;&#99;&#97;&#110;&#32;&#100;&#101;&#114;&#105;&#118;&#101;&#32;&#97;&#32;&#108;&#105;&#110;&#101;&#97;&#114;&#32;&#114;&#101;&#99;&#117;&#114;&#114;&#101;&#110;&#99;&#101;&#32;&#36;&#122;&#95;&#110;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#120;&#95;&#123;&#110;&#125;&#125;&#123;&#110;&#43;&#51;&#125;&#36;&#125; &#122;&#95;&#110;&#32;&#38;&#61;&#32;&#52;&#32;&#122;&#95;&#123;&#110;&#45;&#49;&#125;&#32;&#45;&#32;&#52;&#122;&#95;&#123;&#110;&#45;&#50;&#125;&#32;&#92;&#92; &#112;&#95;&#90;&#40;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#41;&#32;&#38;&#61;&#32;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#94;&#50;&#32;&#45;&#32;&#52;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#32;&#43;&#32;&#52;&#32;&#92;&#92; &#92;&#108;&#97;&#109;&#98;&#100;&#97;&#95;&#49;&#44;&#92;&#108;&#97;&#109;&#98;&#100;&#97;&#95;&#50;&#32;&#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#52;&#32;&#92;&#112;&#109;&#32;&#92;&#115;&#113;&#114;&#116;&#123;&#49;&#54;&#45;&#49;&#54;&#125;&#125;&#123;&#50;&#125;&#32;&#61;&#32;&#50;&#44;&#50;&#32;&#92;&#92; &#92;&#105;&#110;&#116;&#101;&#114;&#116;&#101;&#120;&#116;&#123;&#65;&#115;&#32;&#119;&#105;&#116;&#104;&#32;&#79;&#68;&#69;&#115;&#32;&#119;&#104;&#111;&#115;&#101;&#32;&#99;&#104;&#97;&#114;&#97;&#99;&#116;&#101;&#114;&#105;&#115;&#116;&#105;&#99;&#32;&#112;&#111;&#108;&#121;&#110;&#111;&#109;&#105;&#97;&#108;&#32;&#97;&#114;&#101;&#32;&#114;&#97;&#110;&#107;&#32;&#100;&#101;&#102;&#105;&#99;&#105;&#101;&#110;&#116;&#44;&#32;&#119;&#101;&#32;&#107;&#110;&#111;&#119;&#32;&#116;&#104;&#97;&#116;&#32;&#36;&#122;&#95;&#110;&#32;&#61;&#32;&#65;&#50;&#94;&#110;&#32;&#43;&#32;&#66;&#110;&#50;&#94;&#123;&#110;&#45;&#49;&#125;&#36;&#44;&#32;&#97;&#110;&#100;&#32;&#97;&#112;&#112;&#108;&#121;&#32;&#105;&#110;&#105;&#116;&#105;&#97;&#108;&#32;&#118;&#97;&#108;&#117;&#101;&#32;&#99;&#111;&#110;&#100;&#105;&#116;&#105;&#111;&#110;&#115;&#32;&#111;&#110;&#32;&#36;&#122;&#95;&#48;&#36;&#32;&#97;&#110;&#100;&#32;&#36;&#122;&#95;&#49;&#36;&#32;&#116;&#111;&#32;&#102;&#105;&#110;&#100;&#32;&#116;&#104;&#101;&#105;&#114;&#32;&#99;&#111;&#101;&#102;&#102;&#105;&#99;&#105;&#101;&#110;&#116;&#115;&#125; &#122;&#95;&#48;&#32;&#38;&#61;&#32;&#65;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#51;&#125;&#123;&#51;&#125;&#32;&#92;&#92; &#122;&#95;&#49;&#32;&#38;&#61;&#32;&#50;&#65;&#32;&#43;&#32;&#66;&#32;&#92;&#92; &#38;&#61;&#32;&#66;&#32;&#43;&#32;&#50;&#32;&#92;&#92; &#38;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#52;&#125;&#123;&#52;&#125;&#32;&#92;&#92; &#66;&#32;&#38;&#61;&#32;&#45;&#49; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125;" title="Rendered by QuickLaTeX.com"/></p>
<p>Therefore, <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-d6edf6d7abb67b2486ff46d5bb24e901_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#122;&#95;&#110;&#32;&#61;&#32;&#50;&#94;&#110;&#32;&#45;&#32;&#110;&#50;&#94;&#123;&#110;&#45;&#49;&#125;" title="Rendered by QuickLaTeX.com" height="16" width="110" style="vertical-align: -2px;"/>, which means that <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-02cf1193fdf8ef8ed469ad051a54461e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#120;&#95;&#110;&#32;&#61;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#50;&#94;&#110;&#45;&#110;&#50;&#94;&#123;&#110;&#45;&#49;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#40;&#110;&#43;&#51;&#41;" title="Rendered by QuickLaTeX.com" height="19" width="178" style="vertical-align: -5px;"/>. <img src="http://www.phailed.me/wp-content/ql-cache/quicklatex.com-e1850f4f75f78514aff6f5243df9b2e9_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#92;&#98;&#108;&#97;&#99;&#107;&#115;&#113;&#117;&#97;&#114;&#101;" title="Rendered by QuickLaTeX.com" height="11" width="12" style="vertical-align: 0px;"/></p>
<img src="http://feeds.feedburner.com/~r/SanityPhailedme/~4/rW377bCDLKI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.phailed.me/2012/08/almost-linear/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.phailed.me/2012/08/almost-linear/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 14.808 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-05-22 19:38:53 -->
