I consider ordinary wave equation$$ u_{tt} - u_{xx} = 0 $$ with initial conditions$$u(x, 0) = \exp (-2 x^2) \\u_t(x, 0) = 0 $$To solve this problem I approximate $u_{xx}$ with 4-th order difference scheme and find time evolution with symplectic 4-th order method.I use following parameters:$$x_{min} = -500 \\x_{max} = 500 \\dx = 0.5 \\dt = 0.1 $$The problem is that, for example, in the point $x=0$ this algorithm perfectly works for $t < 1000$ (note that this value equals $x_{max} - x_{min} = 2 x_{max}$ But then evolution looks quite strange. Here is a picture of this.I tried to fix boundary value manually (at every step set $u(x_{min}, t) = u(x_{max}, t) = 0, \ u_t (x_{min}, t) = u_t (x_{max}, t) = 0 $ )and also tried to use exponential suppression to avoid radiation from boundaries. The $u_{xx}$ approximation with finite difference is used only for points which are more than 2 steps distant from boundaries to avoid problems.It seems that the problem lies in the presence of boundaries, because such symplectic algorithm works fine for harmonic oscillator (where there are no boundaries) for any time value.UPD: The stencil I use for partial derivative:$$u_{xx} (x) = \frac{-u(x-2) + 16 u(x-1) - 30 u(x) + 16 u(x+1) - u(x+2)}{12 (dx)^2} $$
Symplectic integration of PDE
pde;numerical analysis;numerical