Advertisement
Guest User

Untitled

a guest
May 20th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <fstream>
  4. #include <vector>
  5. #include <string>
  6. #include <sstream>
  7. #include <iomanip>
  8. #include <cmath>
  9. #include <math.h>
  10. #define prt(x) cout << x << endl
  11. using namespace std;
  12.  
  13. double h = 0.05;
  14. double x0 = M_PI / 6;
  15.  
  16. double f(double x) {
  17. return pow(sin(x), 2);
  18. }
  19.  
  20.  
  21. int main() {
  22. system("color F2");
  23. ifstream fin("in.txt");
  24. ofstream fout("res.txt");
  25.  
  26. double f1_x0 = (f(x0 + h) - f(x0 - h)) / (2 * h);
  27. prt(f1_x0);
  28.  
  29. double f1_x0_t = (8 * (f(x0 + h) - f(x0 - h)) + f(x0 - 2 * h) - f(x0 + 2 * h))
  30. / (12 * h);
  31. prt(f1_x0_t);
  32. prt(sin(2 * x0));
  33. prt("");
  34.  
  35. double f2_x0 = (f(x0 + h) + f(x0 - h) - 2 * f(x0)) / (h* h);
  36. prt(f2_x0);
  37.  
  38. double f2_x0_t = (16 * (f(x0 + h) + f(x0 - h))
  39. - 30 * f(x0)
  40. - f(x0 + 2 * h) - f(x0 - 2 * h)) / (12 * h* h);
  41. prt(f2_x0_t);
  42.  
  43. prt(2 * cos(2 * x0));
  44. system("pause");
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement