Finding the rate of change in a function