Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. double f(double x) // Функция y(x)
  2.     {
  3.         return (2*exp(3.0 * x - x*x));
  4.     }
  5.  
  6. double S(double a, double b) // Поиск интеграла от a до b (Метод прямоугольников)
  7. {
  8.     int n = 50;
  9.     double s=(f(a)+f(b))/2;
  10.     double h=(b-a)/n;
  11.     for (int i=1; i<=n-1; i++)
  12.     {
  13.         s+=f(a+i*h);
  14.     }
  15.     double I=h*s;
  16.     return I;
  17. }
  18.  
  19. double SS(double a, double b, double E) // Поиск интеграла от a до t
  20. {
  21.     double t = a;
  22.     double s1 = 0;
  23.  
  24.     while (fabs(s1 - S(a, b)/2) >= E)
  25.     {
  26.         t = t + E;
  27.         s1 = S(a, t);
  28.        
  29.     }  
  30.     return t;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement