Quoting Paul Reiners <paul.reiners@gmail.com>:
This is a programming question I ran across. Does anyone happen to know the answer? ..... After profiling, I've found that the sqrt call in the distance calculation is taking a significant amount of my time. Is there an iterative way to calculate the distance?
This problem was alreay vexing programmers at the ENIAC. Depending on the context, particularly if it was a matter of comparing distances and they were greater than 1, comparing squares sufficed and completely sidestepped the square roots. Pure square roots (don't use logarithms) in floating point are actually fairly economical; half the exponent and three cycles of Newton's approximation leave them only slightly worse than a few multiplications. -hvm ------------------------------------------------- www.correo.unam.mx UNAMonos Comunicándonos