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.
using System;
using Imsl.Math;

public class MinUnconMultiVarEx1 : MinUnconMultiVar.IFunction
{
    public double F(double[] x)
    {
        return 100.0 * ((x[1] - x[0] * x[0]) * (x[1] - x[0] * x[0])) +
            (1.0 - x[0]) * (1.0 - x[0]);
    }


    public static void  Main(String[] args)
    {
        MinUnconMultiVar solver = new MinUnconMultiVar(2);
        solver.SetGuess(new double[]{- 1.2, 1.0});
        double[] x = solver.ComputeMin(new MinUnconMultiVarEx1());
        Console.Out.WriteLine
            ("Minimum point is (" + x[0] + ", " + x[1] + ")");
    }
}

Output

Minimum point is (0.99999996726513, 0.99999993304521)

Link to C# source.