public void ComputeTest2()
{
// Create a simple function with two parameters: f(x,y) = x² + y
Func<double[], double> function = x => Math.Pow(x[0], 2) + x[1];
// The gradient w.r.t to x should be 2x,
// the gradient w.r.t to y should be 1
// Create a new finite differences calculator
var calculator = new FiniteDifferences(2, function);
// Evaluate the gradient function at the point (2, -1)
double[] result = calculator.Compute(2, -1); // answer is (4, 1)
Assert.AreEqual(4, result[0], 1e-10);
Assert.AreEqual(1, result[1], 1e-10);
Assert.IsFalse(Double.IsNaN(result[0]));
Assert.IsFalse(Double.IsNaN(result[1]));
}