Monday, May 25, 2009

Calculus I - Historical Background

One of the original uses for math, back at the dawn of mathematics with the Egyptians and Babylonians, was to determine areas. This originally came up for the problem of determining the areas of land for taxation, but by the Classic Greek period there were plenty of other uses for determining areas or volumes, not to mention the abstract interest of just finding solutions to these problems. The Greeks, in particular, found a great number of practical solutions - not just areas of squares or triangles or circles, but the area under parabolas and other, more complicated shapes. But the Greeks never managed a general solution to the problem of finding areas - that would wait until much later, and an important conceptual advance.

The Greek conception of geometry was much like the basic conception of it today: you have a bunch of things - points, lines circles - which you can do a few basic things to, and with this you can prove things about them. This has the advantage of being close to the real-world view of geometry, a sort of "drawing pictures in the sand" where there's nothing deeper to it than the actual lines you draw. But the downside of this is that it is very, very hard to create more complicated shapes. Proving things by this method pretty much requires that you be dealing with straight lines or circles, so more complicated shapes have to be broken down, for instance by taking them as sections of a cone:



And shapes more complicated still - heart shapes, figure-8s, even spirals - are essentially impossible. This wasn't a huge problem for the Greeks, who accomplished quite a lot with what they had already, but eventually people started trying to come up with new ways to deal with geometry. The most successful by far was the invention, around 1640, of analytical geometry by Rene Descartes (1596-1650). In the years since about 1400, the study of arithmetic had developed into a field concerned with equations in a more abstract sense: algebra. While geometry had more or less stagnated since about the time of Archimedes (287-212 BC), algebra had developed numerous new and useful techniques.  So, if the techniques of algebra could somehow be applied to geometry, great strides forward could be made. The obvious problem is that algebra deals with numbers and equations, and geometry... doesn't.

Descartes' solution was to lay two lines at right angles, run numbers down each of them, producing the Cartesian plane, and then express the points and lines of regular geometry as pairs of numbers:


So a line might include the points (0,0), (1, 1), (2, 2), and (as a continuous line) also a number of other points (1.00001, 1.00001), (3.14159, 3.14159), and so on. This at first glance might seem a step backward: we've replaced the intuitive definition of a line with an infinite collection of pairs of numbers. But all of the pairs are pairs (x, y) where x and y are solutions to the equation x = y, and Descartes realized that if you treat the equation as the line, you can do anything to it you could do to the regular geometric line. You can find intersections by solving equations together - one of the oldest and best understood fields of algebra - and most simple shapes, conveniently, have simple analytic expressions: lines are of the form ax + by = c for some numbers a, b, c; circles are x^2 + y^2 = r^2 for some number r; figure-eights are (x^2 + y^2)^2 = 2(a^2)(x^2 - y^2) for some number a; and so on. Most importantly for our purposes, it reduces the problem of finding areas to an algebra problem - an algebra problem Descartes didn't know how to solve, admittedly, but he had more techniques to throw at it now. Over the next couple of decades, he and a few others began making progress with analytical geometry.

Analytic geometry also has wide applications to the sciences: pretty much any physical activity that can be expressed as two numbers can be graphed on the Cartesian plane. A particularly common use is measuring distance traveled vs time, for instance for a bouncing ball:



This opens up a new avenue of investigation. It turns out that if you measure the slope of the line just touching to the graph at any given point, that provides the rate of change at that point: on a distance-time graph, this is the speed the object graphed is traveling at. So now we can find instantaneous velocities just by using a graph! The problem now is that finding a line just touching the graph - a tangent line - turns out to be a nontrivial problem as well. In classical geometry, finding a tangent is trivially easy for a few shapes (straight lines, circles, a few conic sections) and effectively impossible for anything else. So Descartes and his successors set to work on that problem too.

In the 1670s and 80s, two men - Isaac Newton (1643-1727) and Gottfried Liebniz (1646-1716) - independently came up with a method for solving both problems. Newton began by trying to find a general method for finding tangents; Liebniz, for finding areas. Both of them discovered in the process that the two problems are related in a surprisingly intimate way, and used this to develop an amazingly powerful tool, the infinitesimal calculus (nowadays so prominent it is usually simply referred to as the calculus). The two of them then promptly got into an amazingly bitter and lengthy fight over which one plagiarized the other (it is generally believed now that they developed it independently).

We've reached the calculus itself now, so we might as well get into the mathematical details. For reasons of simplicity, most calculus courses usually start with the differential half of calculus (the section devoted to tangents), so the meat of our tour will begin there.

Friday, May 15, 2009

So does this count as a Meta-Meme?

Metablogging was originally intended to be the personal category ("I broke my leg/am getting wisdom teeth extracted/just don't care today, so no blog for you") but this will be my fourth post (of five total) in metablogging and all but one of them have been about metablogging, not personal stuff. Ah well. The best laid plans of mice and men, and all that.

In the interests of having something personal to justify this category, though, I'll start with a personal anecdote: Jehovah's Witnesses came by this morning shortly before my hiatus. Not terribly notable in and of itself, of course, but it was actually the first time I've seen them go door-to-door, so kinda exciting. But it got me thinking on the subject of memes.

A little background first: in the mid-19th century, the idea of evolution, in a broad sense - that is, that life used to take different forms than it does now, and that it has somehow developed from those forms into the ones it has now - was generally accepted. But the mechanism behind it was not really known. The most widely accepted theories were those proposed by Jean-Baptiste Lamarck at the beginning of the century: first, that creatures developed certain aspects of their physiologies over the course of their lives and passed them on to their offspring (so a proto-giraffe, stretching its neck to reach leaves, would have children with slightly longer necks than the parents were born with); or, alternately, that there was simply some élan vital that made animals develop and complexify (so successive generations of giraffes would simply have longer necks because, well, that is how their élan tells them to develop). The problem was that the first option (inheritance of acquired characteristics) had a lack of evidence - the children of blacksmiths being born not particularly more muscly then their peers, for instance - and the second (generally just called Lamarckian Evolution) was really just a way of passing the buck into philosophical realms where science couldn't meaningfully argue with it.

In 1859 Charles Darwin, an English naturalist, published a book titled On the Origin of Species by Means of Natural Selection, or the Preservation of Favoured Races in the Struggle for Life (now generally just called On the Origin of Species) in which he proposed a third theory. All creatures, he argued, produce far more offspring than could ever survive to adulthood. Some of them will live long enough to produce the new generation; most will die. Which ones survive? Well, those best adapted to the environment; proto-giraffes with longer necks will have access to more food than their shorter compatriots, be healthier and get more mates (who will also tend to be longer-necked) and their kids, although still having a variety of neck lengths, will on average have necks ever so slightly longer than their parents' generation. Darwin's theory ("Natural Selection") was so eminently testable, was presented with so much evidence (Darwin held off publication for the better part of two decades, never feeling that his increasingly mountainous pile of evidence was enough, until the possibility of being scooped by a colleague* finally prompted him to publish) and above all made so much sense, that it almost immediately became the dominant paradigm of biology, a position it has held ever since.

Then, in the 1970s, a man named Richard Dawkins had an interesting thought about natural selection. Who said it only applies to living things? After all, ideas behave much like animals do: they spread, reproduce, mutate, survive at different rates based on their adaptation to the environment. Dawkins formalized this into the idea of memes (by analogy to genes; it's pronounced "meem"). Perhaps the quintessential example of a meme is a chain-letter or -email. A meme is born, or develops out of an old one: somebody creates a joke and forwards it to some friends. It spreads, passing from person to person, mutating along the way; mutations occur as people change or add or misinterpret or do whatever to the meme. Those mutations that help pass it on (to a chain-letter, perhaps polishing the joke at the core or adding a plea to forward it) are propagated more and faster, and thus take up more and more space relative to the original; mutations that harm its propagation (say, accidentally snipping the joke out entirely) occur as well but die off quickly. As time goes on, natural selection pushes the meme in the direction of better and better reproduction, just like it does to living things; and this is good, because there is a limit to how many chain letters you can forward in a day, so the joke has to not only be good but also be better than any other joke you could be telling in order to get passed on.

But of course memes aren't just limited to chain letters, even if they provide the most clear-cut example. Dawkins pointed out that pretty much anything that might be loosely qualified as an "idea" could be considered as a meme. Fashions are memes: they are created, spread, mutate, and eventually are replaced by other fashions, which (in some hard-to-define way) are better adapted to the environment of people's fashion choices. So are, say, phrases: the "best laid plans" quote towards the top of the post is an example of a meme, spreading through writing and conversation; at one point it lost the Scots dialect ending ("gang aft a-gley") and the new version, despite the weakness of making its ending implicit, outcompeted its progenitor. Philosophical concepts are memes too, as are political ones: communism, for example, mutated out of socialism into a more aggressively expansionist version; developed secondary characteristics (Soviet state education, the Comintern) to help keep up propagation; mutated into new varieties, some of which flourished (eg, Marxism-Leninism), some of which failed due to an inability to reproduce fast enough to stay competitive (Anarcho-Communism), and some of which failed due to changing environmental conditions outside their control (Trotskyism); and finally, the whole environment changed rapidly, outpacing the mutability of the family of communist memes to keep up, replacing them en masse with other memes (largely various species of libertarian capitalism and light authoritarianism). Finally, to take this post back to the opening anecdote, religions can be treated as memes too**; Jehovah's Witnesses (Jehovah's Witnessing? Jehovah's Witnessism?), for example, is a competitive religious meme not least because of its explicit commands to evangelism.

Finally, the internet turns out to be a great breeding ground for memes. People on the internet tend to have plenty of free time, plenty of desire to converse, and with practically real-time connectivity can spread memes around very quickly. The intro to the video game Zero Wing, for instance, was so badly translated that people began referencing it all over the internet, the phrase "All your base are belong to us" in particular becoming a fast spreading meme. After a while, the phrase became seen as boring or old, and mainly died off. There are dozens - probably hundreds - of other memes floating around the internet: rickrolling (innocuous-seeming or downright misleadingly-labelled links to the music video of "Never Going To Give You Up" by Rick Astley), lolcats (weirdly labelled pictures of cats), de-motivational posters (long since mutated to include pretty much anything in the "picture, black frame, label" model), and many, many more.

...And of course, the idea of internet memes (like the concept of memes itself) is a meme in its own right: spreading from person to person, via things like this blog post, and continuing to occupy a niche in the mental environment as long as people continue to pass it on. Memetics never really turned into a science in the sense Dawkins probably imagined back in 1976, but it remains a pretty neat concept to think about and throw around occasionally.

*Alfred Russell Wallace.
**Dawkins has since become an outspoken and frankly irritatingly evangelistic atheist; his reductionistic view of religions as memes only is probably related to this.

Friday, May 8, 2009

Going off the grid

The blog will be not updating for the next week; I'm going out into the Ontario backwoods to hew some wood and draw some water.

Wednesday, May 6, 2009

Fun IT Blog, with footnotes

II've just discovered The Daily WTF. Currently reading through the back archives (because, well, that's what you do on the internet; why miss the back-issues just because you arrived late?*). My favorite so far is the VB-turned-C programmer who realized that with macros, you can pretend to be programing in anything.

*There's an interesting case to be made that this - not even free access or flash animations or anything else - is the big difference between traditional comics and webcomics. Scott McCloud, in Reinventing Comics (sequel to the excellent Understanding Comics) argues that internet-based comics will have a host of advantages over conventual paper-based ones: they have none of the space limitations of conventional paper, they can include visual effects not possible in print, they can take advantage of the internet's abilities to create branching plots, and so forth. But in the nine years since publication, essentially none of that came off. Most webcomics creators - even the professional ones - don't have the time to create more than one plot, or fill out more than one conventional strip worth of artwork, or add anything more programmatically intricate than a .gif file. 

What was different - and the fact that this was missed is kind of surprising, since it's a property of the medium of webcomics itself, not any one comic in particular - was that internet archiving means that any individual comic is available to anyone at any time. Print comics can't do this: if you pick up your newspaper one morning and haven't read the funnies a three weeks, you still want to be able to laugh at Garfield's antics; so everything - plot, setting, characterization, even the jokes themselves - has to be as broadly set out and as static as possible. Even relatively story-based comics (such as Doonesbury) tend to simply throw the cast in various situations and let the jokes fend for themselves**.

The webcomics paradigm is different. Readers can come and go as they choose, but - thanks to the miracles of archiving - they never have to miss a strip. Indeed, most webcomics creators take advantage of this to get rid of all the "Gilligan's Island" plotting and endless recapping that plagues print comics. Instead, webcomics can be highly decompressed, and have long-running story arcs and much larger, better-developed casts, albeit at the cost of making reading all the back archives necessary, even for established readers, and making the front-end comics absolutely incomprehensible to new readers. Fortunately, these new readers can simply trawl through the backstory, although with some of the longer-running comics starting to approach 10 years of 7-comics-a-week updating, this can become a daunting task. Not all webcomics do this (the excellent xkcd comes to mind as a well-made gag-a-day strip) but many do, and, even without showy visuals or funky web effects, it opens up vast new storytelling areas long denied to comics. Probably the best example of this is Narbonic, which is a couple of years long and changes a great deal in the process: you can see the creator realizing she doesn't need to make every strip funny on its own, right in front of your eyes, and it improves greatly for it.

So check out Narbonic and see what I'm talking about. It's a good read.

**Although, if you really really want the backissues of Doonesbury, they're here. Just increment the url.

Monday, May 4, 2009

English - older than you think

So, when we left off, we'd just discovered that despite the use of Lorem Ipsum elsewhere, the full-size style preview on Blogger is actually filled with, well, regular English.


Specifically, the first couple of lines of Book II of John Milton's Paradise Lost (Satan vowing to wage eternal war on Heaven) and the start of Belial's speech on the same subject from a bit later in. (For no reason I can tell, Belial's speech is the second sample post, followed by the rest of Satan's speech. My best guess is they initially wanted to have a series of posts with one of each of the demons'  speeches from Book II per post, got two posts in, and then decided to just copy the text in sequence out of the start of the book.) This works in the narrow sense that the text is fairly arbitrary and so not particularly distracting, but in the more general sense of adding in spacefiller gibberish it is an utter failure: the text is recognizable and readable English.
High on a Throne of Royal State, which far
Outshon the wealth of ORMUS and of IND,
Or where the gorgeous East with richest hand
Showrs on her Kings BARBARIC Pearl and Gold,
Satan exalted sat, by merit rais'd
To that bad eminence; and from despair
Thus high uplifted beyond hope, aspires
Beyond thus high, insatiate to pursue
Vain Warr with Heav'n, and by success untaught
His proud imaginations thus diplaid.
It's not quite modern English but it's comprehensible. ("Satan sits on his shiny throne, and, despite the fact that he can't win, is planning to go on fighting Heaven.") Paradise Lost was published (in its final form) in 1674, which means it falls into a century-long slot of not-quite-modern English most popularly exemplified by Shakespeare and the King James Bible. Despite complaints about it, Shakespeare is eminently readable. It is, after all, written at the same time as the KJV (there are even some - unsubstantiated - theories that Shakespeare contributed to the 1611 KJV) and most people nowadays can still fake a passable King James. Taking (for example) the opening lines of the Book of Esther:
Now it came to pass in the days of Ahasuerus, (this is Ahasuerus which reigned, from India even unto Ethiopia, over an hundred and seven and twenty provinces:)
That in those days, which the king Ahasuerus sat on the throne of his kingdom, which was in Shushan the palace,
In the third year of his reign, he made a feast unto all his princes and his servants; the power of Persia and Media, the nobles and princes of the provinces, being before him:
When he shewed the riches of his glorious kingdom and the honour of his excellent majesty many days, even an hundred and fourscore days.
Comparing this to the New International Version of 1978, we have
This is what happened in the time of Xerxes, the Xerxes who ruled over 127 provinces stretching from India to Cush:
At that time King Xerxes reigned from his royal throne in the citadel of Susa,
And in the third year of his reign he gave a banquet for all his nobles and officials. The military leaders of Persia and Media, the princes, and the nobles of the provinces were present.
For a full 180 days he displayed the vast wealth of his kingdom and the splendor and glory of his majesty.

There's not a terribly great difference. Apart from the occasional out-of-order phrasings and the even more occasional archaic vocabulary (the only real example above being the use of "power" for "generals") it's just about as readable. Shakespeare is a little more flowery than the KJV in general, since he's not restricted to translating a preexisting text, but even then reading it (or better still, listening to it) you can understand what is being said.

Going back eighty years or so to the Coverdale bible of 1535 (Tyndale is the more popular version, but he was executed before getting around to the book of Esther) we find that the spelling takes a sudden hard hit but it still remains understandable, especially read aloud:
In the tyme of Ahasuerus, which reigned from India unto Ethiopia, over an hundreth and seven and twentye londes,
What tyme as he sat on his seate roiall in the castell of Susa
In the thirde yeare of his reigne, he made a feast unto all his prynces and servauntes, namely unto the mighty men of Persia and Media, to the Debites and rulers of his countrees,
That he mighte shewe the noble riches of his kingdome, and the glorious worshippe of his greatnesse, many dayes longe, even an hundreth and foure score dayes.
The phrasing is a little strange but spellcheck it and drop the occasional very weird word ("debites"?) and it's pretty much the same as the KJV. But Coverdale wasn't even the first English translation of the Bible: that credit goes to Wycliffe, around 1380.
In the daies of kyng Assuerus, that regnede fro Ynde til to Ethiope, on an hundrid and sevene and twenti provynces, whanne he sat in the seete of his rewme,
The citee Susa was the bigynnyng of his rewme.
Therefor in the thridde yeer of his empire he he made a greete feeste to alle hise princes and children, the strongeste men of Persis, and to the noble men of Medeis, and to the prefectis of provynces, bifor him silf,
To schewe the richessis of the glorie of his rewme, and the gretnesse, and boost of his power in myche tyme, that is, an hundrid and foure scoor daies.
The spelling is terrible, and the language falls into what is generally called Middle English, but if you read it out loud it is still legible. ("In the days of king Assuerus, that reigned fro' Ind 'til to Ethiop, on an 'undred and seven and twenty provinces, when he sat in the seat of his rewme [realm]...") It's not until you hit Old English, pre-Norman invasion, and more than a thousand years ago, that the language becomes sufficiently different to be incomprehensible (not Esther but the Lord's Prayer, c. 1000, due to lack of a complete Old English Bible):
Fæder ure þu þe eart on heofonum, Si þin nama gehalgod. to becume þin rice, gewurþe ðin willa, on eorðan swa swa on heofonum. urne gedæghwamlican hlaf syle us todæg, and forgyf us ure gyltas, swa swa we forgyfað urum gyltendum. and ne gelæd þu us on costnunge, ac alys us of yfele. soþlice.
Note that the language, for the first time, is completely incomprehensible even read aloud: "Fader ure thu the eart on hyofonum, si thin nama gehalgod..." (The þ and ð are called thorn and eth respectively, and both pronounced more-or-less "th".)

Jumping back to the 17th century, Paradise Lost - being in verse - is in fact even less legible than most writing of the time. The Pilgrim's Progress, written only four years later (1678), is in practically everything but style completely modern:
As I walk'd through the wilderness of this world, I lighted on a certain place, where was a Denn; And I laid me down in that place to sleep: And as I slept I dreamed a Dream. I dreamed, and behold I saw a Man cloathed with Raggs, standing in a certain place, with his face from his own House, a Book in his hand, and a great burden upon his Back. I looked and saw him open the Book, and Read therein; and as he read, he wept and trembled: and not being able longer to contain, he brake out with a lamentable cry; saying, what shall I do?
And fifty years after that Gulliver's Travels (1726) is, in effect, a rather formally-written piece of modern English:
My father had a small estate in Nottinghamshire: I was the third of five sons. He sent me to Emanuel College in Cambridge at fourteen years old, where I resided three years, and applied myself close to my studies; but the charge of maintaining me, although I had a very scanty allowance, being too great for a narrow fortune, I was bound apprentice to Mr. James Bates, an eminent surgeon in London, with whom I continued four years.
So what do we know about English? Well, definitely modern English goes back a long time - at least three hundred years, with another hundred of iffy-but-comprehensible modern English before that. Then there's another three or four hundred years of very strangely spelled but still recognizable English before that. You need to get back before Piers Plowman in the mid-14th century - that's six and a half centuries and it's still on the good side of legibility. You have to go back the better part of a millennia, to a time when English hadn't even really come together out of Norman French and Anglo-Saxon, when even the alphabet wasn't the same (thorn and eth were both dropped around 1300) before you genuinely run out of English. And despite the rapid changes in spelling and style (especially in the 16th and 17th centuries respectively) English has been surprisingly stable for a long period of time. If you want Lorem Ipsum text that's illegible to a modern English-speaker, you need to go a lot further back than John Milton.

And, incidentally: try Paradise Lost. It's interesting both historically, culturally, and in and of itself, entertaining, and if you weren't convinced by my claims of legibility ("High on a throne of royal state which far. Outshon the wealth of ormus and of ind... what is this stuff?") Isaac Asimov's Annotated Paradise Lost provides helpful vocabulary and metaphor references, as well as the rather interesting story behind its writing (short version: 2008 was not the first time a government changeover caused the religious right to flame out, although Milton was a far, far better writer than Rush Limbaugh is). 


A friend of mine from university called it "biblical fanfic", which is just about right, but it's very very good fanfic. Give Paradise Lost a try.

Friday, May 1, 2009

Saturday Night Live no longer exists

I was going to continue my Lorem Ipsum post but this struck me just recently.

Saturday Night Live no longer exists (on the Canadian internet).

See, back in the heady days of 2008, I got into Saturday Night Live, largely because of the American election that year, and even more so because of the internet. 2300 to 0100 on Saturday night (technically, it's mostly on Sunday morning) is not really a time I watch TV. At home I usually don't stay up that late, and at university I don't have a TV. Also, the few times Ihad seen it it was... well, live comedy, good when they hit it but with a high proportion of just painful sketches that went on too long. I preferred Whose Line Is It Anyways, which tended towards the consistently brilliant and even better was on at a reasonable time. But in the fall of 2008 I kept getting link after link to SNL, especially Tina Fey's dead-on impression of Sarah Palin. So I watched it online at the NBC site, found it pretty funny, and kept watching on and off for a couple of months.

Cut to yesterday. I decide for various reasons that I want to see the SNL vice-presidential debate ("I would throw myself on a live grenade for John McCain! But for the sake of every man, woman, and child on Earth, we must never allow him to become President!") So I look up "SNL Vice President Debate" on youtube and get... nothing. A couple of brief clips and some longer clips that look like they used to contain the whole skit but currently consist of a single still and a textbox directing you to the NBC site. Apparently NBC has run amuck on youtube taking down all the SNL clips and replacing them with redirects to their website. All right, so I go to the NBC page...


Well, that's annoying. And pretty much every hit for the video, and every other SNL video, is either down or a direct link-through to NBC or the similarly geographically restricted hulu. So essentially, SNL no longer exists on the internet for Canadians.

The particularly hilarious bit - apart from the fact that a little judicious proxying can get you around it anyways - is that it seems so, well, pointless. NBC broadcasts in Canada. SNL goes on the air in Ottawa at the same time that it does in New York, on the same channel (it also goes on the air on Canada-based Global, although the video section of the Global website is pretty sad). The whole point of web-based videos is to expand your audience - you can sell ads on the net just as well as TV spots, and because you're no longer limited to watching the show once at 2330 on a Saturday night six months ago, you'll get more viewers in total. So why stick geographical restrictions on it? Hulu I can see, maybe, because they're working with other people's content and are probably trying hard to stay on the very conservative side of copyright laws. But NBC owns SNL. They can publish it anywhere they like. So why don't they?