> help euler_step the program takes the intial data y_0 at the initial time x_0 and computes up to time x_final using n timesteps. It creates two vectors, x and y, which you can then plot against each other plot(x,y) [x,y] = euler_step(y_0,x_0,x_final,n) compute the approximate solution y1, and the exact solution y1_true. We're solving the problem y'=3y with initial data y(0)=4. > [x1,y1] = euler_step(4,0,1,10); > y1_true = 4*exp(3*x1); > plot(x1,y1_true); hold on; plot(x1,y1,'o'); > [x2,y2] = euler_step(4,0,1,20); > y2_true = 4*exp(3*x2); > plot(x2,y2_true); hold on; plot(x2,y2,'ro'); > [x3,y3] = euler_step(4,0,1,40); > y3_true = 4*exp(3*x3); > plot(x3,y3_true); hold on; plot(x3,y3,'go'); Looking at the plots of the approximate solutions, they appear to be going to the true solution. Note that the various x and y vectors are of different lengths... > whos x* y* Name Size Bytes Class x1 1x11 88 double array x2 1x21 168 double array x3 1x41 328 double array y1 1x11 88 double array y1_true 1x11 88 double array y2 1x21 168 double array y2_true 1x21 168 double array y3 1x41 328 double array y3_true 1x41 328 double array Grand total is 219 elements using 1752 bytes To reach time 1, we have to look at the 11th, 21st, and 41st components: > x1(11) ans = 1 > x2(21) ans = 1 > x3(41) ans = 1 The errors are initially huge, but appear to be decreasing... > y1(11) - y1_true(11) ans = -25.1988 > y2(21) - y2_true(21) ans = -14.8760 > y3(41) - y3_true(41) ans = -8.1652 We check the ratio of the errors... they appear to be going to 2... > (y1(11) - y1_true(11))/(y2(21)-y2_true(21)) ans = 1.6939 > (y2(21)-y2_true(21))/(y3(41)-y3_true(41)) ans = 1.8219 Compute more solutions with finer time-steps to see if it's really converging like O(dt). > [x4,y4] = euler_step(4,0,1,80); > y4_true = 4*exp(3*x4); > [x5,y5] = euler_step(4,0,1,160); > y5_true = 4*exp(3*x5); > [x6,y6] = euler_step(4,0,1,320); > y6_true = 4*exp(3*x6); The ratios are all getting closer to 2. > (y3(41)-y3_true(41))/(y4(81)-y4_true(81)) ans = 1.9031 > (y4(81)-y4_true(81))/(y5(161)-y5_true(161)) ans = 1.9493 > (y5(161)-y5_true(161))/(y6(321)-y6_true(321)) ans = 1.9741