Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- double f(double x)
- {
- return exp(x)*sin(2 * x);
- }
- double xi(double x, int i, double h)
- {
- return x + i * h;
- }
- double FPrimRSP(double x, double h)
- {
- return (-1 * f(xi(x, 2, h)) + 4 * f(xi(x, 1, h)) - 3 * f(x)) / (2 * h);
- }
- double FBisRSP(double x, double h)
- {
- return (-1 * f(xi(x, 3, h)) + 4 * f(xi(x, 2, h)) - 5 * f(xi(x, 1, h)) + 2 * f(x)) / pow(h, 2);
- }
- double FTerRSP(double x, double h)
- {
- return (-3 * f(xi(x, 4, h)) + 14 * f(xi(x, 3, h)) - 24 * f(xi(x, 2, h)) + 18 * f(xi(x, 1, h)) - 5 * f(x)) / (2 * pow(h, 3));
- }
- double FPrimRST(double x, double h)
- {
- return (3 * f(x) - 4 * f(xi(x, -1, h)) + f(xi(x, -2, h))) / (2 * h);
- }
- double FBisRST(double x, double h)
- {
- return (2 * f(x) - 5 * f(xi(x, -1, h)) + 4 * f(xi(x, -2, h)) - f(xi(x, -3, h))) / pow(h, 2);
- }
- double FTerRST(double x, double h)
- {
- return (5 * f(x) - 18 * f(xi(x, -1, h)) + 24 * f(xi(x, -2, h)) - 14 * f(xi(x, -3, h)) + 3 * f(xi(x, -4, h))) / (2 * pow(h, 3));
- }
- double FPrimRSC(double x, double h)
- {
- return (f(xi(x, 1, h)) - f(xi(x, -1, h))) / (2 * h);
- }
- double FBisRSC(double x, double h)
- {
- return (f(xi(x, 1, h)) - 2 * f(x) + f(xi(x, -1, h))) / (pow(h, 2));
- }
- double FTerRSC(double x, double h)
- {
- return (f(xi(x, 2, h)) - 2 * f(xi(x, 1, h)) + 2 * f(xi(x, -1, h)) - f(xi(x, -2, h))) / (2 * pow(h, 3));
- }
- int main()
- {
- double h = 1.e-4;
- double x;
- cout << "Podaj x: " << endl;
- cin >> x;
- cout << "RSP" << endl;
- cout << "F'(" << x << ")" << "\t" << FPrimRSP(x, h) << endl;
- cout << "F''(" << x << ")" << "\t" << FBisRSP(x, h) << endl;
- cout << "F'''(" << x << ")" << "\t" << FTerRSP(x, h) << endl;
- cout << "RST" << endl;
- cout << "F'(" << x << ")" << "\t" << FPrimRST(x, h) << endl;
- cout << "F''(" << x << ")" << "\t" << FBisRST(x, h) << endl;
- cout << "F'''(" << x << ")" << "\t" << FTerRST(x, h) << endl;
- cout << "RSC" << endl;
- cout << "F'(" << x << ")" << "\t" << FPrimRSC(x, h) << endl;
- cout << "F''(" << x << ")" << "\t" << FBisRSC(x, h) << endl;
- cout << "F'''(" << x << ")" << "\t" << FTerRSC(x, h) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement