Even-reflection closure for Neumann diffusion (source code)

= Even-reflection closure for Neumann diffusion
{title2=$U_{-j}=U_j,\quad U_{N+j}=U_{N-j}$}

For the <heat equation> with homogeneous <Neumann boundary conditions> at both ends of a uniform grid, even reflection supplies ghost values for a centered <finite difference method>. A <fourth-order centered second derivative> needs two ghost values at each end, obtained with the displayed rule for $j=1,2$. For a sufficiently smooth compatible solution, differentiating the <Neumann boundary conditions> in time and using the <heat equation> makes every odd spatial derivative vanish at the endpoints. Its even extension therefore retains the smoothness required by the fourth-order stencil; arbitrary incompatible initial data need care at the initial boundary corners.

The discrete cosine modes diagonalize this reflected spatial operator, with <eigenvalues> $-4h^{-2}\sin^2(\theta/2)[1+\sin^2(\theta/2)/3]$ and $\theta=j\pi/N$. Its most negative <eigenvalue> is $-16/(3h^2)$, so the <forward Euler method> is stable in the corresponding trapezoid-weighted norm when $\Delta t/h^2\leq3/8$. The <Crank-Nicolson diffusion scheme> is stable for every time step for this closure, but its amplification factor approaches $-1$ on highly damped spatial modes, allowing sign-alternating numerical transients. The ghost values are defined here as auxiliary samples outside the physical interval, rather than additional unknown initial data.