Finding the average value of a function on an interval