Esempio n. 1
0
        private void explicitMethod(uint approximation, funcPointer func, configurationAxisMethod cnf)
        {
            double yn         = 0;
            double yn1        = 0;
            int    tableBegin = 0;

            for (double i = cnf.x1; i < cnf.x2; i += cnf.h)
            {
                dataGridView1.Rows[tableBegin].Cells[(int)approximation + explicitOffset].Value = yn;
                yn1 = yn + cnf.h * func(yn, i);
                yn  = yn1;
                tableBegin++;
            }
        }
Esempio n. 2
0
        private void implicitMethod(uint approximation, funcPointer func, configurationAxisMethod cnf)
        {
            double yn         = 0;
            double yn1        = 0;
            int    tableBegin = 0;
            double x1         = cnf.x1;
            double x2         = cnf.x2;
            double h          = cnf.h;

            for (double i = cnf.x1; i < cnf.x2; i += cnf.h)
            {
                dataGridView1.Rows[tableBegin].Cells[(int)approximation + implictOffset].Value = yn;
                yn1 = 1 / (2 * h) - Math.Sqrt(1 / (4 * h * h) - yn / h - Math.Pow(i + h, 2));

                yn = yn1;
                tableBegin++;
            }
        }
Esempio n. 3
0
        private void pikardMethod(funcPointerPoly func, uint approximation, configurationAxisMethod cnf)
        {
            string resStringOfPolynoms = "";
            // initialize polynom
            List <double> list1 = new List <double>(1)
            {
                0
            };
            Polynomial poly1 = new Polynomial(list1);

            //poly1.printPolynomial();
            resStringOfPolynoms += poly1.printPolynomial() + "  == Это первый полином" + Environment.NewLine;

            List <double> list2 = new List <double>(2)
            {
                1, 0
            };
            Polynomial poly2 = new Polynomial(list2);

            resStringOfPolynoms += poly2.printPolynomial() + "  == Это второй полином" + Environment.NewLine;

            textBox1.Text = resStringOfPolynoms;

            Polynomial resPoly;


            for (uint i = 0; i <= approximation; i++)
            {
                resPoly = func(poly1, poly2);
                resPoly.integrate();
                resPoly.printPolynomial();
                poly1 = (Polynomial)resPoly.Clone();

                int begin = 0;
                for (double j = cnf.x1; j < cnf.x2; j += cnf.h)
                {
                    double res = resPoly.computeResult(j, false);
                    dataGridView1.Rows[begin].HeaderCell.Value    = j.ToString();
                    dataGridView1.Rows[begin].Cells[(int)i].Value = res;
                    begin++;
                }
            }
        }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            double x1            = 0;
            double x2            = 4;
            double h             = 1e-3;
            uint   approximation = 9;

            int tableHeight = (int)((x2 - x1) / h);
            int tableWidth  = 3 + (int)approximation;

            dataGridView1.RowCount    = tableHeight + 1;
            dataGridView1.ColumnCount = tableWidth;

            fillTable(approximation);

            funcPointerPoly funcPoly = testFunctionPoly;
            funcPointer     func     = testFunction;
            List <double>   list1    = new List <double>(1)
            {
                0
            };
            List <double> list2 = new List <double>(2)
            {
                1, 0
            };
            configurationAxisMethod config = new configurationAxisMethod(x1, x2, h);



            pikardMethod(funcPoly, approximation, config);

            explicitMethod(approximation, func, config);

            implicitMethod(approximation, func, config);


            Polynomial poly = new Polynomial(list2);
            string     res  = poly.printPolynomial();
            //textBox1.Text = res;
        }