Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static double Newtoon(double[] MasX, double[] MasY, int n, double x)
- {
- double result = MasY[0];
- double[,] endDiffY0 = new double[n, n]; //конечные разности y0. Первый столбец для y0, второй для y1, третий y2
- for (int i = 0; i < n - 1; i++)
- {
- endDiffY0[0, i] = MasY[i + 1] - MasY[i];
- }
- for (int i = 1; i < n; i++) //порядок конечной разности
- {
- for (int j = 0; j < n - i; j++) //для каких y
- {
- endDiffY0[i, j] = endDiffY0[i - 1, j + 1] - endDiffY0[i - 1, j];
- }
- }
- int fact = 1;
- double q = (x - MasX[0]) / (MasX[1] - MasX[0]);
- double q_f = q;
- for (int i = 1; i < n; i++)
- {
- result += q_f * endDiffY0[i - 1, 0] / fact;
- q_f *= (q - i);
- fact *= (i + 1);
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement