A variation on the first derivative test for identifying local extrema, identify points where the delta alternates sign from one interval to the next. These points will be maxima if the delta goes from positive to negative and minima if the delta goes from negative to positive, but for your use that doesn't seem to matter. Also, throw in the end points because the interval is considered open for this test and you seem to want them included.
Note: I tested a little on ideone.com, it works, but it may have undetected issues. This should work for floats just as well.
Credit: This is the first derivative test from every Calculus I textbook, adapted only slightly for discrete maths. We are treating every point as a critical point because we don't know the function for the graph.
Edit: After looking at a plot of the data on wolframalpha I am thinking that maybe you are just looking for the global max and min on the closed interval, plus the end points? If so, just use something simple, like max($points)
and min($points)
.
Edit: I have never had a good opportunity to use xor before!