Finding the intervals where a function is positive or negative