using System; using System.Collections.Generic; using System.Linq; using System.Text; using V = Science.Mathematics.VectorCalculus; namespace VectorCalculus5Ed.Chapter2.Section5 { public class Example01 { public Example01() { } 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); Science.Mathematics.Function.ToLastType h = new Science.Mathematics.Function.ToLastType(funch); double[] x0 = { 4.0, 1.0, 1.0 }; V.MatrixOfPartialDerivatives obj1 = new V.MatrixOfPartialDerivatives(f, x0); obj1.Compute(); V.MatrixOfPartialDerivatives obj2 = new V.MatrixOfPartialDerivatives(g, x0); obj2.Compute(); V.MatrixOfPartialDerivatives obj3 = new V.MatrixOfPartialDerivatives(h, x0); obj3.Compute(); result += obj3.Result.ToString() + "\r\n"; V.Matrix res = (g(x0)[0] * obj1.Result - f(x0)[0] * obj2.Result) * (1.0 / g(x0)[0] / g(x0)[0]); result += res.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]*x[2]; return r; } private double[] funcg(double[] x) { double[] r = new double[1]; r[0] = x[0] * x[0] + 1.0; return r; } private double[] funch(double[] x) { double[] r = new double[1]; r[0] = funcf(x)[0] / funcg(x)[0]; return r; } } } /* -0.0276816608995446 0.117647058823692 0.117647058823692 -0.0276816608996471 0.117647058823697 0.117647058823697 */