Bellaard.com

Nine-point stencil for 2D laplacian

By: Gijs Bellaard

Suppose you have some sufficiently smooth black-box function \(f: \mathbb{R}^2 \rightarrow \mathbb{R} \) of which you want to know the laplacian at the point \(x\). We introduce the following shorthand: \[ f = f(x) \] \[ f_{i,j} = f(x+ih,y+jh)\] where \(h\) is the spacing. Then the laplacian at the point of interest is: \[ \Delta f \approx \frac{1}{3h^2} \left( f_{-1,1} + f_{0,1} + f_{1,1} + f_{-1,0} - 8f + f_{1,0} + f_{-1,-1} + f_{0,-1} + f_{1,-1} \right) \] with an error of \(\mathcal{O}(h^2)\). It's not actually better than the five point stencil in accuracy but it does help smooth out the grid artifacts.