Skip to content

Instantly share code, notes, and snippets.

@tachyondecay
Created March 14, 2013 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tachyondecay/5160466 to your computer and use it in GitHub Desktop.
Save tachyondecay/5160466 to your computer and use it in GitHub Desktop.
<user_review>I read math books for fun. I realize that, right away, this puts me in an unusual portion of the population. It’s not &lt;em&gt;just&lt;/em&gt; my fancy math degree that makes these books attractive. However, I do think that there are some math books written for people interested in math (whether professionally or amateurly), and then there are math books written for people who, usually thanks to a bad experience in school, have sworn off math like they said they would swear off cheap booze. &lt;em&gt;Our Days Are Numbered&lt;/em&gt; is one of the latter. In a passionate and personal exploration of shape, algebra, geometry, and number, Jason I. Brown illuminates the fundamental mathematics behind some everyday tasks. While some people will still run away screaming, others will hopefully begin to see math in a new way.&lt;br /&gt;&lt;br /&gt;Among the topics Brown explores are: converting between units, using graphs to display data, the meaning behind averages, the role of chance in decision-making, networks and coincidences, prime numbers in cryptography, fractals in art, and the math behind the mystery of the Beatles’ Chord. Each chapter is bookended by a short, two- or three-paragraph anecdote related to its given topic. For the main body of the chapter, Brown gradually develops some of the math behind common tasks. For example, he shows how an understanding of ratio and conversion factors makes converting between units a breeze without any memorization (aside from the factor itself, of course). Later, he explains why the Web and social networking has guaranteed that graph theory will remain a practical and important field of math for a long time.&lt;br /&gt;&lt;br /&gt;This is not really &lt;em&gt;my&lt;/em&gt; kind of math book, and that isn’t even because of the audience or the way Brown presents the math. Rather, I read math books for the &lt;em&gt;story&lt;/em&gt;. I’m interested in math books that take a specific topic and explore its history, its present state, and the different ways to interpret it using mathematics. &lt;em&gt;Our Days Are Numbered&lt;/em&gt; instead covers a variety of topics. There isn’t anything wrong with this approach. However, each of these topics can be (and has been) the subject of entire, weighty tombs. It’s difficult for Brown to do them justice. Sometimes, such as with the chapter on conversion factors, he does a very thorough job. Other times, such as with his explanation of prime numbers and Internet security, he leaves something to be desired.&lt;br /&gt;&lt;br /&gt;Also, much of one’s enjoyment will hinge on how one much one likes or dislikes Brown’s writing style. As the chapter titles and subheadings demonstrate, he is a man of corny humour, easy puns, and deprecating remarks towards himself and fellow mathematicians. I can get behind the first and third attribute, and I can ignore the second. Although I think a book any longer might have begun pushing its luck, as it is, I enjoyed Brown’s conversational and easygoing style. Others will find it overbearing and intrusive, however, and there is no escape from it here.&lt;br /&gt;&lt;br /&gt;So, &lt;em&gt;Our Days Are Numbered&lt;/em&gt; isn’t &lt;em&gt;my&lt;/em&gt; mathematical cup of tea, but could it be anyone’s? Well, one way in which this book excels is Brown’s unrelenting insistence that math is useful, relevant, and not at all scary. As a math enthusiast and math teacher, the opposites of these sentiments besiege me constantly. I love how Brown comments on the somewhat unique reception math receives at parties:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;When I tell people what I do for a living, the most common response is a look of dismay, followed by “I always hated mathematics!” This statement is made with relish and without a hint of embarrassment. I don’t think there is another profession out there that gets the same response. Do people state they’ve always hated English? Music? Lawn care? I think not.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Tongue-in-cheek, Brown touches on a very crucial and deplorable fact: hating math is socially acceptable. It’s &lt;em&gt;cool&lt;/em&gt; to disparage math and one’s ability to do math. To some extent, the aura of nerdery surrounds all of the STEM fields, but scientists and engineers get a little more recognition—people’s eyes might glaze over if one announces oneself as a theoretical physicist, but there is a little gleam of gruding respect. Mathematicians, however … what do they even &lt;em&gt;do&lt;/em&gt;?&lt;br /&gt;&lt;br /&gt;The social acceptability of disparaging mathematics troubles me. Math is the foundation of the other three STEM fields. Science, technlogy, and engineering are all fields that require creative, passionate thinkers. Yet from an early age we send children signals that math is a dull, uncreative subject and it’s OK to hate it for being boring and irrelevant. This is nothing short of educational sabotage. It’s certainly fine for people not to like math, and I understand how parts of the educational system foster that feeling. But we should do everything we can to avoid reinforcing that notion, especially among our children.&lt;br /&gt;&lt;br /&gt;Hence the power of this book. Brown takes it as a given that math is a useful, powerful tool in the everyday world. He isn’t out to convert everyone to a science or engineering job. He isn’t trying to shoehorn calculus into a discussion of changing a car tire. (As a teacher, the incessant call to include real-world applications and contexts in my lessons wearies me at times.) He is careful not to insist that everyone uses or needs all of this math all the time—you don’t &lt;em&gt;need&lt;/em&gt; to know how to use prime numbers in order to keep your online banking secure. But isn’t it nice to know why it &lt;em&gt;is&lt;/em&gt; secure?&lt;br /&gt;&lt;br /&gt;Brown’s non-evangelical stance is refreshing, though it can also be a little frustrating. &lt;em&gt;Our Days Are Numbered&lt;/em&gt; lacks a true, cohesive message, aside from the idea in the title. With no introduction and no conclusion, Brown relies on the title and the chapters to come together to create that singular idea. While not essential, some kind of introduction or meta-narrative would lend additional structure to this otherwise scattered text.&lt;br /&gt;&lt;br /&gt;With brilliant mathematics, hardcore mystery-solving, and no small amount of humour, &lt;em&gt;Our Days Are Numbered&lt;/em&gt; is a well-written and very successful math book. It isn’t anywhere close to my Platonic ideal of what a math book should be—but that’s me being picky. Nor do I think, in the long run, that people convinced math is uninteresting or “not for me” will find their convictions toppled by anything in here. But for anyone who is open to learning about the role of math in everyday life, there is definitely something here, waiting to be read.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://creativecommons.org/licenses/by-nc/3.0/" rel="nofollow"&gt;
&lt;img alt="Creative Commons BY-NC License" width="88" height="31" src="http://i.creativecommons.org/l/by-nc/3.0/88x31.png" class="escapedImg" /&gt;&lt;/a&gt;</user_review>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings">
<!--
A tolerant truncation utility
-->
<xsl:template name="truncate">
<xsl:param name="node" />
<xsl:param name="limit" />
<!--
Append this to the end of the value, if we have truncated it.
-->
<xsl:param name="suffix" select="'&#x2026;'" />
<!--
Tolerance allows words that fall over the required length be
appended, as long as they don't go over $length + $tolerance.
-->
<xsl:param name="tolerance" select="3" />
<!--
Treat any of these characters as the end of a word.
-->
<xsl:param name="delimiters" select="str:tokenize(' -!?:)(;,.…&#x2013;&#x2014;&#160;', '')" />
<!-- Find actual limit -->
<xsl:variable name="limit">
<xsl:choose>
<xsl:when test="string-length($node) &lt;= $limit">
<xsl:value-of select="string-length($node)" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="preceding-delimiter">
<xsl:call-template name="truncate-find-delimiter">
<xsl:with-param name="value">
<xsl:for-each select="str:tokenize(substring($node, 1, $limit + 1), '')">
<xsl:sort select="position()" data-type="number" order="descending" />
<xsl:value-of select="." />
</xsl:for-each>
</xsl:with-param>
<xsl:with-param name="delimiters" select="$delimiters" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="following-delimiter">
<xsl:call-template name="truncate-find-delimiter">
<xsl:with-param name="value" select="substring($node, $limit + 1)" />
<xsl:with-param name="delimiters" select="$delimiters" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$preceding-delimiter = 0 and $following-delimiter = 0">
<xsl:value-of select="$limit" />
</xsl:when>
<xsl:when test="$following-delimiter &lt;= $tolerance">
<xsl:value-of select="$limit + $following-delimiter" />
</xsl:when>
<xsl:when test="$preceding-delimiter &lt;= $tolerance">
<xsl:value-of select="$limit - $preceding-delimiter" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$limit" />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Build output -->
<xsl:choose>
<xsl:when test="$limit != string-length($node)">
<xsl:apply-templates select="($node/* | $node/text())[1]" mode="truncate-search">
<xsl:with-param name="limit" select="$limit" />
<xsl:with-param name="suffix" select="$suffix" />
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$node/* | $node/text()" mode="truncate-render" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
Search for the node that runs over the limit.
-->
<xsl:template match="* | text()" mode="truncate-search">
<xsl:param name="length" select="0" />
<xsl:param name="limit" select="0" />
<xsl:param name="position" select="1" />
<xsl:param name="suffix" />
<xsl:variable name="next" select="(../* | ../text())[$position + 1]" />
<xsl:choose>
<!-- Limit found -->
<xsl:when test="$length + string-length(.) &gt;= $limit">
<xsl:choose>
<!-- Keep searching children -->
<xsl:when test="*">
<xsl:element name="{name()}">
<xsl:apply-templates select="@*" mode="truncate-render" />
<xsl:apply-templates select="(./* | ./text())[1]" mode="truncate-search">
<xsl:with-param name="length" select="$length" />
<xsl:with-param name="limit" select="$limit" />
<xsl:with-param name="suffix" select="$suffix" />
</xsl:apply-templates>
</xsl:element>
</xsl:when>
<!-- The node to truncate -->
<xsl:otherwise>
<xsl:apply-templates select="(../* | ../text())[position() &lt; $position]" mode="truncate-render" />
<xsl:apply-templates select="." mode="truncate-apply">
<xsl:with-param name="limit" select="$limit - $length" />
<xsl:with-param name="suffix" select="$suffix" />
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Keep searching at this level -->
<xsl:when test="$next">
<xsl:apply-templates select="$next" mode="truncate-search">
<xsl:with-param name="length" select="$length + string-length(.)" />
<xsl:with-param name="limit" select="$limit" />
<xsl:with-param name="position" select="$position + 1" />
<xsl:with-param name="suffix" select="$suffix" />
</xsl:apply-templates>
</xsl:when>
<!-- Nothing to truncate -->
<xsl:otherwise>
<xsl:apply-templates select="../* | ../text()" mode="truncate-render" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
Apply truncation to node
-->
<xsl:template match="*" mode="truncate-apply">
<xsl:param name="limit" />
<xsl:param name="suffix" />
<xsl:element name="{name()}">
<xsl:apply-templates select="@*" mode="truncate-render" />
<xsl:value-of select="substring(., 1, $limit)" disable-output-escaping="yes"/>
<xsl:value-of select="$suffix" />
</xsl:element>
</xsl:template>
<xsl:template match="text()" mode="truncate-apply">
<xsl:param name="limit" />
<xsl:param name="suffix" />
<xsl:value-of select="substring(., 1, $limit)" disable-output-escaping="yes"/>
<xsl:value-of select="$suffix" />
</xsl:template>
<!--
Render all nodes
-->
<xsl:template match="*" mode="truncate-render">
<xsl:element name="{name()}">
<xsl:apply-templates select="@*" mode="truncate-render" />
<xsl:apply-templates select="* | text()" mode="truncate-render" />
</xsl:element>
</xsl:template>
<xsl:template match="@*" mode="truncate-render">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="text()" mode="truncate-render">
<xsl:value-of select="." />
</xsl:template>
<!--
Search for a delimiter
-->
<xsl:template name="truncate-find-delimiter">
<xsl:param name="value" />
<xsl:param name="delimiters" />
<xsl:param name="length" select="0" />
<xsl:choose>
<xsl:when test="$value != ''">
<xsl:choose>
<xsl:when test="$delimiters[starts-with(substring($value, 1, 1), .)]">
<xsl:value-of select="$length" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="truncate-find-delimiter">
<xsl:with-param name="value" select="substring($value, 2)" />
<xsl:with-param name="delimiters" select="$delimiters" />
<xsl:with-param name="length" select="$length + 1" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$length" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="user_review">
<xsl:call-template name="truncate">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="limit" select="'500'"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment