Changed two norm to use math.Hypot for better numerical stability