Advertisement
nikminer4sv

Untitled

Dec 21st, 2022
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. double n = 1;
  2.         double h = (b - a) / n;
  3.  
  4.         double ih = 1;
  5.         double previous = 0.0;
  6.  
  7.         while (Math.Abs(ih - previous) >= 15 * epsilon) {
  8.             previous = ih;
  9.             double sum = 0;
  10.             for (int i = 1; i < n; ++i) {
  11.                 sum += i % 2 == 0 ? 2 * Function1(i * h + a) : 4 * Function1(i * h + a);
  12.             }
  13.  
  14.             ih = (sum + Function1(a) + Function1(b)) * h / 3;
  15.             n *= 2;
  16.             h /= 2;
  17.         }
  18.  
  19.         return ih;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement