SHARE
TWEET

Untitled

a guest Mar 24th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <locale.h>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. double moya(double x) {
  7.     return sqrt(1 - x * x);
  8. }
  9.  
  10. double Integrate(double a, double b, int n) {
  11.     double ans = 0;
  12.     double temp = (b - a) / n;
  13.     for (double i = 0; i < n; ++i) {
  14.         double xi = a + temp * i;
  15.         double xi1 = a + temp * (i + 1);
  16.         ans += moya((xi + xi1) / 2) * (xi1 - xi);
  17.     }
  18.     return ans;
  19. }
  20.  
  21. int main() {
  22.     setlocale(LC_ALL, "Rus");
  23.     double a, b;
  24.     cout << "Введите пределы интегрирования:(в моём задании от 0 до 1)\n";
  25.     cin >> a >> b;
  26.     double p = 8;
  27.     cout << "интеграл равен pi/4 = " << atan(1) << "\n";
  28.     cout << "n:\terr_n:\t\ts_n:\n";
  29.     for (int i = 3; i < 16; ++i) {
  30.         auto ans = abs(atan(1) - Integrate(a, b, p));
  31.         auto ans2 = log(ans) / (log(b - a) - log(p));
  32.         cout << p << "\t" << ans << "\t" << ans2 << "\n";
  33.         p *= 2;
  34.     }
  35.     return 0;  
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top