using System; namespace Science.Mathematics.VectorCalculus { public class GreenTheorem { private Function.ToLastType ff; private Function.ToLastType sf; private Path c; private Surface s; public GreenTheorem() { } public GreenTheorem(Path C, Function.ToLastType P, Function.ToLastType Q, Surface D) { c = C; ff = P; sf = Q; s = D; } public Function.ToLastType FirstFunction { set { ff = value; } } public Function.ToLastType SecondFunction { set { sf = value; } } public Path Boundary { set { c = value; } } public Surface Domain { set { s = value; } } public void Compute() { Function.ToLastType vf = new Function.ToLastType(vPQ); LineIntegral li = new LineIntegral(vf, c); li.Compute(); ltgral = li.Result; Function.ToLastType sf = new Function.ToLastType(sPQ); SurfaceIntegralScalar obj = new SurfaceIntegralScalar(sf, s); obj.NumberOfCall = nc; obj.Compute(); tgral = obj.BestEstimation; sd = obj.StandardDeviation; chi2 = obj.ChiSQUARE; } private double[] vPQ(double[] x) { double[] f = new double[3]; f[0] = ff(x); f[1] = sf(x); f[2] = 0.0; return f; } private double sPQ(double[] x) { PartialDerivative obj = new PartialDerivative(sf, x); obj.WithRespectTo = 0; obj.Compute(); double sum = obj.Result; PartialDerivative obj1 = new PartialDerivative(ff, x); obj1.WithRespectTo = 1; obj1.Compute(); sum -= obj1.Result; return sum; } public double LeftHandSideBestEstimation { get { return ltgral; } } private double ltgral, tgral, sd, chi2; private ulong nc = 100000; public double RightHandSideBestEstimation { get { return tgral; } } public double RightHandSideStandardDeviation { get { return sd; } } public double RightHandSideChiSQUARE { get { return chi2; } } public ulong NumberOfCall { set { nc = value; } } public override string ToString() { string res = ""; res += this.LeftHandSideBestEstimation.ToString() + " = "; res += this.RightHandSideBestEstimation.ToString() + " +/- " + this.RightHandSideStandardDeviation.ToString(); res += "\r\n"; return res; } } }