|
Метод Гаусса с выбором главной переменной
Текст программы. #include <stdlib.h> long double A[num][num+1]; { max =
A[num+1-sr][num+2-st]; for (j = num+2-st ; j<=num ;
j++) } } cout << "\n"; for (j =
num+2-st ; j<=num+1 ; j++) cout <<
A[i][j]; void preob(int S) for (j = S; j<= num+1 ; j++) A[i][j] = A[i][j] -
A[S][j]*temp; void perestanovka(int sr,int
st) A[i][J] = A[i][J] + A[i][num+1-sr]; c[J] =
c[J] + c[num+1-sr]; { A[num+2-
st][j] = A[I][j] - A[num+2-st][j]; // -----------------------------------------------
------------------- for(j = num; j
> i; j--) temp = temp - A[i][j]*x[j]; // -----------------------------------------
------------------------- cout << "\n Массив перестановок
столбцов "; // ---------------------------------------------------------
--------- ch = 'q'; // ----------------------------------
-------------------------------- { preob(num+2-
g); interface();
getch(); cout << "\n\n "; for (i=1;
i<=num; i++) cout << " X" << i << " = " <<
X[i]; + 2.73x 1.2 Расчёт
погрешности вычисления: 2.34*(-
0.025461) + 1.27*0.915112 + 3.15*0.335678 = 2,1599992 погрешность:
8,0*10 - 1.05*0.915112 -
0.63*0.335678 = -1,25000079 погрешность: 7,9*10 3.81x 1 1
+ 2.45x X1 = -12.660899 X2 = -16.107649 X3 = 5.273899 X4 = 66.299137 X1 = -12.132586 X2 = -14.858407 X3 = 5.186943 X4 = 63.347289 X1 = -11.604272 X2 = -13.609166 X3 = 5.099988 X4 = 60.39544 X1 = -11.075957 X2 = -12.359925 X3 = 5.013031 X4 = 57.443595 X1 = -10.547642 X2 = -11.110685 X3 = 4.926076 X4 = 54.491746 X1 = -10.019327 X2 = -9.861445 X3 = 4.839121 X4 = 51.539901 X1 = 13.959632
X2 = -39.106359
X3 =
7.324007 X4 = -
27.756765 X1 = 16.668562
X2 = -46.672114
X3 = 8.73446
X4 = -
33.605312 X1 = 19.377489
X2 = -54.237864
X3 = 10.144913
X4 = -
39.453861 X1 = 22.086416
X2 = -61.803618
X3 = 11.555367
X4 = -
45.30241 X1 = 24.795347
X2 = -69.369373
X3 = 12.96582
X4 = -
51.150959 X1 = 27.504276
X2 = -76.935127
X3 = 14.376274
X4 = -
56.999508 X1 = 1.033843 X2 = -1.696273 X3 = 0.997951 X4 = -0.211727 X1 = 1.191176 X2 = -2.016845 X3 = 1.183171 X4 = -0.486773 X1 = 1.348508 X2 = -2.337417 X3 = 1.36839 X4 = -0.761819 X1 = 1.505841 X2 = -2.657989 X3 = 1.55361 X4 = -1.036865 X1 = 1.663174 X2 = -2.978561 X3 = 1.73883 X4 = -1.311911 X1 = 1.820507 X2 = -3.299134 X3 = 1.92405 X4 = -1.586957 X1 = 0.772977
X2 = -0.794749
X3 = 0.762146
X4 = 0.13016 X1 = 0.872765 X2 = -0.954303 X3 = 0.902687 X4 = -0.008559 X1 = 0.972553 X2 = -1.113856 X3 = 1.043229 X4 = -0.147278 X1 = 1.072341 X2 = -1.27341 X3 = 1.18377 X4 = -0.285998 X1 = 1.172129 X2 = -1.432964 X3 = 1.324311 X4 = -0.424717 X1 = 1.271917 X2 = -1.592518 X3 = 1.464853 X4 = -0.563436 X1 = 0.675128
X2 = -0.476895
X3 =
0.645225 X4 =
0.196021 X1 = 0.754634 X2 = -0.580642 X3 = 0.763131 X4 = 0.105936 X1 = 0.83414 X2 = -0.68439 X3 = 0.881037 X4 = 0.015852 X1 = 0.913647 X2 = -0.788137 X3 = 0.998942 X4 = -0.074233 X1 = 0.993153 X2 = -0.891884 X3 = 1.116848 X4 = -0.164317 X1 = 1.072659 X2 = -0.995631 X3 = 1.234754 X4 = -0.254402
| |