Thursday, January 27, 2005

A Day in the Life of a Numerical Analyst

I imagine that to most people, my work seems terribly dull. To me, the overall picture is very interesting, but the day-to-day stuff is definitely dull.

For example, I devised this exciting new method of optimization. Does it work? That's the big question.

Before you can answer the big question, however, a barrage of little questions must be answered.

You see, before you can answer that question, you have to write a computer program that will perform the optimization method. You have to develop the fine details that you might have glossed over when you first came up with the idea. And no matter how smart you are, no matter how carefully you plan, the program will always have some sort of bug in it that you have to find. The easy ones to find are the places where you forgot to put in a semicolon at the end of the line, or forgot to initialize a variable, or the like. The hard ones to find are where you actually made a mistake in your logic, or forgot how computers do integer arithmetic (HINT: 5/2 = 2, but 5./2 = 2.5), or accidentally didn't allocate enough memory and your program writes over memory it shouldn't have access to.

These things can take weeks, or sometimes months, to track down, especially if you use a parallel machine like I do. Then it is staggeringly difficult to find what went wrong.

Oh yes, there are debuggers out there, commercial programs that help you find your errors, but I have found that careful insertion of print statements works just as well, if not better, than any debugger. And as for finding errors in parallel programs, I have devised a method of having each processor write out a file containing detailed debugging information.

Right now I am working on a generalization of the magnetotelluric geoprospecting problem from two to three dimensions. There is a bug somewhere in there, but I haven't been able to catch it yet. (Actually, it seems likely that there are multiple bugs, because in my experience it is rare that only one thing is wrong with a program of that size.) I have been working on this on and off since December, and I am still unsure of how it will work. I am past the stage of having easy errors like the semicolon, and now I'm looking for an error in my logic or memory allocations.

As for that optimization method, I started writing the program in the spring, and worked on it for at least four months until what I believed to be the final bug was found. I can say that it certainly appears to work correctly. But again, you never really know if the program does what you want it to do; you can only say with a high degree of probability that it seems to work.

No comments: