Algorithm for distance from point to function

Quote:

> The minimum distance is the length of the shortest line from the point

> x1y1 to a tangent to the line y=f(x). The equation of the tangent is a

> line whose slope is the first derivative at x2y2. The point x2,y2

> satisfying the function and at the shortest distance is the

> intersection of a line through x1y1 which is perpendicular to the

> tangent at x2,y2 and therefore has a slope of the inverse of the tanget

> (or the reciprocal of the first derivative at that point).

> Then the distance is just the normal Gausian square rooot of the sum of

> the squares of the differences between each coordinate of the pair

> x1,y1; x2,y2

> Searching by closer approximations is the best technique.

Thanks to all who posted hints. We had indeed been planning

to use an optimization in finding the shortest distance. The

function to which we are finding distance is monotonic, and I

think that will simplify things a bit. It may even be

possible that we can use the derivative of the distance --

we'll have to examine that closely.

I was hoping that there might be a magic bullet we had

overlooked, but (not surprisingly) it appears not.

Because the distances are needed for an outer optimization

(fitting by least squared distances), this is becoming

computationally intense. Luckily, the data sets are small.

...Mike

Mike Prager

North Carolina, USA