Wednesday, November 10, 2010

Math of the Moment

Every now and then I get the need to do some math... and it reminds me of all the math I used to know and have forgotten. So I try to figure out math problems without cheating and looking at Wikipedia.

Most recently, I was working with some “Mercator” map coordinates. Basically they express a position on the earth in terms of its location on a Mercator projection of the earth. I dug out a formula from our code at work, and it seemed to work, but I wasn't satisfied that the function for the Y coordinate in terms of Longitude was odd (that f(x) = -f(-x)). So I proved that, which was fun. It got me a taste for more calculus.

So then I decided I had to derive the Mercator projection. The Mercator projection is basically defined such that, if the Earth were spherical, at any point on the map the horizontal scale (relating distance along a constant-latitude circle to horizontal distance on the map) is equal to the vertical scale (relating distance along a constant-longitude circle to vertical distance on the map). That wouldn't be too hard, I guess, except that I needed to integrate a secant, and I didn't remember how to integrate a secant, or how to integrate nested functions (because then I could define secant in terms of cosine, which is easy to integrate).

So I had to figure out how to integrate nested functions... which I remembered was related to the product rule for derivatives... which I also didn't remember. I think I've managed to derive that from the definition of a derivative. And that's where I am right now. I hope I'm not down a blind alley, but deriving the product rule was fun either way.

Speaking of which, I wish software folk could use short variable names like mathematicians and physicists. ε. δ. What's so hard about that? Set out the meaning of variables in comments and write code that's readable as code instead of vainly trying to make it read like language? If a modern software engineer invented calculus it would have been independentVariableDifferentialNumeric and dependentVariableDifferentialNumeric. *puke*.

No comments: