Using an array of stock prices how do I find all of the inflection points (indices of the array corresponding to the points where the slope reverses, ie local minimum and maximu