Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <math.h>
- #include <fstream>
- using namespace std;
- #define AMOUNT 1000
- double f(double y) {
- return (0.9 * y - 0.1 * pow(y, 2));
- }
- int main() {
- double a = 0.9, b = 0.1, h = 0.01;
- double Y[AMOUNT];
- Y[0] = 1;
- Y[1] = Y[0] + h * f(Y[0]);
- Y[2] = Y[1] + h * f(Y[1]);
- Y[3] = Y[2] + h * f(Y[2]);
- cout << "y_" << "0" << ": " << Y[0] << endl;
- for (size_t k = 2; k<AMOUNT; k++) {
- Y[k+1] = (1.33333 * Y[k] - 0.333333 * Y[k - 1]) + 0.666666 * h * f(Y[k + 1]);
- if (AMOUNT == 1000) {
- if (k % 2 != 0) {
- cout << "y_" << k << ": " << Y[k] << endl;
- }
- } else { cout << "y_" << k << ": " << Y[k] << endl; }
- }
- //proverka
- cout << "y_" << "0" << ": " << Y[0] << endl;
- cout << "y_" << "1" << ": " << Y[1] << endl;
- cout << "y_" << "2" << ": " << Y[2] << endl;
- cout << "y_" << "3" << ": " << Y[3] << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement