Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale.h>
- #include <cmath>
- using namespace std;
- double moya(double x) {
- return sqrt(1 - x * x);
- }
- double Integrate(double a, double b, int n) {
- double ans = 0;
- double temp = (b - a) / n;
- for (double i = 0; i < n; ++i) {
- double xi = a + temp * i;
- double xi1 = a + temp * (i + 1);
- ans += moya((xi + xi1) / 2) * (xi1 - xi);
- }
- return ans;
- }
- int main() {
- setlocale(LC_ALL, "Rus");
- double a, b;
- cout << "Введите пределы интегрирования:(в моём задании от 0 до 1)\n";
- cin >> a >> b;
- double p = 8;
- cout << "интеграл равен pi/4 = " << atan(1) << "\n";
- cout << "n:\terr_n:\t\ts_n:\n";
- for (int i = 3; i < 16; ++i) {
- auto ans = abs(atan(1) - Integrate(a, b, p));
- auto ans2 = log(ans) / (log(b - a) - log(p));
- cout << p << "\t" << ans << "\t" << ans2 << "\n";
- p *= 2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement