Finite Difference

Finite difference tends to be quite simple to implement, by far the most difficult part is incorporating the boundary condition. One can either build the boundary condition into the finite difference matrix by including a constant in the basis, or build it into the right-hand-side vector. The former approach may break symmetry of the differential operator etc. Thus one should almost always take the latter approach.

In particular, the 2D laplacian can be put on a n-by-n grid. In lexigraphical order, the laplacian can be build out of a bunch of block tridiagonal matrices plus two off diagonal bands. Factor out the \(\frac{1}{h^2}\), each block matrix will have -4 on the diagonal and 1 on off diagonal. It is crucial at this step that the entire n-by-n matrix does NOT have identically 1 on the off diagonal. The off diagonal has a 0 every n steps.