An algorithm for finding the absolute extremum of a function