mrAnderson33

Untitled

Dec 18th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. static double[] uproch = {0,0,0,0,0,0};
  2.  
  3.  static void rachet(double x0,double x1, double x2, double x3, double x4, double x5,double x6)
  4.         {
  5.             double f0, f1, f2, f3, f4;
  6.                 f0 = x1 + x2 + x3 + x4 + x5;
  7.                 f1 = x1 * x2 + x2 * x4 + x1 * x4 + x2 * x3 - x1 * x3 + x3 * x4 + x2 * x5 + x1 * x5 + x4 * x5 + x3 * x5;
  8.                 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;
  9.                 f3 = x1 * x2 * x3 * x4 + x1 * x2 * x4 * x5 + x1 * x2 * x3 * x5 + x2 * x3 * x4 * x5 + x1 * x3 * x4 * x5;
  10.                 f4 = x1 * x2 * x3 * x4 * x5;
  11.            
  12.                
  13.                
  14.                 double res;
  15.                 res = Math.Pow(x0, 5) - Math.Pow(x0, 4) * f0 + Math.Pow(x0, 3) * f1 - Math.Pow(x0, 2) * f2 + x0 * f3 - f4;
  16.                 res *= x6;
  17.                 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);
  18.                 uproch[0] += x6;
  19.                 uproch[1] += x6 * f0;
  20.                 uproch[2] += x6*f1;
  21.                 uproch[3] += x6*f2;
  22.                 uproch[4] += x6*f3;
  23.                 uproch[5] += x6*f4;
  24.  
  25.         }
  26.  
  27.         static void Polynom_Lagrange(double[] arr_x, double[] arr_y)
  28.         {
  29.            
  30.            
  31.             rachet(arr_x[0],arr_x[1], arr_x[2], arr_x[3], arr_x[4], arr_x[5],arr_y[0]);
  32.             Console.WriteLine(" + ");
  33.             rachet(arr_x[1], arr_x[0], arr_x[2], arr_x[3], arr_x[4], arr_x[5], arr_y[1]);
  34.             Console.WriteLine(" + ");
  35.             rachet(arr_x[2], arr_x[0], arr_x[1], arr_x[3], arr_x[4], arr_x[5], arr_y[2]);
  36.             Console.WriteLine(" + ");
  37.             rachet(arr_x[3], arr_x[0], arr_x[1], arr_x[2], arr_x[4], arr_x[5], arr_y[3]);
  38.             Console.WriteLine(" + ");
  39.             rachet(arr_x[4], arr_x[0], arr_x[1], arr_x[2], arr_x[3], arr_x[5], arr_y[4]);
  40.             Console.WriteLine(" + ");
  41.             rachet(arr_x[5], arr_x[0], arr_x[1], arr_x[2], arr_x[3], arr_x[4], arr_y[5]);
  42.             Console.WriteLine("\n\n\n");
  43.             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]);
  44.         }
Add Comment
Please, Sign In to add comment