using System; using System.Collections.Generic; using System.Linq; using System.Text; using V = Science.Mathematics.VectorCalculus; namespace VectorCalculus5Ed.Chapter7.Section6 { public class Example04 { public Example04() { } private string result; public string Result { get{return result;} } public void Compute() { Science.Mathematics.Function.ToLastType ff = new Science.Mathematics.Function.ToLastType(func); V.Surface s = new V.Surface(ff); s.Parameter1StartValue = 0.0; s.Parameter1EndValue = 2.0 * Math.PI; s.Parameter2StartValue = 0.0; s.Parameter2EndValue = Math.PI; Science.Mathematics.Function.ToLastType fg = new Science.Mathematics.Function.ToLastType(fff); double[] tempat = { 0.0, 0.0, 0.0 }; grad = new V.Gradient(fg, tempat); Science.Mathematics.Function.ToLastType g = new Science.Mathematics.Function.ToLastType(gfunc); V.SurfaceIntegral obj = new V.SurfaceIntegral(g, s); obj.Compute(); result += obj.Result.ToString() + "\r\n"; double res = -8.0 * Math.PI; result += res.ToString() + "\r\n"; } private double[] func(double[] u) { double[] x = new double[3]; x[0] = Math.Cos(u[0]) * Math.Sin(u[1]); x[1] = Math.Sin(u[0]) * Math.Sin(u[1]); x[2] = Math.Cos(u[1]); return x; } V.Gradient grad; private double[] gfunc(double[] x) { grad.At = x; grad.Compute(); return grad.Result; } private double fff(double[] x) { return x[0] * x[0] + x[1] * x[1] + x[2] * x[2]; } } } /* -25.1328143807556 -25.1327412287183 */