//clc() disp("f(x,y) = 4*exp(0.8*x) - 0.5*y") //f'(x,y) = 4*exp(0.8*x) - 0.5*y x = 0:2:2; y(1) = 2; h =2; t = 14.84392; k1 = 4*exp(0.8*x(1)) - 0.5*y(1); x1 = x(1) + h/2; y1 = y(1) + k1*h/2; k2 = 4*exp(0.8*x1) - 0.5*y1; x1 = x(1) + h/2; y1 = y(1) + k2*h/2; k3 = 4*exp(0.8*x1) - 0.5*y1; x1 = x(1) + h; y1 = y(1) + k3*h; k4 = 4*exp(0.8*x1) - 0.5*y1; y(2) = y(1) + (k1 + 2*k2 + 2*k3 + k4)*h/6; e = (t - y(2))/(t); disp(y(1:2),"y by h = 2 is") disp(e,"error = ") h = 1; x = 0:h:2; for i=1:3 k1(i) = 4*exp(0.8*x(i)) - 0.5*y(i); x1 = x(i) + h/2; y1 = y(i) + k1(i)*h/2; k2(i) = 4*exp(0.8*x1) - 0.5*y1; x1 = x(i) + h/2; y1 = y(i) + k2(i)*h/2; k3(i) = 4*exp(0.8*x1) - 0.5*y1; x1 = x(i) + h; y1 = y(i) + k3(i)*h; k4(i) = 4*exp(0.8*x1) - 0.5*y1; y(i+1) = y(i) + (k1(i) + 2*k2(i) + 2*k3(i) + k4(i))*h/6; end e = (t - (y(3)))/t; disp(y(1:3),"y by h = 1 is") disp(e,"error = ")