sum of functions optimizer.