Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- double integral(double a, double b, int n)
- {
- double h = (b-a) / n;
- double sum = 0;
- double x;
- for(x = a; x <= b; x++)
- sum += cos(exp(x)); // или как там посчитать это значение
- return sum * h;
- }
- int main(void)
- {
- double a = 0.25, b = 2.76; // Смотри, вот переменные близки по смыслу — я написал их в одной строке
- int n = 1;
- double old_integral, new_integral = integral(a, b, n);
- do
- {
- old_integral = new_integral;
- n *= 2;
- new_integral = integral(a, b, n);
- }
- while(fabs(old_integral-new_integral) > 0.0001);
- printf("%lf", new_integral);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement