It is described as -||xi-xy||^2
.
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?
It is described as -||xi-xy||^2
.
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?
The correct answer is
-( (x1-x2)^2 + (y1-y2)^2 )
The mathematical description is accurate, but not useful for implementation. It's stated as the square of the distance between the points, which if implemented directly would be something like:
len = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
result = -( len*len );
which can simplified to
result = -( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
which is your #2.
The third is the negative of the distance. The second appears to be the negative of the square of the distance.