genetic algorithm to optimize single variable functions