Mathematics 285 Fourth-Order Runge-Kutta

restart;
f:=(s,t)->0.2*s*t;
x[0]:=1;
y[0]:=1;
n:=64;
h:=5.0/n;
for i from 0 to n-1 do
   x[i+1]:=x[0]+h*(i+1);
   k1:=h*f(x[i],y[i]);
   k2:=h*f(x[i]+0.5*h,y[i]+0.5*k1);
   k3:=h*f(x[i]+0.5*h,y[i]+0.5*k2);
   k4:=h*f(x[i+1],y[i]+k3);
   y[i+1]:=y[i]+(1.0/6.0)*(k1+2*(k2+k3)+k4);
od:
plot([seq([x[i],y[i]],i=0..n)]);
Last Updated: Sat Sep 11 18:38:48 PDT 2004