using System; using System.Collections.Generic; using System.Linq; using System.Text; using V = Science.Mathematics.VectorCalculus; namespace VectorCalculus5Ed.Chapter6.Section2 { 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[] from = { 0.0, 0.0, 0.0 }; double[] to = { 1.0, Math.PI, 2.0*Math.PI }; V.IntegrationMultiD obj = new V.IntegrationMultiD(f, from, to); obj.NumberOfCall = 1000000; obj.Compute(); result += obj.BestEstimation.ToString() + "\r\n"; result += (4.0/3.0*Math.PI*(Math.E - 1.0)).ToString() + "\r\n"; } private double func(double[] u) { return Math.Abs(jac(u)) * funcxy(funcT(u)); } private double[] funcT(double[] u) { double[] x = new double[3]; x[0] = u[0] * Math.Sin(u[1]) * Math.Cos(u[2]); x[1] = u[0] * Math.Sin(u[1]) * Math.Sin(u[2]); x[2] = u[0] * Math.Cos(u[1]); return x; } private double jac(double[] u) { double[] at = { u[0], u[1], u[2] }; Science.Mathematics.Function.ToLastType f = new Science.Mathematics.Function.ToLastType(funcT); V.JacobianDeterminant obj = new V.JacobianDeterminant(f, at); obj.Compute(); return obj.Result; } private double funcxy(double[] x) { return Math.Exp(Math.Pow(x[0] * x[0] + x[1] * x[1] + x[2] * x[2],1.5)); } } } /* 7.19752429792026 7.1975220921117 */