Runge-Kutta算法!

来源:学生作业学帮网 编辑:学帮网 时间:2024/06/10 20:14:53

Runge-Kutta算法!

#include
void main(){
double x0,y0,h,N;
double x1,y1,K1,K2,K3,K4;
coutx0>>y0;
coutN;
couth;
double f(double x,double y);
for(int n=1;n!=N;n++,x0=x1,y0=y1)
{
x1=x0+h;
K1=f(x0,y0);
K2=f(x0+h/2,y0+(h/2)*K1);
K3=f(x0+h/2,y0+(h/2)*K2);
K4=f(x0+h,y0+h*K3);
y1=y0+h/6*(K1+2*K2+2*K3+K4);
}
cout