I have built a program which implements RK4 method to solve ODEs. I want to show my program can find a specific value correct to 5 decimal places. How would I prove this?
-
Compute the same value with a different step size and use that to estimate the error. – Lutz Lehmann Mar 29 '19 at 15:51
-
What do you mean? I've tried halving the step size, but how does that help estimate error – user3376601 Mar 29 '19 at 20:10
1 Answers
You know that the global error order is $4$. Thus the error of step size $h$ is $Ch^4$ plus higher order terms. Now compute $$y_1=y_*+Ch^4+O(h^5)$$ and once again with half the step size $$y_2=y_*+C(h/2)^4+O(h^5).$$ From these two identities you can compute $y_*$ and $Ch^4$ as $$ y_*=\frac{16y_2-y_1}{15}~~\text{ and }~~ Ch^4=\frac{16}{15}(y_1-y_2). $$ There is a working region of $h$ where this estimate of the error of $y_1$ is good, $C$ being constant in the first two digits, which is sufficient for error estimates. If $h$ is too large, then the higher order terms influence the error noticeably. If $h$ is too small, then the floating point computation over the large number of steps accumulates too much noise which then dominates the method error.
- 126,666