📄 runge-kutta.h
字号:
#include "iostream.h"
#include "math.h"
rungekutta(double h, double xstart, double y, double xend)
{
double x = xstart, k1, k2, k3, k4;
for(int i = 0; i < (xend - xstart) / h; i++)
{
k1 = feuler(x, y);
k2 = feuler(x + h / 2, y + h * k1 / 2);
k3 = feuler(x + h / 2, y + h * k2 / 2);
k4 = feuler(x + h, y + h * k3);
y = y + h * (k1 + 2 * k2 + 2 * k3 + k4) / 6;
x += h;
double ytemp = 1 / (1 + x * x);
cout << i + 1 << "\t" << x << "\t" << y << "\t" << ytemp << "\t" << sqrt((y - ytemp)*(y - ytemp)) << endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -