Initial value problems 259
explicit Euler. There are 4 function evaluations in RK4 compared to 1 function
evaluation in explicit Euler, but you should not expect a ratio of exactly 4 —
there are still a few more calculations besides just evaluating the function. The
noise at the small values of ∆xare just system noise from the computer doing
5
6npts = 50;
7dx vec = logspace(-5,0,npts);
8xmax = 10;
9xmin = 0;
20 fprintf(‘Integrating for dx = %8.6f \n’,dx)
21 n = ceil((xmax-xmin)/dx + 1); %total number of steps, …
round-off
22
23 %make the exact solution
33 y implicit = implicit euler(dx,xmin,ymin,n);
34 time implicit(i) = toc;
35
36 if i == 1
37 h = figure;