Midpoint flux stencil for one-dimensional diffusion (source code)

= Midpoint flux stencil for one-dimensional diffusion
{title2=$L_hv_j=h^{-2}[a_{j-1/2}(v_{j-1}-v_j)+a_{j+1/2}(v_{j+1}-v_j)]$}

For $u_t=(au_x)_x$, this conservative <finite difference method> uses coefficient samples at edge midpoints. For smooth $a,u$, its spatial residual is $h^2(au_{xxxx}/12+a'u_{xxx}/6+a''u_{xx}/8+a'''u_x/24)+O(h^4)$. With zero <Dirichlet boundary conditions>, $-v^TL_hv=h^{-2}\sum_j a_{j+1/2}(v_{j+1}-v_j)^2$. If $0<a\leq a_+$, its <eigenvalues> lie in $[-4a_+/h^2,0]$, giving the mesh-independent <Forward Euler method> bound $\Delta t/h^2\leq1/(2a_+)$. Constant $a=a_+$ proves sharpness as the grid is refined.