1-D optimization for several variables