Math 2280-2, Project #1, Problem #6This problem shows that even an accurate numerical method like Runge-Kutta 4, is susceptible to problems that are unstable.x0:=0.; xn:=4.; # first and last points in the interval
y0:=1; # initial condition
n:=80; # number of steps
h:=(xn-x0)/n; # step sizex:=x0; y:=y0;
f:=(x,y)->5*y - 6*exp(-x); # slope function (rhs in DE dy/dx = f(x,y))
printf("%15s, %15s, %15s\134n","x_i","y_i","y(x_i)");
for i from 1 to n do
k1:= f(x,y): # left hand slope
k2:= f(x+h/2,y+h*k1/2): # midpoint slope: first approx.
k3:= f(x+h/2,y+h*k2/2): # midpoint slope: second approx.
k4:= f(x+h,y+h*k3): # right hand slope approx.
k:=(k1+2*k2+2*k3+k4)/6: # Simpson's integration rule
y:= y + h*k: # RK4 update
x:= x+h: # increase x
if frac(i/8)=0 then
printf("%15.2f, %15.10f, %15.10f\134n",x,y,exp(-x));
end if;
od: # end for i loop