optimize multivariable function