I am trying to solve a Poisson equation using a second-order finite difference approximation: $ \frac{\partial^2 u_{i,j}}{\partial x^2} = \frac{u_{i-1,j} -2 u_{i,j} + u_{i+1,j} }{h^2} + O(h^2) $.
The equation is:
$ \frac{\partial^2 u}{\partial x^2} + \frac{ \partial^2 u}{\partial y^2} = - \pi^2 sin(\pi*x) sin(\pi*y) $,
The exact solution is: $ u = sin(\pi*x) sin(\pi*y) $.
I am trying to compute the error using an $l^2$ norm: $T = \sum_{i,j} \sqrt{ | u_{i,j}^2 - \tilde{u}_{i,j}^2 |} $...
Qualitatively, my approximation looks great, but the error is of order$ 10^{1} $! I thought that it might just be a few spikes here and there, but when I do a surface plot of the exact solution minus the approximation, I have a nice smooth oscillating pattern with amplitude ~0.3.
Is this normal for approximating PDEs? I thought that the second order difference approximation was order 2. Shouldn't that mean that the overall error is ~$h^2$?
Thank you!