ФІО = Skliarov to Gorbachenko Запитання: #include #include #include #include using namespace std; double lagrange(double *xmas, double *ymas, int n, double x, double &dx) { double rez = 0, f; for(int i = 0; i < n; i++) { f = 1.0; for(int j = 0; j < n; j++) { if (i != j) f *= (x - *(xmas + j))/(*(xmas + i) - *(xmas + j)); } rez += *(ymas + i)*f; } dx = fabs(pow(x,0.5) - rez); return rez; } int main() { double a; double * xmas; double * ymas; double * reslt; double dx, err = 0; xmas=(double*)malloc(8*sizeof(double)); ymas=(double*)malloc(8*sizeof(double)); reslt=(double*)malloc(11*sizeof(double)); for(int i=0;i<8;i++) { *(xmas+i)= cos((2*i+1)*M_PI/16)+1; } for(int i=0;i<8;i++) { *(ymas+i)=pow(*(xmas+i),0.5); } double F=0; for(int i = 0; i < 11; i++) { *(reslt + i) = lagrange(xmas, ymas, 8, i*0.2, dx); if (dx > err) err = dx; } cout<<"Znachenia x "<<"Table(function)"<<" "<<"Interpolation"<