Esempio n. 1
0
        private void buttonMainSolve_Click(object sender, EventArgs e)
        {
            n = int.Parse(textBoxDiv.Text);

            Column3.HeaderText = "v(xi)";
            Column4.HeaderText = "v2(x2i)";
            Column5.HeaderText = "|v(xi) - v2(x2i)|";



            dataGridView1.Rows.Clear();

            dataGridView1.Visible = false;

            task = new MainTask();

            List <double> ai;
            List <double> di;
            List <double> phi;
            List <double> vi;
            List <double> ai2;
            List <double> di2;
            List <double> phi2;
            List <double> vi2;
            List <double> dif;
            List <double> xi   = new List <double>();
            List <double> xi2  = new List <double>();
            List <double> x2i  = new List <double>();
            List <double> x2i2 = new List <double>();

            List <List <double> > matrix;
            List <List <double> > matrix2;

            double h = 1.0 / n;

            task.GetGrids(ref xi, ref xi2, h);

            ai     = task.GetAi(h, n, xi);
            di     = task.GetDi(h, xi2);
            phi    = task.GetPhi(h, xi2);
            matrix = task.GetMatrix(n, h, ai, di, phi);
            vi     = task.GetDifSceme(n, matrix);

            int    n2 = n * 2;
            double h2 = 1.0 / n2;

            task.GetGrids(ref x2i, ref x2i2, h2);

            ai2     = task.GetAi(h2, n2, x2i);
            di2     = task.GetDi(h2, x2i2);
            phi2    = task.GetPhi(h2, x2i2);
            matrix2 = task.GetMatrix(n2, h2, ai2, di2, phi2);
            vi2     = task.GetDifSceme(n2, matrix2);
            dif     = task.GetAbsDif(vi, vi2);

            DrawSolve(xi, vi2, vi);
            DrawError(xi, dif);

            zedGraphControl2.GraphPane.XAxis.Title = "X";
            zedGraphControl2.GraphPane.YAxis.Title = "U(xi)";

            zedGraphControl1.GraphPane.XAxis.Title = "X";
            zedGraphControl1.GraphPane.YAxis.Title = "|v(xi) - v2(x2i)|";

            dataGridView1.Visible = true;

            labelInfo.Text = "Для решения задачи использована равномерная сетка с числом разбиений n = " +
                             n.ToString() + "\n \n" + "Задача решена с погрешностью max(|v(xi) - v2(x2i)|) = " +
                             dif.Max().ToString() +
                             "\n \n" + "Mаксимальная разность численных решений в общих узлах сетки наблюдается в точке x = " +
                             xPoint.ToString();
        }