Determining intervals on which a function is increasing or decreasing