Runge-Kutta算法!

来源:学生作业帮助网 编辑:六六作业网 时间:2024/05/29 08:07:47
Runge-Kutta算法!Runge-Kutta算法!Runge-Kutta算法!#includevoidmain(){doublex0,y0,h,N;doublex1,y1,K1,K2,K3,K4

Runge-Kutta算法!
Runge-Kutta算法!

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