Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- #define epsilon 0.00001
- double f(const double x) {return 5*pow(x,5) + 3*pow(x,3) + 1 ;}
- double Integrate(const double a, const double b)
- {
- if(b-a < epsilon)
- return (f(a)*(b-a) + f(b)*(b-a))/2;
- else
- return Integrate(a, (a + b)/2) + Integrate((a + b)/2, b);
- }
- int main()
- {
- cout << "int_-2^+3 (5*x^5+3*x^3+1)dx = " << Integrate(-2,3) << endl;
- cout << endl << " \u25b2" << endl;
- cout << "\u25b2 \u25b2" << endl << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement