Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <random>
- #include <math.h>
- #include <iostream>
- int main()
- {
- std::default_random_engine rnd(7);
- std::weibull_distribution<double> distribution(0.5, 1.0);
- double eta = 0;
- double k = 1;
- double s = 0;
- double s1 = 0;
- int N = 100000;
- for (int i = 0; i < N; i++)
- {
- double x = distribution(rnd);
- double y = distribution(rnd);
- eta = 4 * cos(2 * k * pow(x * y, 0.5)) * (exp(-(x+y)+pow(x,0.5)+pow(y,0.5)));
- s += eta;
- s1 += eta * eta;
- }
- std::cout << s << '\n';
- double d = s1 / N - pow(s / N, 2);
- std::cout <<"precise value"<<"\n"<<M_PI/sqrt(1+k*k) << "\n";
- std::cout <<"approximate value"<< "\n" << s / N << "\n";
- std::cout<<"miscalculation"<< "\n" << 3 * sqrt(d / N);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement