Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5.  
  6. #define epsilon 0.00001
  7.  
  8. double f(const double x) {return 5*pow(x,5) + 3*pow(x,3) + 1 ;}
  9.  
  10. double Integrate(const double a, const double b)
  11. {
  12. if(b-a < epsilon)
  13. return (f(a)*(b-a) + f(b)*(b-a))/2;
  14. else
  15. return Integrate(a, (a + b)/2) + Integrate((a + b)/2, b);
  16. }
  17.  
  18. int main()
  19. {
  20. cout << "int_-2^+3 (5*x^5+3*x^3+1)dx = " << Integrate(-2,3) << endl;
  21. cout << endl << " \u25b2" << endl;
  22. cout << "\u25b2 \u25b2" << endl << endl;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement