Appendix: Useful formulas

Finite difference operator notation

$$ \begin{align} u'(t_n) &\approx \lbrack D_tu\rbrack^n = \frac{u^{n+\half} - u^{n-\half}}{\Delta t} \tag{393}\\ u'(t_n) &a\approx \lbrack D_{2t}u\rbrack^n = \frac{u^{n+1} - u^{n-1}}{2\Delta t} + \tag{394}\\ u'(t_n) &= \lbrack D_t^-u\rbrack^n = \frac{u^{n} - u^{n-1}}{\Delta t} \tag{395}\\ u'(t_n) &\approx \lbrack D_t^+u\rbrack^n = \frac{u^{n+1} - u^{n}}{\Delta t} \tag{396}\\ u'(t_{n+\theta}) &= \lbrack \bar D_tu\rbrack^{n+\theta} = \frac{u^{n+1} - u^{n}}{\Delta t} \tag{397}\\ u'(t_n) &\approx \lbrack D_t^{2-}u\rbrack^n = \frac{3u^{n} - 4u^{n-1} + u^{n-2}}{2\Delta t} \tag{398}\\ u''(t_n) &\approx \lbrack D_tD_t u\rbrack^n = \frac{u^{n+1} - 2u^{n} + u^{n-1}}{\Delta t^2} \tag{399}\\ u(t_{n+\half}) &\approx \lbrack \overline{u}^{t}\rbrack^{n+\half} = \half(u^{n+1} + u^n) \tag{400}\\ u(t_{n+\half})^2 &\approx \lbrack \overline{u^2}^{t,g}\rbrack^{n+\half} = u^{n+1}u^n \tag{401}\\ u(t_{n+\half}) &\approx \lbrack \overline{u}^{t,h}\rbrack^{n+\half} = 2\frac{\frac{1}{u^{n+1}} + \frac{1}{u^n}} \tag{402}\\ u(t_{n+\theta}) &\approx \lbrack \overline{u}^{t,\theta}\rbrack^{n+\theta} = \theta u^{n+1} + (1-\theta)u^n ,\quad t_{n+\theta}=\theta t_{n+1} + (1-\theta)t_{n-1} \tag{403} \end{align} $$

Truncation errors of finite difference approximations

$$ \begin{align} \uex'(t_n) &= [D_t\uex]^n + R^n = \frac{\uex^{n+\half} - \uex^{n-\half}}{\Delta t} +R^n\nonumber,\\ R^n &= -\frac{1}{24}\uex'''(t_n)\Delta t^2 + {\cal O}(\Delta t^4) \tag{404}\\ \uex'(t_n) &= [D_{2t}\uex]^n +R^n = \frac{\uex^{n+1} - \uex^{n-1}}{2\Delta t} + R^n\nonumber,\\ R^n &= -\frac{1}{6}\uex'''(t_n)\Delta t^2 + {\cal O}(\Delta t^4) \tag{405}\\ \uex'(t_n) &= [D_t^-\uex]^n +R^n = \frac{\uex^{n} - \uex^{n-1}}{\Delta t} +R^n\nonumber,\\ R^n &= -\half\uex''(t_n)\Delta t + {\cal O}(\Delta t^2) \tag{406}\\ \uex'(t_n) &= [D_t^+\uex]^n +R^n = \frac{\uex^{n+1} - \uex^{n}}{\Delta t} +R^n\nonumber,\\ R^n &= -\half\uex''(t_n)\Delta t + {\cal O}(\Delta t^2) \tag{407}\\ \uex'(t_{n+\theta}) &= [\bar D_t\uex]^{n+\theta} +R^{n+\theta} = \frac{\uex^{n+1} - \uex^{n}}{\Delta t} +R^{n+\theta}\nonumber,\\ R^{n+\theta} &= -\half(1-2\theta)\uex''(t_{n+\theta})\Delta t + \frac{1}{6}((1 - \theta)^3 - \theta^3)\uex'''(t_{n+\theta})\Delta t^2 + \nonumber\\ &\quad {\cal O}(\Delta t^3) \tag{408}\\ \uex'(t_n) &= [D_t^{2-}\uex]^n +R^n = \frac{3\uex^{n} - 4\uex^{n-1} + \uex^{n-2}}{2\Delta t} +R^n\nonumber,\\ R^n &= \frac{1}{3}\uex'''(t_n)\Delta t^2 + {\cal O}(\Delta t^3) \tag{409}\\ \uex''(t_n) &= [D_tD_t \uex]^n +R^n = \frac{\uex^{n+1} - 2\uex^{n} + \uex^{n-1}}{\Delta t^2} +R^n\nonumber,\\ R^n &= -\frac{1}{12}\uex''''(t_n)\Delta t^2 + {\cal O}(\Delta t^4) \tag{410} \end{align} $$ $$ \begin{align} \uex(t_{n+\theta}) &= [\overline{\uex}^{t,\theta}]^{n+\theta} +R^{n+\theta} = \theta \uex^{n+1} + (1-\theta)\uex^n +R^{n+\theta},\nonumber\\ R^{n+\theta} &= -\half\uex''(t_{n+\theta})\Delta t^2\theta (1-\theta) + {\cal O}(\Delta t^3) \tp \tag{411} \end{align} $$

Finite differences of exponential functions

Complex exponentials

Let \( u^n = \exp{(i\omega n\Delta t)} = e^{i\omega t} \). $$ \begin{align} [D_tD_t u]^n &= u^n \frac{2}{\Delta t}(\cos \omega\Delta t - 1) = -\frac{4}{\Delta t}\sin^2\left(\frac{\omega\Delta t}{2}\right), \tag{412}\\ [D_t^+ u]^n &= u^n\frac{1}{\Delta t}(\exp{(i\omega\Delta t)} - 1), \tag{413}\\ [D_t^- u]^n &= u^n\frac{1}{\Delta t}(1 - \exp{(-i\omega\Delta t)}), \tag{414}\\ [D_t u]^n &= u^n\frac{2}{\Delta t}i\sin{\left(\frac{\omega\Delta t}{2}\right)}, \tag{415}\\ [D_{2t} u]^n &= u^n\frac{1}{\Delta t}i\sin{(\omega\Delta t)} \tag{416} \tp \end{align} $$

Real exponentials

Let \( u^n = \exp{(\omega n\Delta t)} = e^{\omega t} \). $$ \begin{align} [D_tD_t u]^n &= u^n \frac{2}{\Delta t}(\cos \omega\Delta t - 1) = -\frac{4}{\Delta t}\sin^2\left(\frac{\omega\Delta t}{2}\right), \tag{417}\\ [D_t^+ u]^n &= u^n\frac{1}{\Delta t}(\exp{(i\omega\Delta t)} - 1), \tag{418}\\ [D_t^- u]^n &= u^n\frac{1}{\Delta t}(1 - \exp{(-i\omega\Delta t)}), \tag{419}\\ [D_t u]^n &= u^n\frac{2}{\Delta t}i\sin{\left(\frac{\omega\Delta t}{2}\right)}, \tag{420}\\ [D_{2t} u]^n &= u^n\frac{1}{\Delta t}i\sin{(\omega\Delta t)} \tag{421} \tp \end{align} $$

Finite differences of \( t^n \)

The following results are useful when checking if a polynomial term in a solution fulfills the discrete equation for the numerical method. $$ \begin{align} \lbrack D_t^+ t\rbrack^n = 1, \tag{422}\\ \lbrack D_t^- t\rbrack^n = 1, \tag{423}\\ \lbrack D_t t\rbrack^n = 1, \tag{424} \lbrack D_{2t} t\rbrack^n = 1, \tag{425} \lbrack D_{t}D_t t\rbrack^n = 0 \tag{426} \tp \end{align} $$

The next formulas concern the action of difference operators on a \( t^2 \) term. $$ \begin{align} \lbrack D_t^+ t^2\rbrack^n = (2n+1)\Delta t, \tag{427}\\ \lbrack D_t^- t^2\rbrack^n = (2n-1)\Delta t, \tag{428}\\ \lbrack D_t t^2\rbrack^n = 2n\Delta t, \tag{429} \lbrack D_{2t} t^2\rbrack^n = 2n\Delta t, \tag{430} \lbrack D_{t}D_t t^2\rbrack^n = 2, \tag{431} \end{align} $$

Finally, we present formulas for a \( t^3 \) term: These must be controlled against lib.py. Use \( t_n \) instead of \( n\Delta t \)?? $$ \begin{align} \lbrack D_t^+ t^3\rbrack^n &= 3(n\Delta t)^2 + 3n\Delta t^2 + \Delta t^2, \tag{432}\\ \lbrack D_t^- t^3\rbrack^n &= 3(n\Delta t)^2 - 3n\Delta t^2 + \Delta t^2, \tag{433}\\ \lbrack D_t t^3\rbrack^n &= 3(n\Delta t)^2 + \frac{1}{4}\Delta t^2, \tag{434}\\ \lbrack D_{2t} t^3\rbrack^n &= 3(n\Delta t)^2 + \Delta t^2, \tag{435}\\ \lbrack D_{t}D_t t^3\rbrack^n &= 6n\Delta t, \tag{436} \end{align} $$