Assuming L(x) is differentiable, we differentiate L(x) to get gradient function L'(x) and inspect this function L'(x) over the interval x = 0 to x = (2.00pm - 6.00am) hrs, ie x = 0 to x = 8 hrs.
We want to find the maxima of the function L(x) over this period. To find turning points (maxima and minima) we set L'(x) = 0 and solve for x. These values of x are where the turning points of L(x) are, ie where the points with zero gradient are - the peaks and the troughs.
Once we have the turning points we need to check each one to see whether it is a maximum or a minimum. Minima will have increasing gradient at the relevant value of x (the gradient goes from negative to positive, going through zero at the turning point) and maxima will have a decreasing gradient (the gradient goes from positive to negative, going through zero at the turning point). To find whether the gradient is decreasing, we examine the function of the rate of change of the gradient, L''(x). This is obtained by differentiating L(x) twice, or in other words by differentating the gradient function L'(x).
Disgarding turning points that are minima, we focus on maxima, if we have any. If we have any maxima, we choose the one that achieves the largest value of L(x), or the global maximum of the function over the range x = 0 to 8 hrs if that is larger. If we don't have any maxima, the peak listening time is simply the global maximum of the function. The global maximum is either the highest peak, or the value of L(x) at either end of the range, ie when x =0 or x = 8. If there are multiple points on L(x) that achieve the maximum listnership over the period, then the maximum listnership occurs at all of those times.