new function Optimize() for univariate optimization