Assume a multistep method with order $p$. Then for the global error we have: $$ \| y_{n+1} - y(x_{n+1}) \| = O(h^p) \leq K h^p $$ Given the above, if we divide the step $h$ by $2$, then $$ \frac{e_{new}}{e_{old}} \approx 2^{-p} $$ where $e$ denotes the global error.
Having this in mind, I'm trying to test it, using bdf3 method, with the problem:
$$ \begin{cases} y' = 2\sqrt{y-1} \\ y(0) = 5 \end{cases} $$
for $t \in [0,2]$, with analytical solution: $y(t) = 1 + (t+2)^2$.
However, the sequence of $-\log_2(\frac{e_{new}}{e_{old}})$ doesn't converge to $3$ as expected, instead its value after some iterations seems to be around $-1$, which doesn't make sense to me.
Here's the Matlab script:
clf
% Initialize problem
y0 = 5;
t0 = 0;
tfinal = 2;
errors = [];
error_ratios = [];
for k = 2:10
h = 2^(-k);
[tout, yout] = bdf3('f3', t0, tfinal,h,y0);
if k == 2
err = max(abs(yout-f3true(tout)));
errors = [errors err];
else
err_prev = err;
err = max(abs(yout-f3true(tout)));
err_ratio = -log2(err/err_prev);
errors = [errors, err];
error_ratios = [error_ratios, err_ratio];
end
end
format short g;
disp(errors);
disp(error_ratios);
Output:
1.6941e-05 7.0892e-07 2.6055e-08 8.8711e-10 2.8844e-11 5.8442e-13 7.7804e-13 1.2896e-12 2.9665e-12
4.5787 4.766 4.8763 4.9427 5.6251 -0.41284 -0.72904 -1.201
