3 лаба численные методы
.pdfx[1] = (a[1][3] - x[2] * a[1][2]) / a[1][1];
x[0] = (a[0][3] - a[0][2] * x[2] - a[0][1] * x[1]) / a[0][0]; cout << "a = "<< x[2] << endl;
cout << "b = "<< x[1] << endl; cout << "c = "<< x[0] << endl; cout << "\n\t""Таблица : " << endl; for (int u = 0, h = 0; u < 3; u++) { cout << "\nВведитеx : ";
cin >> x0;
for (h = 0; h < 13; h++) { if (x0 == n[0]) {
tempX1 = n[0]; tempX2 = n[1]; tempX3 = n[2]; break;
}
if (x0 <= n[h]) {
tempX1 = n[h - 1]; tempX2 = n[h]; tempX3 = n[h + 1]; break;
}
if (x0 >= n[11]) {
tempX1 = n[9]; tempX2 = n[10]; tempX3 = n[11]; break;
}
11
if (x0 >= n[11]) {
tempX1 = n[9]; tempX2 = n[10]; tempX3 = n[11]; break;
}
}
cout << "f("<< x0 << ") = " << func(x0) << endl;
cout << "Полином Лагранжа при x = " << x0 << ": " << ((((x0 - tempX2)*(x0 -
tempX3)) / ((tempX1 - tempX2)*(tempX1 - tempX3)))*func(tempX1) +
(((x0 -
tempX1)*(x0 - tempX3)) / ((tempX2 - tempX1)*(tempX2 - tempX3)))*func(tempX2)
+ (((x0 - tempX1)*(x0 - tempX2)) / ((tempX3 - tempX1)*(tempX3 - tempX2)))*func(tempX3))
<< endl;
cout << "Аппроксимация при x = "<< x0 << ": "<< x[2] * pow(x0, 2) + x[1] * x0 +
x[0] << endl;
}
system("pause"); return 0;
}
12