Example 1: Solve a System of Nonlinear Equations

A system of nonlinear equations is solved.
using System;
using Imsl.Math;

public class ZeroSystemEx1 : ZeroSystem.IFunction
{
    public void  F(double[] x, double[] f)
    {
        f[0] = x[0] + System.Math.Exp(x[0] - 1.0) + (x[1] + x[2]) *
            (x[1] + x[2]) - 27.0;
        f[1] = System.Math.Exp(x[1] - 2.0) / x[0] + x[2] * x[2] - 10.0;
        f[2] = x[2] + System.Math.Sin(x[1] - 2.0) + x[1] * x[1] - 7.0;
    }


    public static void  Main(String[] args)
    {        
        ZeroSystem zf = new ZeroSystem(3);
        zf.SetGuess(new double[]{4, 4, 4});
        new PrintMatrix("zeros").Print(zf.Solve(new ZeroSystemEx1()));
    }
}

Output

        zeros
          0          
0  0.99999999995498  
1  2.00000000000656  
2  2.99999999999468  


Link to C# source.