using System; using System.Collections.Generic; using System.Linq; using System.Text; using V = Science.Mathematics.VectorCalculus; namespace ScienceTest.MathematicsTest.VectorCalculusTest { public class NonlinearFunctionTest { public NonlinearFunctionTest() { } private string result; public string Result { get{return result;} } public void Compute() { double[] x = new Double[4]; // initial value x[0] = 10.0; x[1] = 15.0; x[2] = 10.0; x[3] = 12.0; V.Function.ToLastType ddd = new V.Function.ToLastType(deri); V.NonlinearFunction dd = new V.NonlinearFunction(ddd); dd.FindRoot(x); for (int i = 0; i < x.Length; i++) result += Convert.ToString(dd.Root[i]) + "\r\n"; } private double[] deri(double[] x) { double[] fvec = new Double[x.Length]; fvec[0] = (x[2] - 3.0) * (x[3] - 4.0); fvec[1] = (x[1] - 2.0) * (x[2] - 7.0); fvec[2] = (x[2] - 3.0) * (x[0] - 5.0); fvec[3] = (x[2] - 5.0) * (x[1] - 1.0); return fvec; } } }