Local truncation error of Crank-Nicolson for PDE $u_t+au_x = 0$
Let us write the Crank-Nicolson method for the linear advection equation $u_t + au_x = 0$ by averaging forward and backward Euler time-integration and by using centered spatial differences: $$ \frac{u_{j}^{n+1} - u_j^n}{\Delta t} = -\frac{a}{2}\left(\frac{u_{j+1}^n - u_{j-1}^n}{2\Delta x} + \frac{u_{j+1}^{n+1} - u_{j-1}^{n+1}}{2\Delta x}\right) , \qquad u_j^n \simeq u(j\Delta x, n\Delta t) . \tag{1} $$ Thus, the scheme reads $ u_{j}^{n+1} = u_j^n - \frac{1}{4} p\big(u_{j+1}^n - u_{j-1}^n + u_{j+1}^{n+1} - u_{j-1}^{n+1}\big) = 0 $, where $p = {a \Delta t}/{\Delta x}$ denotes the Courant number. To perform the local truncation error analysis, we need to expand the smooth function $u$ as a Taylor series in two variables in the vicinity of $(x, t)$. Doing so at the third order, we have \begin{aligned} v &= u + h u_x + k u_t + \tfrac{1}{2} \left( h^2 u_{xx} + 2 hk u_{xt} + k^2 u_{tt}\right) \\ &+ \tfrac{1}{6} \left( h^3 u_{xxx} + 3 h^2 k u_{xxt} + 3 h k^2 u_{xtt} + k^3 u_{ttt}\right) + O(h^4 + k^4) \end{aligned} with the notation $v(x,t) = u(x+h, t+k)$ for the steps $h \in \lbrace{0, \pm\Delta x}\rbrace$ and $k \in \lbrace{0,\Delta t}\rbrace$. Assuming that $u$ satisfies the PDE $u_t = -au_x$, we replace time-derivatives by spatial derivatives as follows $$ v = u + (h-ak)u_x + \tfrac{1}{2} ( h-ak)^2 u_{xx} + \tfrac{1}{6} ( h-ak)^3 u_{xxx} + O(h^4 + k^4) . $$ For a fixed value of the Courant number, we obtain the following expressions to be substituted in the numerical scheme $(1)$: \begin{aligned} v_{j}^{n+1} &= u - p\Delta x\,u_x + \tfrac{1}{2}(p\Delta x)^2 u_{xx} - \tfrac{1}{6} (p\Delta x)^3 u_{xxx} + O(\Delta x^4) \\ v_j^n &= u \\ v_{j\pm 1}^{n} &= u \pm \Delta x\,u_x + \tfrac{1}{2} \Delta x^2 u_{xx} \pm \tfrac{1}{6} \Delta x^3 u_{xxx} + O(\Delta x^4) \\ v_{j\pm 1}^{n+1} &= u + (\pm 1 -p)\Delta x\, u_x + \tfrac{1}{2} ( \pm 1-p)^2\Delta x^2 u_{xx} + \tfrac{1}{6} ( \pm 1 -p)^3\Delta x^3 u_{xxx} + O(\Delta x^4) \end{aligned} The divided finite-difference operators become \begin{aligned} \frac{v_{j}^{n+1} - v_j^n}{\Delta t} &= {-a} u_x + \tfrac{1}{2}pau_{xx} \Delta x - \tfrac{1}{6} p^2 au_{xxx} \Delta x^2 + O(\Delta x^3) \, , \\ \frac{v_{j+1}^{n} - v_{j-1}^n}{2\Delta x} &= u_x + \tfrac{1}{6} u_{xxx} \Delta x^2 + O(\Delta x^3) \, , \\ \frac{v_{j+1}^{n+1} - v_{j-1}^{n+1}}{2\Delta x} &= u_x - pu_{xx}\Delta x + \tfrac{1}{6} (1 + {3}p^2) u_{xxx} \Delta x^2 + O(\Delta x^3) \end{aligned} leading to the local truncation error $a u_{xxx} \big({\tfrac{1}{6}} + \tfrac{1}{12} p^2\big) \Delta x^2 + O(\Delta x^3)$.