Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Eps  = Convert.ToDouble(tbEps.Text);
            Eps1 = Convert.ToDouble(tbEps1.Text);

            p0  = Convert.ToDouble(tbP.Text);
            T_0 = Convert.ToDouble(tbT_0.Text);
            T0  = Convert.ToDouble(tbT0.Text);
            Tw  = Convert.ToDouble(tbTw.Text);
            n   = Convert.ToInt32(tbN.Text);

            //c = p0 * 7242 / T_0;
            c = p0 * 3621 / T_0;

            N              = (int)UpDownNTrapez.Value;
            Integral       = Trapez;
            lblAnswer.Text = "Trapezium: p = " + Dihotomy(0, 50).ToString();

            N               = (int)UpDownNSimpson.Value;
            Integral        = Simpson;
            lblAnswer3.Text = "Simpson: p = " + Dihotomy(0, 50).ToString();

            N = (int)UpDownNGauss.Value;
            LegendrePolynom = new LegendrePolynom((int)UpDownNGauss.Value, Eps);

            Integral = Gauss;
            LegendreCoeffs2(N, out LegendreCoefs);
            lblAnswer2.Text = "Gauss: p = " + Dihotomy(0, 50).ToString();
        }
Пример #2
0
        void CalculGaussCoefs(int N, out double[] LegendreRoots, out double[] GaussCoefs)
        {
            LegendrePolynom Polynom = new LegendrePolynom(N, 1e-9);

            double[,] Matrix = new double[N, N + 1];

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (i == 0)
                    {
                        Matrix[i, j] = 1;
                    }
                    else
                    {
                        Matrix[i, j] = Math.Pow(Polynom.Roots[j], i);
                    }
                }

                if (i % 2 == 0)
                {
                    Matrix[i, N] = 2.0 / (i + 1);
                }
                else
                {
                    Matrix[i, N] = 0;
                }
            }
            GaussCoefs    = SLE.GaussSolve(Matrix, N);
            LegendreRoots = Polynom.Roots;
        }