You should replace both two denominators with the following code. SQR(POW(X2-X,2)+POW(Y2-Y,2))