Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortest distance from a point to this curve

I need to find the distance of multiple points to a curve of the form: f(x) = a^(k^(bx))

My first option was using its derivative, using a line of the form with the inverse of the derivative, giving it coordinates of the Point and intersecting it with the original curve. Finally, we calculate the distance between points with simple geometry.

That's the mathematical process that I usually follow. I need to save time (since I'm doing a genetic algorithms program) so I need an efficient way to do this. Ideas?

like image 591
OFRBG Avatar asked Jan 25 '13 22:01

OFRBG


People also ask

How do you find the shortest distance from a point to a curve?

Every point on the curve has coordinates (x,(x−3)3) and the distance between such a point and the point (−3,3) is: √(x+3)2+((x−3)3−3)2 . We can minimize the distance by minimizing the radicand: f(x)=(x+3)2+((x−3)3−3)2 .

What is the shortest distance from a point to a line?

As defined above, the distance more specifically, the shortest distance of a point from a line is the length of the perpendicular drawn from the point to the line.


1 Answers

The distance between a point (c,d) and your curve is the minimum of the function

sqrt((c-x)^2 + (d-a^(k^(bx)))^2)

To find its minimum, we can forget about the sqrt and look at the first derivative. Find out where it's 0 (it has to be the minimal distance, as there's no maximum distance). That gives you the x coordinate of the nearest point on the curve. To get the distance you need to calculate the y coordinate, and then calculate the distance to the point (you can just calculate the distance function at that x, it's the same thing).

Repeat for each of your points.

The first derivative of the distance function, is, unfortunately, a kind of bitch. Using Wolfram's derivator, the result is hopefully (if I haven't made any copying errors):

dist(x)/dx = 2(b * lna * lnk * k^(bx) * a^(k^(bx)) * (a^(k^(bx)) - d) - c + x)
like image 133
zmbq Avatar answered Oct 21 '22 23:10

zmbq