November 18, 2008

Filed under: science»math

A Golden Eternal Bore

Man, I really want to be the kind of person who enjoyed reading Douglas Hofstadter's Godel, Escher, Bach. It's been recommended by some really smart people, and Hofstadter himself seems like a very smart, agreeable person. The thing won a Pulitzer, for pity's sake. I should be eating it up. I feel bad about hating it. But I can't help it.

GEB claims, in an introduction that is both wry and impossibly self-congratulatory, to be a "fugue" tying together music, art, and math in an examination of how the mind works, and how AI could be designed. Hofstadter writes that he felt the need to add an introduction explaining the book's purpose because so many people had gotten it wrong. Someone with less investment in the topic should have maybe taken that as a hint. He also says that the book originally started as a pamphlet and simply grew and grew over the years--well, so does cancer. Thing is, these two problems are related: if people have trouble understanding that your 800+ page book isn't really about math and Bach, maybe you should consider editing out the two-thirds of it that are a crash-course in number theory.

Yeah, I'm a little bitter about it. Like I said, I feel bad--like I'm not living up to my potential by raving about the book. But fundamentally, this is a work for people who find themselves fascinated by the question "is math true?" And like many pragmatists, I think that question's basically a waste of time: better to ask "does math work? Yes? Okay then." Throwing a bunch of Zen into the mix does not help me take it seriously.

And the dialogs--sweet mother of mercy, the dialogs. For those who've never picked up a copy, Hofstadter precedes each explanatory chapter with a short, "witty" conversation, usually between Achilles and the Tortoise (it's an extended riff on a piece by Lewis Carroll). These are exactly as dreadful as they sound: careening wildly between pedantic and a math geek's idea of whimsical, their only saving grace is that they still look modest compared to Ray Kurzweil's ego-boosting appropriation of secretly-transhumanist historical figures (that said, what doesn't?).

But now I'm just being mean. I don't like GEB, but I think it needs to be put in context. Mentally, it gets shelved next to the Illuminatus trilogy or Zen and the Art of Motorcycle Maintenance--books written by well-meaning hippies trying to locate Big Ideas for the general public through their own personal eccentricities. I even understand the urge--isn't that what many bloggers sometimes find themselves trying to be? I know I do. But on a blog, I think it's possible to forgive the occassional lapse into feigned profundity (sorry, readers!). It's a bit harder to swallow when it's a $20 tome that's as thick as the Arlington phone book.

August 15, 2008

Filed under: science»math

Programmer Math

There's a line in Neal Stephenson's Cryptonomicon where one of the main characters, a mathematician and programmer, is asked if he is good with numbers. "I'm good with math," he replies. "Mathematicians stay away from actual, specific numbers as much as possible. We like to talk about numbers without actually exposing ourselves to them."

To most people, math and numbers are the same thing, which is unfortunate. Certain personality types respond well to numbers--one of my ex-girlfriends, a CPA, derived a kind of warm satisfaction from seeing columns upon columns of financial figures--but for the rest of us they are at best an eye-crossing source of confusion, and at worst a harbinger of bad news: taxes, checkbook balances, bills, etc.

Perhaps I'm an outlier (Cue cries of "freak!"), but I'm finding that while I personally don't care for numbers, I really enjoy math. I've learned (or re-learned) more math in the last two months of coding than I picked up through all of college (granted, I majored in the softer bits of Communication, and had taken all of the math courses available at my high school). This late education has actually been a lot of fun.

Here are a few math functions that I've either picked up, picked up again, or had to explain to coworkers who have forgotten even more of their algebra classes than I had:

  • Modulo: You already know what modulo is, although you may not know that you know. Everybody learns it in elementary school. The modulo is better known as the remainder, or the amount left over after performing division. Apparently, it gets its new name from modular arithmetic, a system developed by Carl Gauss in the early 1800s, where numbers loop back around to zero when they pass a certain value. Which, if you think about it, is basically what the remainder does: it resets to zero each time division results in a whole number. Since programmers tend to care more about referencing 19th century research papers than being accessible, we're stuck calling it "modulo" instead of "remainder." I remember hating remainders in elementary school, because a remainder meant you weren't done with the problem--we had to keep dividing them into smaller and smaller decimal places. But remainders are actually really useful in their own right, because they let you cycle through a set of numbers using only addition and subtraction.
  • Absolute values: I was really surprised when one of our graphic artists didn't remember absolute value--the distance of any given number from zero. Obviously, for positive numbers, the value and the absolute value are the same. But for negative numbers, the absolute value removes the sign. This is surprisingly handy. I've been using it to test whether or not a given arithmetic operation changes the sign between the input and output, for a hobby project.
  • Sigma notation: Man, this is a scary one. I avoided learning about sigma notation for years, but it's actually not that frightening in reality. Sigma notation is just a shorthand for adding an arbitrary number of equations over a range of values. The value below the "broken E" is where your variable starts. The value above is when you stop. And the equation to the right is what you do over and over again, adding each result to all the previous results, until you hit the stop condition. I'm mostly excited about it because I can finally express my multiple-monitor-productivity equation: I figure that I'm 1/n times more productive for each additional monitor. So my second monitor makes me 50% more productive (1/1 + 1/2), while a third takes me up to 183% of normal productivity (1/1 + 1/2 + 1/3). Finally, I can adequately express this for n number of monitors! ("Freak!")
  • Sine and cosine: These are, I think, always explained very badly in geometry classes, at least for the applications in which I've used them 99% of the time. Sine and cosine are just the y and x values of a point on a circle for x number of radians. Getting into the proof and the explanation of how they work requires a lot of triangles, but you don't actually need to know that part to use them. So basically, yeah: y and x values on a circle. Can't draw a circle--or in my case, animate pictures going around in a circle--without these guys.
I know, this all sounds really dorky. But what I'm enjoying about all this math is that it's almost like a puzzle to solve: I've got x input, and need to end up with y output. How do I get one to become the other? All the different mathematical principles and operations are like boxes that I can hook together, like the modulation matrix of a synthesizer, until they spit out what I want. By focusing more on the operation and less on the numbers, I'm having a lot more fun than I thought I would.

Future - Present - Past