Tuesday, November 20, 2007

Coding Nightmares

My coding nightmare tonight has been discovering an error in the way a piece of code executes I can't duplicate outside it's native environment, but I can repeat natively.

Here I am, working on an R script to do some (rather elementary) computational geometry and I want it to compute $(a-c)^2 + (b-d)^2$ (to use the TeX notation) where $a,b,c,d \in \[-2,2\]$. A little examination shows that the sum should always be less than or equal to 16. I was getting 16.8. Not good.

The problem is that while I can duplicate this kind of MAJOR error when computing this number as part of the script, I can't get it by starting R up cleanly and manually imputing one example. Then it works fine. I have to wonder what in the world is going on.

The worst part is most likely the solution is simple and would be obvious to a professional programmer but to me, an amateur, is far from it.

Grrrr . . .

No comments: