Shortest distance from a point to this curve

孤者浪人 提交于 2019-12-01 05:12:18

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)

To find distance from point to curve it's not a simple task, for that you need to find the global of function

where f(x) is the function which determine your curve.

For that goal you could use:
Simplex method
Nelder_Mead_method
gradient_descent

This methods implemented in many libraries like Solver Foundation, NMath etc.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!