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); }
public string GetPolyNewton(int poryadok, int row = 1) { string str = this.txtBxs[row, 1].Text; string proizv = ""; Fraction m = new Fraction(); Fraction l = new Fraction(); Fraction k = new Fraction(); if (isRavnom()) { Fraction h = new Fraction(); m = this.matr.A[1, 0].CopyFr; k = this.matr.A[2, 0].CopyFr; h = k - m; if (poryadok >= this.NRow - row - 1) { poryadok = this.NRow - row - 1; } for (int i = 1; i <= poryadok; i++) { m.FractTxt = "" + MyFuncs.factorial(i); m *= h.Power(i); l = this.matr.A[row, i + 1].CopyFr; l /= m; //str += "+" + l.FractTxt; str += (l < 0?"":"+") + l.FractTxt; proizv = ""; for (int j = 1; j < i + 1; j++) { //proizv += "(" + this.txtBxs[0, 0].Text + "-" + this.txtBxs[j + row - 1, 0].Text + ")"; proizv += '\x00D7' + (this.txtBxs[j + row - 1, 0].Text == "0" ? "" :"(") + this.txtBxs[0, 0].Text + (this.txtBxs[j + row - 1, 0].Text == "0"?"": "-" + this.txtBxs[j + row - 1, 0].Text + ")"); } str += proizv; } } else { if (poryadok >= this.NRow - row - 1) { poryadok = this.NRow - row - 1; } for (int i = 1; i <= poryadok; i++) { l = this.matr.A[row, i + 1].CopyFr; str += (l < 0 ? "" : "+") + l.FractTxt; proizv = ""; for (int j = 1; j < i + 1; j++) { proizv += '\x00D7' + (this.txtBxs[j + row - 1, 0].Text == "0" ? "" : "(") + this.txtBxs[0, 0].Text + (this.txtBxs[j + row - 1, 0].Text == "0" ? "" : "-" + this.txtBxs[j + row - 1, 0].Text + ")"); } str += proizv; } } return(str); }
public Fraction GetPolyNewtonVal(Fraction fr, int poryadok, int row = 1) { Fraction rez = new Fraction(); rez = this.matr.A[row, 1].CopyFr; Fraction m = new Fraction(1, 1); Fraction n = new Fraction(1, 1); Fraction l = new Fraction(1, 1); Fraction k = new Fraction(1, 1); if (poryadok >= this.NRow - row - 1) { poryadok = this.NRow - row - 1; } if (isRavnom()) { Fraction h = new Fraction(); m = this.matr.A[1, 0].CopyFr; k = this.matr.A[2, 0].CopyFr; h = k - m; for (int i = 1; i <= poryadok; i++) { m.FractTxt = "" + MyFuncs.factorial(i); m *= h.Power(i); l = this.matr.A[row, i + 1].CopyFr; l /= m; n.FractTxt = "1"; for (int j = 1; j < i + 1; j++) { k = this.matr.A[j + row - 1, 0].CopyFr; n *= (fr - k); } rez += l * n; } } else { for (int i = 1; i <= poryadok; i++) { l = this.matr.A[row, i + 1].CopyFr; n.FractTxt = "1"; for (int j = 1; j < i + 1; j++) { k = this.matr.A[j + row - 1, 0].CopyFr; n *= (fr - k); } rez += l * n; } } return(rez); }
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); }
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); }