Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cmath>
- using namespace std;
- double f (double a)
- {
- return sin(a);
- }
- double trapezy(double a, double b, int N)
- {
- double h = (b-a)/N;
- double P = (f(a)+f(b))/2;
- for(int i=1; i<N; i++)
- P += f(a+i*h);
- return P*h;
- }
- main()
- {
- for(int i=100; i<10000000; i*=10)
- {cout.precision(15);
- cout<<trapezy(0, M_PI, 1000000)<<endl;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement