dgh2 = (xjg - xjh)2