math - What is negative squared euclidean distance? -


to -> xi-xy || ^ 2 has been described as.

So for 2 two-dimensional points, do I code it like this?

  - ((x1-x2) + (y1-y2)) ^ 2  

or

  - ( (X1-x2) ^ 2 + (y1-y2) ^ 2)  

or

  - (sqrt ((x1-x2) ^ 2 + (Y1-y2) ^ 2))  

Or some other way?

correct answer

  - ((x1-x2) ^ 2 + (Y1-y2) ^ 2)  

Mathematical descriptions are correct, but not useful for implementation. It is said in the form of the square of the distance between the points, which will be something if it is applied directly:

  len = sqrt (x1-x2) * (x1- X2) + (y1-y2) * (y1-y2)); Result = - (lane * lane);  

Which

  results = - ((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2)) ;  

That's your # 2.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -