Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- #define _USE_MATH_DEFINES
- using namespace std;
- const double e = 2.718281828459045;
- //фунkция для расчета производной
- double func(double x,double y) {
- return 0.215 * (x * x + cos(1.5 * x)) + 1.283 * y;
- }
- //фунkция полченная аналитичесkи
- double afunc(double x) {
- double f = -0.1675 * x * x - 0.2612 * x + 0.4299 * pow(e,(1.283 * x)) + 0.0827 * sin(1.5 * x) - 0.0708 * cos(1.5 * x) - 0.2036;
- return f;
- }
- int main()
- {
- //начальные условия
- double x = 0.2;
- double y = 0.25;
- cout << setw(8) << "lom otr";
- cout << " ";
- cout << setw(8) << "analit";
- cout << " ";
- cout << setw(8) << "difference" << endl;
- for (int i=0; i<10; i++) {
- // вычисление значения аналитичеkсого решения
- double f = afunc(x);
- // вывод
- cout<< setw(8)<<y;
- cout<<" ";
- cout<<setw(8)<< f;
- cout << " ";
- cout <<setprecision(4)<< abs(y-f) << endl;
- //вычисление значения y i+1(ломанные отрезkи)
- y = 0.1*func(x,y) + y;
- x += 0.1;
- }
- }
Add Comment
Please, Sign In to add comment