Case #4 is the cool/hard one.
You see, you pick m to be rather large (smaller however than the minimum distance between peaks can ever be though as to avoid losing accuracy). Then when you test and get a case like 4, where the difference is there, but the slope of the line from (n - m) to n does not equal the negative of n to (n + m). So if the slope from (n-m) to n is X then the apex is where the slope of n to (n+m) is -X.
So when you get to case #4, you halve your "m" value, and try again but
only over the region from n-m to n+m. This way it saves CPU cycles. For easiest programming this factoring down could be ommitted by just making m a really small value to begin with. However this will destroy your CPU cycles.