private MathFunction UK(BoundaryValueTask task, int k)
        {
            if (k == 0)
            {
                double[,] m = new double[, ]
                {
                    { task.alpha0 *task.a + task.alpha1, task.alpha0 },
                    { task.betta0 *task.b + task.betta1, task.betta0 }
                };
                double[] v = new double[] { task.A, task.B };

                Vector res = method.Solve(new SLAE(m, v));

                return(new XFunction(res[0]) + res[1]);
            }

            return((new XFunction(1.0) ^ (k - 1)) *
                   (new XFunction(1.0) - task.a) * (new XFunction(1.0) - task.b));
        }
        public KeyValuePair <double, double>[] Solve(BoundaryValueTask task, int n)
        {
            MathFunction[] u = new MathFunction[collocationN + 1];
            for (int i = 0; i <= collocationN; i++)
            {
                u[i] = UK(task, i);
            }

            double[,] matrix = new double[collocationN, collocationN];
            double[] vect = new double[collocationN];
            double   h    = (task.b - task.a) / (collocationN + 1);

            for (int i = 0; i < collocationN; i++)
            {
                double xi = task.a + (i + 1) * h;

                vect[i] = task.FX.Calculate(xi) - task.LOperator(u[0], xi);
                for (int j = 0; j < collocationN; j++)
                {
                    matrix[i, j] = task.LOperator(u[j + 1], xi);
                }
            }

            Vector       C  = method.Solve(new SLAE(matrix, vect));
            MathFunction yn = u[0];

            yn.Calculate(0);
            for (int i = 1; i <= collocationN; i++)
            {
                yn += C[i - 1] * u[i];
            }

            h = (task.b - task.a) / n;
            KeyValuePair <double, double>[] result = new KeyValuePair <double, double> [n + 1];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new KeyValuePair <double, double>(task.a + i * h, yn.Calculate(task.a + i * h));
            }

            return(result);
        }
        public KeyValuePair <double, double>[] Solve(BoundaryValueTask task, int n)
        {
            double[,] matrix = new double[n + 1, n + 1];
            double[] vect = new double[n + 1];

            double h = (task.b - task.a) / n;

            vect[0]          = task.A * h;
            vect[n]          = task.B * h;
            matrix[0, 0]     = task.alpha0 * h - task.alpha1;
            matrix[0, 1]     = task.alpha1;
            matrix[n, n]     = task.betta0 * h + task.betta1;
            matrix[n, n - 1] = -task.betta1;

            for (int i = 1; i <= n - 1; i++)
            {
                double xi = task.a + i * h;

                vect[i] = 2 * Math.Pow(h, 2) * task.FX.Calculate(xi);

                matrix[i, i + 1] = 2 + task.PX.Calculate(xi) * h;
                matrix[i, i]     = task.QX.Calculate(xi) * 2 * Math.Pow(h, 2) - 4;
                matrix[i, i - 1] = 2 - task.PX.Calculate(xi) * h;
            }

            Vector yx = new GaussMethod().Solve(new SLAE(matrix, vect));

            KeyValuePair <double, double>[] result = new KeyValuePair <double, double> [yx.Count];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new KeyValuePair <double, double>(task.a + i * h, yx[i]);
            }

            return(result);
        }