# define _USE_MATH_DEFINES include stdlib include math include stdio inc

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65``` ```#define _USE_MATH_DEFINES #include #include #include #include float f( float x ) { //printf("Points=%.9f ", x); float k=tan(x); //printf("tan=%.9f ", k); return k; } float F( float x ) { float p; p=-log(fabs(cos(x))); return -log(fabs(cos(x))); } /* функция численного интегрирования */ float Integral(float Left, float Right, int n, float (*func)(float)) { int i; float res,h; res=0.0; //printf("Left=%.9f ",Left); h = (Right - Left) / n; for(i = 0; i < n-1; i++) { //printf("Func=%.9f ", f(Left + h * (i+0.5))); res+= f(Left + h * (i + 0.5)); //->printf("res=%.9f\n",res); } printf("lastf = %.9f\n", Left + (Right-Left) * (n - 1 + 0.5)/n); printf(" %.9f\n", (Right+(Left+h*i))/2); printf("lastd = %.9lf\n", (double)Left + (((double)Right - (double)Left) / n) * (n - 1 + (double)0.5)); printf(" %.9lf\n", ((double)Right/2)+((double)Left+(((double)Right - (double)Left) / n)*i)/2); //printf("///////%.9f\n", Left+h*i); res *= h; //printf("Func1=%.7f ", (Right - (Left+h*i))); res += (Right - (Left+h*i))*f((Right/2)+(Left+h*i)/2); //->printf("res=%.9f\n",res); return res; } int main() { long n; float D = 1.57079; float L =-D/*M_PI/4*/, R =D/*M_PI/4*/; float V, V0 = F( R ) - F( L ); printf("V0=%.9f\n", V0); setlocale( LC_ALL, "" ); /* точное решение */ printf("Число шагов;абсолютная ошибка\n"); for ( n = 1; n < 100 ;n += n/100+1) { V = Integral( L, R, n, f ); /* приближенное решение для n шагов */ printf( "%ld;=%.9f\n", n, (V-V0) ); /* n и абсолютная ошибка */ } return 0; } ```