using System; using System.Collections.Generic; using System.Linq; using System.Text; using V = Science.Mathematics.VectorCalculus; namespace VectorCalculus5Ed.Chapter2.Section5 { public class Example02 { public Example02() { } private string result; public string Result { get{return result;} } public void Compute() { Science.Mathematics.Function.ToLastType f = new Science.Mathematics.Function.ToLastType(funcf); Science.Mathematics.Function.ToLastType g = new Science.Mathematics.Function.ToLastType(funcg); double[] x0 = { 4.0, 1.0, 1.0 }; V.ChainRule obj = new V.ChainRule(f,g,x0); obj.Compute(); result += obj.Result.ToString() + "\r\n"; result += (4.0*x0[0]*x0[0]*x0[0]*x0[1]*x0[1]+x0[2]*Math.Exp(-x0[0]*x0[2])).ToString() + "\r\n"; } private double[] funcf(double[] x) { double[] r = new double[1]; r[0] = x[0] * x[0] + x[1] * x[1] - x[2]; return r; } private double[] funcg(double[] x) { double[] r = new double[3]; r[0] = x[0] * x[0] * x[1]; r[1] = x[1] * x[1]; r[2] = Math.Exp(-x[0] * x[2]); return r; } } } /* 256.018315638684 515.999999999315 0.0732625555573645 256.018315638889 */