# sign function def sgn(x): if x>=0: return 1 return -1