Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static double[] uproch = {0,0,0,0,0,0};
- static void rachet(double x0,double x1, double x2, double x3, double x4, double x5,double x6)
- {
- double f0, f1, f2, f3, f4;
- f0 = x1 + x2 + x3 + x4 + x5;
- f1 = x1 * x2 + x2 * x4 + x1 * x4 + x2 * x3 - x1 * x3 + x3 * x4 + x2 * x5 + x1 * x5 + x4 * x5 + x3 * x5;
- f2 = x1 * x2 * x4 + x1 * x2 * x3 + x2 * x3 * x4 + x1 * x3 * x4 + x1 * x2 * x5 + x2 * x4 * x5 + x1 * x4 * x5 + x2 * x3 * x5 + x1 * x3 * x5 + x3 * x4 * x5;
- f3 = x1 * x2 * x3 * x4 + x1 * x2 * x4 * x5 + x1 * x2 * x3 * x5 + x2 * x3 * x4 * x5 + x1 * x3 * x4 * x5;
- f4 = x1 * x2 * x3 * x4 * x5;
- double res;
- res = Math.Pow(x0, 5) - Math.Pow(x0, 4) * f0 + Math.Pow(x0, 3) * f1 - Math.Pow(x0, 2) * f2 + x0 * f3 - f4;
- res *= x6;
- Console.Write("( {0}*x^5 - {1}*x^4 + {2}*x^3 - {3}*x^2 + {4}*x - {5} )", x6, x6 * f0, x6 * f1, x6 * f2, x6*f3,x6* f4);
- uproch[0] += x6;
- uproch[1] += x6 * f0;
- uproch[2] += x6*f1;
- uproch[3] += x6*f2;
- uproch[4] += x6*f3;
- uproch[5] += x6*f4;
- }
- static void Polynom_Lagrange(double[] arr_x, double[] arr_y)
- {
- rachet(arr_x[0],arr_x[1], arr_x[2], arr_x[3], arr_x[4], arr_x[5],arr_y[0]);
- Console.WriteLine(" + ");
- rachet(arr_x[1], arr_x[0], arr_x[2], arr_x[3], arr_x[4], arr_x[5], arr_y[1]);
- Console.WriteLine(" + ");
- rachet(arr_x[2], arr_x[0], arr_x[1], arr_x[3], arr_x[4], arr_x[5], arr_y[2]);
- Console.WriteLine(" + ");
- rachet(arr_x[3], arr_x[0], arr_x[1], arr_x[2], arr_x[4], arr_x[5], arr_y[3]);
- Console.WriteLine(" + ");
- rachet(arr_x[4], arr_x[0], arr_x[1], arr_x[2], arr_x[3], arr_x[5], arr_y[4]);
- Console.WriteLine(" + ");
- rachet(arr_x[5], arr_x[0], arr_x[1], arr_x[2], arr_x[3], arr_x[4], arr_y[5]);
- Console.WriteLine("\n\n\n");
- Console.WriteLine("Упрощаем: {0}*x^5 + {1}*x^4 + {2}*x^3 + {3}*x^2 + {4}*x + {5}", uproch[0], uproch[1], uproch[2], uproch[3], uproch[4], uproch[5]);
- }
Add Comment
Please, Sign In to add comment