using System; using System.Collections.Generic; using System.Linq; using System.Text; using V = Science.Mathematics.VectorCalculus; namespace VectorCalculus5Ed.Chapter2.Section3 { public class Example06 { public Example06() { } private string result; public string Result { get{return result;} } public void Compute() { Science.Mathematics.Function.ToLastType f = new Science.Mathematics.Function.ToLastType(func); double[] x0 = {4.0, 2.0}; V.MatrixOfPartialDerivatives obj = new V.MatrixOfPartialDerivatives(f, x0); obj.Compute(); result += obj.Result.ToString(); result += (Math.Exp(x0[0]+x0[1])).ToString() + " "; result += (Math.Exp(x0[0] + x0[1])+1.0).ToString() + "\r\n"; result += (x0[1]*x0[1]).ToString() + " "; result += (2.0 * x0[0] * x0[1]).ToString() + "\r\n" + "\r\n"; Science.Mathematics.Function.ToLastType fc = new Science.Mathematics.Function.ToLastType(funcc); double[] t = { 4.0, 2.0, 1.0 }; V.MatrixOfPartialDerivatives objc = new V.MatrixOfPartialDerivatives(fc, t); objc.Compute(); result += objc.Result.ToString(); result += (t[2]*Math.Exp(t[0])).ToString() + " "; result += (0.0).ToString() + " "; result += (Math.Exp(t[0])).ToString() + "\r\n"; result += (0.0).ToString() + " "; result += (-Math.Exp(t[2])).ToString() + " "; result += (-t[1]*Math.Exp(t[2])).ToString() + "\r\n"; } private double[] func(double[] x) { double[] r = new double[2]; r[0] = Math.Exp(x[0] + x[1]) + x[1]; r[1] = x[1] * x[1] * x[0]; return r; } private double[] funcc(double[] x) { double[] r = new double[2]; r[0] = x[2]*Math.Exp(x[0]); r[1] = - x[1] * Math.Exp(x[2]); return r; } } } /* 403.428793492627 404.428793492662 3.999999999999 16.0000000000064 403.428793492735 404.428793492735 4 16 54.5981500331566 0 54.5981500331386 0 -2.71828182845971 -5.43656365691873 54.5981500331442 0 54.5981500331442 0 -2.71828182845905 -5.43656365691809 */