The smallest distance from a point to this curve

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

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

This is a mathematical process that I usually follow. I need to save time (since I am running a genetic algorithm program), so I need an effective way to do this. Ideas?

+6
source share
2 answers

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

 sqrt((cx)^2 + (da^(k^(bx)))^2) 

To find its minimum, we can forget about sqrt and look at the first derivative. Find out where it is 0 (this should be the minimum distance, since there is no maximum distance). This gives the x coordinate of the nearest point on the curve. To get the distance needed to calculate the y coordinate and then calculate the distance to the point (you can just calculate the distance function at this x , this is the same thing).

Repeat for each of your points.

The first derivative of the distance function, unfortunately, is a kind of bitch. Using Wolfram derivative , the result is, hopefully (if I have not made any copy errors):

 dist(x)/dx = 2(b * lna * lnk * k^(bx) * a^(k^(bx)) * (a^(k^(bx)) - d) - c + x) 
+4
source

To find the distance from a point to a curve is not an easy task, for which you need to find a global function enter image description here where f (x) is the function defining your curve.

For this purpose you can use:
Simplex method
Nelder_Mead_method
gradient_descent

These methods are implemented in many libraries, such as Solver Foundation , NMath , etc.

0
source

All Articles