using System; using System.Collections.Generic; using System.Linq; using System.Text; using V = Science.Mathematics.VectorCalculus; namespace VectorCalculus5Ed.Chapter4.Section3 { public class Example05 { public Example05() { } private string result; public string Result { get{return result;} } public void Compute() { Science.Mathematics.Function.ToLastType ff = new Science.Mathematics.Function.ToLastType(grad); V.VectorField f = new V.VectorField(ff); double[] c = {1.0,1.0,1.0}; V.Point p = new V.Point(c); f.FindComponents(p); result += f[0].ToString() + "\r\n"; result += f[1].ToString() + "\r\n"; result += f[2].ToString() + "\r\n"; } private double[] grad(double[] x) { Science.Mathematics.Function.ToLastType delv = new Science.Mathematics.Function.ToLastType(v); V.Gradient gr = new V.Gradient(delv, x); gr.Compute(); double[] res = new double[x.Length]; for (int i = 0; i < res.Length; i++) res[i] = gr.Result[i]; return res; } private double v(double[] x) { return -1.0 / Math.Sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]); } } } /* 0.192450089730004 0.192450089730004 0.192450089730004 */