Ejemplo n.º 1
0
        public Fraction GetPolyNewtonDiff2Err(Fraction fr, int poryadok, int row = 1)
        {
            if (poryadok >= this.NRow - row - 1)
            {
                poryadok = this.NRow - row - 1;
                if (poryadok >= 5)
                {
                    poryadok = 5;
                }
                if (poryadok >= this.NCol - row - 2)
                {
                    poryadok = this.NCol - row - 2;
                }
            }
            Fraction rez = new Fraction();

            if (isRavnom())
            {
                Fraction q = new Fraction();
                Fraction l = new Fraction();
                Fraction h = new Fraction();
                h = this.matr.A[1, 0].CopyFr;
                q = this.matr.A[2, 0].CopyFr;
                h = q - h;
                q = this.matr.A[row, 0].CopyFr;
                q = (fr - q) / h;
                switch (poryadok)
                {
                case 1:
                    l   = this.matr.A[row, 3].CopyFr;
                    rez = h.Invert().Power(2) * l;
                    break;

                case 2:
                    l   = this.matr.A[row, 4].CopyFr;
                    rez = h.Invert().Power(2) * l * (q - 1);
                    break;

                case 3:
                    l   = this.matr.A[row, 5].CopyFr;
                    rez = h.Invert().Power(2) * l * (6 * q.Power(2) - 18 * q + 11) / 12;
                    break;

                case 4:
                    l   = this.matr.A[row, 6].CopyFr;  //возможна ошибка
                    rez = h.Invert().Power(2) * l * (2 * q.Power(3) - 12 * q.Power(2) + 21 * q - 10) / 12;
                    break;

                case 5:
                    l   = this.matr.A[row, 7].CopyFr;                                               //возможна ошибка
                    rez = h.Invert().Power(2) * l * GetPolyNewtonDiff1Val(fr, poryadok, row) / 720; //доделать
                    break;

                default:
                    MessageBox.Show("Максимальный поддерживаемый порядок = 5!");
                    break;
                }
            }
            return(rez);
        }
Ejemplo n.º 2
0
        public Fraction GetPolyNewtonDiff2Val(Fraction fr, int poryadok, int row = 1)
        {
            if (poryadok >= this.NRow - row - 1)
            {
                poryadok = this.NRow - row - 1;
                if (poryadok >= 5)
                {
                    poryadok = 5;
                }
            }
            Fraction rez = new Fraction();

            if (isRavnom())
            {
                Fraction m  = new Fraction();
                Fraction q  = new Fraction();
                Fraction k  = new Fraction();
                Fraction l1 = new Fraction();
                Fraction l2 = new Fraction();
                Fraction l3 = new Fraction();
                Fraction l4 = new Fraction();
                Fraction l5 = new Fraction();
                Fraction h  = new Fraction();
                m = this.matr.A[1, 0].CopyFr;
                k = this.matr.A[2, 0].CopyFr;
                h = k - m;
                k = this.matr.A[row, 0].CopyFr;
                q = (fr - k) / h;
                switch (poryadok)
                {
                case 1:
                    l1  = this.matr.A[row, 2].CopyFr;
                    rez = l1;
                    break;

                case 2:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    rez = h.Invert() * (l1 + l2 * (q * 2 - 1) / MyFuncs.factorial(2));
                    break;

                case 3:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    rez = h.Invert().Power(2) * (l2 + l3 * (q - 1));
                    break;

                case 4:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    l4  = this.matr.A[row, 5].CopyFr;
                    rez = h.Invert().Power(2) * (l2 + l3 * (q - 1) + l4 * (6 * q.Power(2) - 18 * q + 11) / 12);
                    break;

                case 5:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    l4  = this.matr.A[row, 5].CopyFr;
                    l5  = this.matr.A[row, 6].CopyFr;
                    rez = h.Invert().Power(2) * (l2 + l3 * (q - 1) + l4 * (6 * q.Power(2) - 18 * q + 11) / 12 + l5 * (2 * q.Power(3) - 12 * q.Power(2) + 21 * q - 10) / 12);
                    break;

                default:
                    MessageBox.Show("Максимальный поддерживаемый порядок = 5!");
                    break;
                }
            }
            return(rez);
        }
Ejemplo n.º 3
0
        public Fraction GetPolyNewtonDiff1Val(Fraction fr, int poryadok, int row = 1)
        {
            if (poryadok >= this.NRow - row - 1)
            {
                poryadok = this.NRow - row - 1;
                if (poryadok >= 5)
                {
                    poryadok = 5;
                }
            }
            Fraction rez = new Fraction();

            if (isRavnom())
            {
                Fraction q  = new Fraction();
                Fraction l1 = new Fraction();
                Fraction l2 = new Fraction();
                Fraction l3 = new Fraction();
                Fraction l4 = new Fraction();
                Fraction l5 = new Fraction();
                Fraction h  = new Fraction();
                q  = this.matr.A[1, 0].CopyFr;
                h  = this.matr.A[2, 0].CopyFr;
                h -= q;
                q  = this.matr.A[row, 0].CopyFr;
                q  = (fr - q) / h;
                switch (poryadok)
                {
                case 1:
                    l1  = this.matr.A[row, 2].CopyFr;
                    rez = h.Invert() * (l1);
                    break;

                case 2:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    rez = h.Invert() * (l1 + l2 * (2 * q - 1) / 2);
                    break;

                case 3:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    rez = h.Invert() * (l1 + l2 * (2 * q - 1) / 2 + l3 * (3 * q.Power(2) - 6 * q + 2) / 6);
                    break;

                case 4:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    l4  = this.matr.A[row, 5].CopyFr;
                    rez = h.Invert() * (l1 + l2 * (2 * q - 1) / 2 + l3 * (3 * q.Power(2) - 6 * q + 2) / 6 + l4 * (2 * q.Power(3) - 9 * q.Power(2) + 11 * q - 3) / 12);
                    break;

                case 5:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    l4  = this.matr.A[row, 5].CopyFr;
                    l5  = this.matr.A[row, 6].CopyFr;
                    rez = h.Invert() * (l1 + l2 * (2 * q - 1) / 2 + l3 * (3 * q.Power(2) - 6 * q + 2) / 6 + l4 * (2 * q.Power(3) - 9 * q.Power(2) + 11 * q - 3) / 12 + l5 * (5 * q.Power(4) - 40 * q.Power(3) + 105 * q.Power(2) - 100 * q + 24) / 120);
                    break;

                default:
                    MessageBox.Show("Максимальный поддерживаемый порядок = 5!");
                    break;
                }
            }
            return(rez);
        }