[求助]解常微分方程组问题
dy1/dt=998*y1+1998*y2
dy2/dt=-999*y1-1999*y2
初始的y1=1; y2=0;
我编写的程序如下:
function y1y2
y1=1; y2=0;
t1=0.1; t2=0.02;
h1=0.1;h2=0.02;
while(t1<=1)
n=0;
while(n<5)
k11=-999*y1-1999*y2;
k22=-999*y1-1999*(y2+h2*k11/2);
k33=-999*y1-1999*(y2+h2*k22/2);
k44=-999*y1-1999*(y2+h2*k33);
y2=y2+h2*(k11+2*k22+2*k33+k44)/6;
n=n+1;
t2=t2+h2;
end
k1=998*y1+1998*y2;
k2=998*(y1+h1*k1/2)+1998*y2;
k3=998*(y1+h1*k2/2)+1998*y2;
k4=998*(y1+h1*k3)+1998*y2;
y1=y1+h1*(k1+2*k2+2*k3+k4)/6
t1=t1+h1;
w=y1;
y1=y2;
y2=w;
end
可是结果一直都不对,不知道是怎么回事,请高手帮忙看看!不胜感激~