Minimizing a non-linear function