Example 1: Minimum of a multivariate function

The minimum of 100(x_2 - x_1^2)^2 + (1-x_1)^2 is found using function evaluations only.
import com.imsl.math.*;

public class MinUnconMultiVarEx1 {
    public static void main(String args[]) throws Exception {
        MinUnconMultiVar solver = new MinUnconMultiVar(2);
        solver.setGuess(new double[]{-1.2, 1.0});
        double x[] = solver.computeMin(new MinUnconMultiVar.Function() {
            public double f(double[] x) {
                return 100.*((x[1] - x[0] * x[0]) * (x[1] - x[0] * x[0])) +
                (1. - x[0]) * (1. - x[0]);
            }
        });
        System.out.println("Minimum point is (" +x[0] +", "+x[1]+")");
    }
}

Output

Minimum point is (0.9999999672651304, 0.9999999330452095)
Link to Java source.