예제 #1
0
        static public double InitTrap(double x1, double x2, ref int Node)
        {
            double z;

            for (int i = 2; ;)
            {
                Sum       = 0;
                SumSecond = 0;

                z = x1;
                H = (x2 - z) / i;
                while (z != x2 && z < x2)
                {
                    z   += H;
                    Sum += H * (IntMath.dSi(z) + IntMath.dSi(z - H)) / 2;
                }

                z  = x1;
                i *= 2;
                H  = (x2 - z) / i;
                while (z != x2 && z < x2)
                {
                    z         += H;
                    SumSecond += H * (IntMath.dSi(z) + IntMath.dSi(z - H)) / 2;
                }
                if (Math.Abs(Sum - SumSecond) < eps && Sum != 0 && SumSecond != 0)
                {
                    Node = i;
                    return(Sum);
                }
            }
        }
예제 #2
0
        static public double InitGauss(double x1, double x2)
        {
            double maskX1;

            x2 = Math.Abs(x2);
            for (int i = 2; ;)
            {
                Sum       = 0;
                SumSecond = 0;

                maskX1 = x1;
                H      = (x2 - maskX1) / i;
                while (maskX1 != x2 && maskX1 < x2)
                {
                    maskX1 += H;
                    Sum    += (H / 2) * (IntMath.dSi(maskX1 - H + H / 2 * (1 - 1 / Math.Sqrt(3))) +
                                         IntMath.dSi(maskX1 - H + H / 2 * (1 + 1 / Math.Sqrt(3))));
                }

                maskX1 = x1;
                i     *= 2;
                H      = (x2 - maskX1) / i;
                while (maskX1 != x2 && maskX1 < x2)
                {
                    maskX1    += H;
                    SumSecond += (H / 2) * (IntMath.dSi(maskX1 - H + H / 2 * (1 - 1 / Math.Sqrt(3))) +
                                            IntMath.dSi(maskX1 - H + H / 2 * (1 + 1 / Math.Sqrt(3))));
                }
                if (Math.Abs(Sum - SumSecond) < eps && Sum != 0 && SumSecond != 0)
                {
                    return(Sum);
                }
            }
        }
예제 #3
0
        static public double InitSimp(double x1, double x2, ref int Node)
        {
            double maskX1;

            for (int i = 2; ;)
            {
                Sum       = 0;
                SumSecond = 0;

                maskX1 = x1;
                H      = (x2 - maskX1) / i;
                while (maskX1 != x2 && maskX1 < x2)
                {
                    maskX1 += H;
                    Sum    += (H / 6) * (IntMath.dSi(maskX1 - H) + 4 * IntMath.dSi((2 * maskX1 - H) / 2) + IntMath.dSi(maskX1));
                }

                maskX1 = x1;
                i     *= 2;
                H      = (x2 - maskX1) / i;
                while (maskX1 != x2 && maskX1 < x2)
                {
                    maskX1    += H;
                    SumSecond += (H / 6) * (IntMath.dSi(maskX1 - H) + 4 * IntMath.dSi((2 * maskX1 - H) / 2) + IntMath.dSi(maskX1));
                }
                if (Math.Abs(Sum - SumSecond) < eps && Sum != 0 && SumSecond != 0)
                {
                    Node = i;
                    return(Sum);
                }
            }
        }