using System; using System.Collections.Generic; using System.Linq; using System.Text; using V = Science.Mathematics.VectorCalculus; namespace VectorCalculus5Ed.Chapter3.Section3 { public class Example10 { public Example10() { } private string result; public string Result { get{return result;} } public void Compute() { Science.Mathematics.Function.ToLastType f = new Science.Mathematics.Function.ToLastType(func); double[] at = { 1.0/2.0, 1.0/2.0 }; double[] h = { 0.01, 0.03 }; V.Hessian obj = new V.Hessian(f, at, h); obj.Compute(); result += obj.Result.ToString() + "\r\n"; result += obj.Matrix.ToString(); result += func(at).ToString() + "\r\n"; double t = Math.PI/4.0; at[0] = Math.Sin(t); at[1] = Math.Cos(t); result += func(at).ToString() + "\r\n"; t = 5.0 * Math.PI / 4.0; at[0] = Math.Sin(t); at[1] = Math.Cos(t); result += func(at).ToString() + "\r\n"; } private double func(double[] x) { return x[0] * x[0] + x[1] * x[1] - x[0] - x[1] + 1.0; } } } /* 0.000999999999988329 1.99999999997666 0 0 1.99999999997666 0.5 0.585786437626905 3.41421356237309 */