%  Runge-Kutta 4th order

% Next 4 constants are for Exercise #9, p.143.
% You will need to change for other examples.
x0=0;
y0=1;
c=1;
N=4;

h=(c-x0)/N;
x=x0;
y=y0;
for i=1:N
   %  The function f(x,y) is x+1-y in this example.
   %  You will need to change the following four lines.
   k1=h* ( x+1-y );
   k2=h* ( (x+h/2) + 1 - (y+k1/2) );
   k3=h* ( (x+h/2) + 1 - (y+k2/2) );
   k4=h* ( (x+h) + 1 - (y+k3) );
   
   x=x+h;
   y=y+(1/6)*(k1+2*k2+2*k3+k4);
   
   x   %prints x
   y   %prints y
   
   end;