check that the square is positive before taking the sqrt