3

My professor (Dutch) asked us to determine, among other things, the truncation error of the central Euler method. First of all, this is probably not the correct term, since there are very few results for "Central Euler", so that made looking things up a hassle.

To determine the truncation error, I thought I had to first know how to derive this central Euler method, given by: $$ u_{k+1}=u_{k-1} + 2h\cdot f(u_k) $$

(It also states $u_0$ and $u_1$ are given/known)

In which $f(x)$ gives the slope at point $x$ (I think).

I tried to derive this using Taylor expansions, but I didn't get close.

I also thought I had to get an intuitive notion of what this means, and I figured out it's this: We add two times the slope (times the step size) at $x=u_k$ to the the y-coordinate at $u_{k-1}$ to get the y coordinate at $x=u_{k+1}$. The two times is because the length between $k-1$ and $k+1$ is equal to $2h$.

So my question is: How do I derive this method, what's it called, and is the derivation a good step in figuring out the truncation error?

Note: It was given that the truncation error is of order $h^3$.

  • If this is for a beginner's course in numerical methods then it would make much more sense in my opinion to consider the explicit midpoint method (aka modified Euler method) $u_{k+1} = u_k + h f\left( u_k + \frac{h}{2} f(u_k) \right)$, which is a one-step method. For this method you might use the techniques which you were taught for forward/backward Euler. But the jump from one-step to two-step schemes is not so straightforward to understand simply in an exercise. – Christoph Jan 10 '19 at 10:29

2 Answers2

3

Local Truncation Error

You can also go the differentiation route, with $x=x_k$, $x\pm h=x_{k\pm 1}$ and $u_j= u(x_j)$ method step can be related to the the central difference quotient. With the Taylor expansion of $u$ we get $$ u(x\pm h)=u(x)\pm hu'(x)+\frac{h^2}{2}u''(x)\pm\frac{h^3}6u'''(x)+... \\~\\ \implies \frac{u(x+h)-u(x-h)}{2h}=u'(x)+\frac{h^2}{6}u'''(x)+O(h^4) $$ so that $$ \frac{u(x+h)-u(x-h)}{2h}-f(x,u(x))=O(h^2) $$ making this linear multi-step method a second order explicit method.


Global Error Approximation

The distance $d_k=u_k-u(x_k)$ of the numerical method solution $u_k$ to the exact solution $u(x_k)$ evolves as \begin{align} u_{k+1}&=u_{k-1}+2hf(u_k)\\ u(x_{k+1})&=u(x_{k-1})+2hf(u(x_k))+\frac{h^2}{6}u'''(x_k)+O(h^4)\\[1em] \hline d_{k+1}&=d_{k-1}+2h(f(u_k)-f(u(x_k))-\frac{h^3}3u'''(x_k)+...\\ &=d_{k-1}+2hf'(u(x_k))d_k-\frac{h^3}3u'''(x_k)+... \end{align} where the omitted terms are of higher order assuming that $hd_k^2$ is $O(h^4)$ or smaller.

Linear difference equation for the error terms: To get an easily solved problem, first assume that $h$ is small enough so that $u,f'(u),u'''$ are slowly changing over several steps. Then we can set them constant in the above recursion. The now linear recursion $$ d_{k+1}=d_{k-1}+2hf'd_k-\frac{h^3}3u''' $$ has for $f'\ne 0$ a solution $d_k=Aq^k+B(-q)^{-k}+C$ where $q>0$ solves $$ q^2-2hf'q+(hf')^2=1+(hf')^2\implies q=hf'+\sqrt{1+(hf')^2}=e^{hf'+O(h^3)} $$ The resulting form of the error terms is, up to higher order terms, $$d_k=Ae^{khf'}+(-1)^kBe^{-khf'}+C.$$

Differential equations for the error components: Translating the terms back into general functions, $d_k=a(x_k)+(-1)^kb(x_k)+c(x_k)$, we identify functions and their differential equations as \begin{align} a(x)&\simeq Ae^{(x-x_k)f'(u(x_k))}&\implies a'(x)&=f'(u(x))a(x),\\ b(x)&\simeq Be^{-(x-x_k)f'(u(x_k))}&\implies b'(x)&=-f'(u(x))b(x),\\ c(x_{k-1})-c(x_{k-1})&=2hf'c(x_k)-\frac{h^3}3u'''&\implies c'(x)&=f'(u(x))c(x)-\frac{h^2}{6}u'''(x) \end{align} with $u'''(x)=f''(u(x))[f(u),f(u)]+f'(u)^2f(u)$. The initial values are zero for the trend $c$ and account for the error in the first step in the oscillating parts $a,b$. \begin{align} c(x_0)&=0, \\ a(x_0)+b(x_0)&=0, \\ a(x_1)-b(x_1)&=u_1-u(x_1)-c(x_1)\approx e(x_0)h^{p+1}+\frac{h^3}{6}u'''(x_0) \end{align} This has as consequence that the trend of the error has order $c(x)=O(h^2)$ while the oscillating parts are of order $a(x),b(x)=O(h^3)$ if $p\ge 2$ for the order of the method for the initial step. If the initial step has only order $p=1$, the oscillating parts will reflect this lower order, their contribution will be of the same scale as the error trend curve $c$.

Experimental Error Order Confirmation

That this method is really of order 2 but rather sensitive to the computation of $u_1$ show the following graph depicting the scaled error of a numerical against an exact solution. That the error graphs converge visibly, in the latter paths alternating between an upper and a lower error function, confirms the order, as else the scaled error graphs would be largely different in scale.

error plots

The equation used is of the form $F(u, u')=F(p,p')$ with here $F(u,u')=u'+10\sin(u)$ and $p(t)=\cos(t)$, so that $$u'(t)=f(t,u)=10(\sin(\cos(t))-\sin(u(t))-\sin(t).$$ The error for the method applied with step size $h$ is divided by $h^2e^{5t}$, as the equation is slightly stiff and the error rapidly growing.

The initialization is from top down by the exact value $u_1=p(t_1)$, order 3 Heun, by the explicit midpoint method and lastly by the order insufficient Euler method. To decrease the influence of the first error, the step was computed with 5 method steps of step size $h/5$.

See Hairer/Nørsett/Wanner: Solving ODE I: Non-stiff problems, chapter III.9, where Figure 9.2 about this same method has a similar construction.

Lutz Lehmann
  • 126,666
  • I unfortunately don't recognize my expression in this answer. You use y and x and a function f that takes two arguments instead of 1? – The Coding Wombat Jan 09 '19 at 19:58
  • 1
    Set $x=x_k=x_0+kh$, then $u_k\simeq y(x_k)$. The formula is the usual formula for the local discretization error of a method, you insert an exact solution in both sides of the method and use Taylor expansion to find the difference between them. – Lutz Lehmann Jan 09 '19 at 20:16
  • So that last line can be rewritten to $u_{k+1}=u_{k-1}+2h\cdot f(u_k) + O(h^2)$? And is what's on the right side exactly equal to the exact value of $u_{k+1}$? If so, to get the complete error, I calculate the difference between this expression and the approxmiation (i.e. $u_{k-1}+2h\cdot f(u_k)$)? – The Coding Wombat Jan 09 '19 at 20:27
  • Also, where did you find the definition of the central difference? Especially the + third derivative and + O(h^4) part? I feel like I'm not searching the web correctly, since I'm having a hard time finding many aspects of numerical analysis. – The Coding Wombat Jan 09 '19 at 20:38
  • You just take the odd part of the Taylor series, $\frac12(y(x+h)-y(x-h))=y'(x)+\frac{h^3}{3!}y'''(x)+\frac{h^5}{5!}y^{(5)}(x)+\frac{h^7}{7!}y^{(7)}(x)+...$. – Lutz Lehmann Jan 09 '19 at 20:45
  • I don't see where that comes from, dividing by 2 on the left side? And why only take every odd part? – The Coding Wombat Jan 09 '19 at 21:05
  • 1
    The odd part of the function $g(h)=f(x+h)$ is $\frac12(g(h)-g(-h))$. The even part is $\frac12(g(h)+g(-h))$. The odd part of a power series contains only the odd powered terms, the even part complementarily the even powers. – Lutz Lehmann Jan 09 '19 at 21:27
2

It's a two-step Nyström method. Using the ODE $u' = f(u)$ and $x_k := x_0 + k h$ you write \begin{equation} u(x_{k+1}) - u(x_{k-1}) = \int \limits_{x_{k-1}}^{x_{k+1}} u'(x) \, \mathrm{d}x = \int \limits_{x_{k-1}}^{x_{k+1}} f(u(x)) \, \mathrm{d}x. \end{equation} Now you use a quadrature formula for the integral, in this case the midpoint rule: $\displaystyle \int \limits_{x_{k-1}}^{x_{k+1}} f(u(x)) \, \mathrm{d}x \simeq 2h f(u(x_k))$.


For the local truncation error at $x_2$ we assume that both previous values $u_0 = u(x_0)$ and $u_1 = u(x_1)$ are exact. The local truncation error is then given by \begin{equation} \tau_2 = u(x_2) - u(x_0) - 2 h f(u(x_1)) = u(x_2) - u(x_0) - 2 h u'(x_1) \end{equation} (using again the ODE in the last step). Now comes Taylor: \begin{eqnarray} u(x_0) = u(x_1 - h) &=& u(x_1) - h u'(x_1) + \frac{1}{2} h^2 u''(x_1) - \frac{1}{6} h^3 u'''(x_1) + \frac{1}{24} h^4 u''''(x_1) + O(h^5),\\ u(x_2) = u(x_1 + h) &=& u(x_1) + h u'(x_1) + \frac{1}{2} h^2 u''(x_1) + \frac{1}{6} h^3 u'''(x_1) + \frac{1}{24} h^4 u''''(x_1) + O(h^5), \end{eqnarray} for $h \rightarrow 0$, so that \begin{equation} \tau_2 = \frac{1}{3} h^3 u^{\prime\prime\prime}(x_1) + O(h^5), \quad h \rightarrow 0. \end{equation}

Christoph
  • 736
  • Cool way of writing that difference as the definite integral of a derivative! So does this mean that the approximation error in the midpoint rule for this integral is the same as the truncation error of the "central euler method"? – The Coding Wombat Jan 09 '19 at 20:08
  • 1
    That's right, I'll add something on the local truncation error. – Christoph Jan 09 '19 at 20:41
  • So, my $u_{k+1}$ in the expression in my question is an approximation for the real value corresponding to $x_2$, right? And the $u(x_2)$ is the exact value at $x_2$? If that's the case, I understand why we then subract the approximation from the exact value.

    I don't understand the taylor expansion of $u(x_0)$ tho, where do the minus signs come from, and how do you expand to a higher $x_i$?

    – The Coding Wombat Jan 09 '19 at 21:02
  • 1
    Yes, I did it for $k=1$ only, you can do it for any $k$ of course. The two expressions above are just Taylor expansions of $u(x_0) = u(x_1 - h)$ (note the minus sign!) and of $u(x_2) = u(x_1 + h)$ around $x_1$. – Christoph Jan 09 '19 at 21:05
  • One more thing: In your formula for $\tau$ you use $u(x_2)$ and $u(x_0)$ and $u(x_1)$, but here the first is an exact value for every iteration right? But the second and third are approximate results from previous iterations if I'm not mistaken? (So in this case $x_0$ and $x_1$ are exact in this example, because they were given, but I mean for the next and subsequent iterations). – The Coding Wombat Jan 09 '19 at 21:16
  • You are right, but for the local truncation error we always assume that the previous values $u_{k-1}, u_k$ are exact and we check the error of the next value, $u_{k+1}$, which is no longer exact. See https://en.wikipedia.org/wiki/Truncation_error_(numerical_integration)#Extension_to_linear_multistep_methods for example. – Christoph Jan 09 '19 at 21:19