Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- #include <sstream>
- #include <iomanip>
- #include <cmath>
- #include <math.h>
- #define prt(x) cout << x << endl
- using namespace std;
- double h = 0.05;
- double x0 = M_PI / 6;
- double f(double x) {
- return pow(sin(x), 2);
- }
- int main() {
- system("color F2");
- ifstream fin("in.txt");
- ofstream fout("res.txt");
- double f1_x0 = (f(x0 + h) - f(x0 - h)) / (2 * h);
- prt(f1_x0);
- double f1_x0_t = (8 * (f(x0 + h) - f(x0 - h)) + f(x0 - 2 * h) - f(x0 + 2 * h))
- / (12 * h);
- prt(f1_x0_t);
- prt(sin(2 * x0));
- prt("");
- double f2_x0 = (f(x0 + h) + f(x0 - h) - 2 * f(x0)) / (h* h);
- prt(f2_x0);
- double f2_x0_t = (16 * (f(x0 + h) + f(x0 - h))
- - 30 * f(x0)
- - f(x0 + 2 * h) - f(x0 - 2 * h)) / (12 * h* h);
- prt(f2_x0_t);
- prt(2 * cos(2 * x0));
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement